#include #include #include #include int time_base_den(char *path) { FILE *file = fopen(path,"r"); if( file ) { fclose(file); av_register_all(); avcodec_register_all(); AVFormatContext *ps=NULL; int ret=avformat_open_input(&ps,path,NULL,NULL); //int ret=av_open_input_file(&ps,path,NULL,0,NULL); //printf("avformat_open_input ret:%i\n",ret); if(ret==0) { avformat_find_stream_info(ps,NULL); AVCodecContext *enc = ps->streams[0]->codec; //return ps->bit_rate; return enc->time_base.den; } else return -1; } else return -1; } //enc->time_base.num int time_base_num(char *path) { FILE *file = fopen(path,"r"); if( file ) { fclose(file); av_register_all(); avcodec_register_all(); AVFormatContext *ps=NULL; int ret=avformat_open_input(&ps,path,NULL,NULL); //int ret=av_open_input_file(&ps,path,NULL,0,NULL); //printf("avformat_open_input ret:%i\n",ret); if(ret==0) { avformat_find_stream_info(ps,NULL); AVCodecContext *enc = ps->streams[0]->codec; //return ps->bit_rate; return enc->time_base.num; } else return -1; } else return -1; } int bitrate(char *path) { FILE *file = fopen(path,"r"); if( file ) { fclose(file); av_register_all(); avcodec_register_all(); AVFormatContext *ps=NULL; // oneiric ffmpeg int ret=avformat_open_input(&ps,path,NULL,NULL); //int ret=av_open_input_file(&ps,path,NULL,0,NULL); //printf("avformat_open_input ret:%i\n",ret); if(ret==0) { avformat_find_stream_info(ps,NULL); return ps->bit_rate; } else return -1; } else return -1; } int res_x(char *path) { FILE *file = fopen(path,"r"); if( file ) { fclose(file); av_register_all(); avcodec_register_all(); AVFormatContext *ps=NULL; // oneiric ffmpeg int ret=avformat_open_input(&ps,path,NULL,NULL); //int ret=av_open_input_file(&ps,path,NULL,0,NULL); //printf("avformat_open_input ret:%i\n",ret); if(ret==0) { avformat_find_stream_info(ps,NULL); AVCodecContext *enc = ps->streams[0]->codec; //return ps->bit_rate; return enc->width; } else return -1; } else return -1; } int res_y(char *path) { FILE *file = fopen(path,"r"); if( file ) { fclose(file); av_register_all(); avcodec_register_all(); AVFormatContext *ps=NULL; // oneiric ffmpeg int ret=avformat_open_input(&ps,path,NULL,NULL); //int ret=av_open_input_file(&ps,path,NULL,0,NULL); //printf("avformat_open_input ret:%i\n",ret); if(ret==0) { avformat_find_stream_info(ps,NULL); AVCodecContext *enc = ps->streams[0]->codec; //return ps->bit_rate; return enc->height; } else return -1; } else return -1; } int main(int args,char* argv[]) { printf("Bitrate=%d\n",bitrate("/tmp/downvideo")); printf("x=%d y=%d\n",res_x("/tmp/downvideo"),res_y("/tmp/downvideo")); return 0; }