简体   繁体   English

无法使用FFMPEG API将H264配置文件从Main更改为High

[英]Not able to change H264 profile to High from Main using FFMPEG API

I am using QtFFMPEG wrapper( https://code.google.com/p/qtffmpegwrapper/ ) with Qt 5.4 and MSCV 2012. I want to encode a mp4 video from image files at 25 fps and high profile. 我正在Qt 5.4和MSCV 2012上使用QtFFMPEG包装器( https://code.google.com/p/qtffmpegwrapper/ )。我想以25 fps和高配置从图像文件中编码mp4视频。 I used the createFile() and encodeImage() functions from here 我从这里使用了createFile()和encodeImage()函数

I am using the below parameters: 我正在使用以下参数:

pCodecCtx=pVideoStream->codec;
pCodecCtx->codec_id = pOutputFormat->video_codec;
pCodecCtx->codec_type = ffmpeg::AVMEDIA_TYPE_VIDEO;
pCodecCtx->profile=FF_PROFILE_H264_HIGH;
pCodecCtx->bit_rate = Bitrate;
pCodecCtx->width = getWidth();
pCodecCtx->height = getHeight();
pCodecCtx->time_base.den = fps;
pCodecCtx->time_base.num = 1;
pCodecCtx->gop_size = 10;
pCodecCtx->pix_fmt = ffmpeg::PIX_FMT_YUV420P;
pCodecCtx->qmin = 10;
pCodecCtx->qmax = 51;

The FFMPEG variables are: FFMPEG变量是:

License: %s
 GPL version 3 or later
AVCodec version %d
 3476480
AVFormat configuration: %s
 --disable-static --enable-shared --enable-gpl --enable-version3 --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib

Now I currently get a video with below properties: 现在,我现在获得具有以下属性的视频:

ID                             : 1
Format                         : AVC
Format/Info                    : Advanced Video Codec
Format profile                 : Main@L3.2
Format settings, CABAC         : No
Format settings, ReFrames      : 1 frame
Format settings, GOP           : M=1, N=10
Codec ID                       : avc1
Codec ID/Info                  : Advanced Video Coding
Duration                       : 4s 320ms

I want the profile to be "High" and the CABAC to be yes with 3 ReFrames. 我希望配置文件为“高”,并且希望CABAC为3 ReFrame。 How do I achieve that? 我该如何实现? I tried setting the profile, coder_type and max_b_frames but did not help. 我尝试设置配置文件,coder_type和max_b_frames,但没有帮助。 At times the generated file did not even play. 有时生成的文件甚至无法播放。 Can anyone help please. 谁能帮忙。 Thanks. 谢谢。

I also tried using the av_opt_set() way but could not find that function. 我也尝试使用av​​_opt_set()方法,但找不到该函数。 Only function I have is av_opt_set_dict(), am I missing something - outdated FFMPEG or missing #include. 我唯一的功能是av_opt_set_dict(),我缺少什么了吗-FFMPEG过时或缺少#include。

Tried this too, didnt help- 也尝试过这个,没有帮助-

   ffmpeg::AVDictionary *opt = NULL;
   int iRes = av_dict_set(&opt, "profile", "high", 0);
   av_opt_set_dict(pFormatCtx->priv_data, &opt);
   av_opt_set_dict(pFormatCtx, &opt);

Please help. 请帮忙。

EDIT: I got a high quality mp4 by changing the qmin and qmax values and then reencoding the big sized output via command line. 编辑:通过更改qmin和qmax值,然后通过命令行重新编码大尺寸输出,我得到了高质量的mp4。 I will try to upgrade the FFMPEG as suggested by Ronald below. 我将尝试按照以下Ronald的建议升级FFMPEG。 Please consider the question closed for now. 请考虑暂时关闭的问题。

 AVCodec version %d 3476480 

That version (libavcodec 53.12.0) is from October 2011, please update to something newer. 该版本(libavcodec 53.12.0)是从2011年10月开始的,请更新到较新的版本。 As you can see from the H264 encoding wiki docs , your settings will work with recent versions of ffmpeg. H264编码wiki文档中可以看到,您的设置将与ffmpeg的最新版本一起使用。 (Also please share the rest of your code, you're just showing the code that sets your settings, but not any other part of your code, so I can't reproduce anything.) (还请共享您的其余代码,您只是在显示设置设置的代码,而不是代码的其他部分,因此我无法重现任何内容。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM