简易改写Ffmpeg
来源:互联网 发布:变频器仿真软件下载 编辑:程序博客网 时间:2024/04/29 19:35
防止调用Ffmpeg 的方法时导致主线程退出
注意: 需要对应修改exit_program()!!
源代码:
用 ffmpeg_cleanup(0);
代替 exit_program(received_nb_signals ? 255 : main_return_code);
读取文件信息:
int ff_PrintFile(char * filepath)
{
AVFormatContext * pFormatContext=NULL;
av_register_all();
pFormatContext = avformat_alloc_context();
if(avformat_open_input(&pFormatContext,filepath,NULL,NULL)!=0)
{
printf("Can not open the media file you specified!\n");
return -1;
}
if(avformat_find_stream_info(pFormatContext, NULL) < 0){
return -1;
}
av_dump_format(pFormatContext, 0, filepath, 0);
printf("\n****************file information*****************\n");
int video_stream=-1;
int audio_stream=-1;
int i=0;
for (i = 0; i < (int)pFormatContext->nb_streams; i++) {
AVStream* ist = pFormatContext->streams[i];
printf(" Stream #%d: timebase={num=%d, den=%d}\n", i, ist->time_base.num, ist->time_base.den);
if(pFormatContext->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO)
{
video_stream=i;
}
if(pFormatContext->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO)
{
audio_stream=i;
}
}
if(audio_stream==-1&&video_stream==-1)return -1;
printf("\n");
printf("input:%s",pFormatContext->iformat->long_name);
AVCodecContext *pCodecCtx,*pCodecCtx_au;
if(video_stream!=-1)
{
pCodecCtx=pFormatContext->streams[video_stream]->codec;
printf("size:%d x %d",pCodecCtx->width,pCodecCtx->height);
float framerate_temp=(pFormatContext->streams[video_stream]->r_frame_rate.num)/(pFormatContext->streams[video_stream]->r_frame_rate.den);
printf("framerate:%5.2ffps",framerate_temp);
}
printf("\n");
if(audio_stream!=-1)
{
pCodecCtx_au=pFormatContext->streams[audio_stream]->codec;
//pCodec_au=avcodec_find_decoder(pCodecCtx_au->codec_id);
//printf("%s",pCodecCtx_au->codec->name);
printf("profile:%d",pCodecCtx_au->profile);
printf("level:%d",pCodecCtx_au->level);
printf("sample_rate:%d",pCodecCtx_au->sample_rate);
printf("channels:%d",pCodecCtx_au->channels);
}
printf("bit_rate:%5.2fkbps",pFormatContext->bit_rate/1000.0);
int tns, thh, tmm, tss;
tns = (pFormatContext->duration)/1000000;
thh = tns / 3600;
tmm = (tns % 3600) / 60;
tss = (tns % 60);
printf("\n");
printf("duration:%02d:%02d:%02d",thh,tmm,tss);
printf("\n");
AVDictionaryEntry *m = NULL;
while(m=av_dict_get(pFormatContext->metadata,"",m,AV_DICT_IGNORE_SUFFIX))
{
printf("%s:",m->key);
printf("%s",m->value);
printf("\n");
}
printf("\n****************file information*****************\n");
avformat_close_input(&pFormatContext);
return 0;
}
修改文件作者和专辑等信息
可在opt 下方法open_output_file添加
av_dict_set(&oc->metadata, "artist", "ffedu", AV_DICT_MATCH_CASE);
av_dict_set(&oc->metadata, "album", "ffedu", AV_DICT_MATCH_CASE);
- 简易改写Ffmpeg
- credential Provider 简易改写攻略
- 简易的$_GET获取改写过滤函数
- Ffmpeg 安装,改写Ffmpeg并封装成so
- Ubuntu16.04,ffmpeg搭建简易监控环境
- 一个基于ffmpeg的简易视频播放器
- mfc对话框做一个简易的ffmpeg视频播放器
- ffmpeg实战教程(二)用SDL播放YUV,并结合ffmpeg实现简易播放器
- 改写Riched20
- 改写url
- 改写整数
- 改写方法
- 改写load_system
- 改写atoi
- 改写小游戏
- 改写进度条
- ramfs--改写
- 2.1改写
- sql 取dataTime的天
- Bootstrup的炫酷jQuery开关按钮插件
- WebKit加载流程 - 概述
- 关于编写服务应用程序的一点总结
- hdu 1305 Immediate Decodability (字典树)
- 简易改写Ffmpeg
- 维护在线redo log
- VC获取系统时间、程序运行时间(精确到秒,毫秒)的五种方法
- Java 基础知识No.1——Java的类和对象
- 新的想法不是关键
- 关于EditText或WebView文字长按,actionMode出错问题解决方案
- CentOS-6.3安装配置JDK-7
- CSS3和js谷歌Material Design进度条插件
- osgearth2.5 Container