All pastes #923580 Raw Edit

Miscellany

public c v1 · immutable
#923580 ·published 2008-02-29 17:52 UTC
rendered paste body
int get_media_attr(struct dlfile *dl){  AVFormatContext *ic;  AVFormatParameters params, *ap = &params;  AVInputFormat *file_iformat = NULL;  int err, ret,i ;  av_register_all();  err = av_open_input_file(&ic, dl->localpath, file_iformat, 0, ap);  if (err < 0) {    return -1;  }  ret = av_find_stream_info(ic);  if (ret < 0) {    printf("%s: could not find codec parameters\n", dl->localpath);    return -1;  }  printf("Duration: %lld\n", ic->duration);  printf("Bitrate: %d\n", dl->total_size / (ic->duration / AV_TIME_BASE));  /*Free*/  for(i = 0; i < ic->nb_streams; i++) {    av_freep(&ic->streams[i]->codec);    av_freep(&ic->streams[i]);  }  url_fclose(ic->pb);  av_free(file_iformat);  av_free(ic);  return 0;}