Opened 12 years ago
Closed 12 years ago
#1548 closed defect (invalid)
avcodec ignores profile when using ffmpeg C API
Reported by: | TheSHEEEP | Owned by: | |
---|---|---|---|
Priority: | important | Component: | avcodec |
Version: | 0.10.4 | Keywords: | libx264 |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
I first posted this on stackoverflow as I thought this was my mistake (maybe it is), but was encouraged that this might be a bug in ffmpeg.
I am encoding an h264 mp4 in code using the latest ffmpeg libraries on Windows. I definitely set the profile property of the AVCodecContext to FF_PROFILE_H264_CONSTRAINED_BASELINE.
However, no matter what I set the profile property to, the video always ends up using the "High" profile instead of "Constrained Baseline".
As the command line "-profile:v baseline" works, this is either a bug in the libraries. Or something else must be set from the user, in addition to the profile. In the latter case, this must definitely be communicated to people using this. Like me ;)
See the link for more info:
http://stackoverflow.com/questions/11537830/ffmpeg-api-h264-encoded-video-does-not-play-on-all-platforms
I have also attached the *.cpp that includes the functions used to encode the video.
Attachments (2)
Change History (13)
by , 12 years ago
Attachment: | ffmpeg_dll.cpp added |
---|
by , 12 years ago
Attachment: | ffmpeg_dll.h added |
---|
comment:2 by , 12 years ago
What would av_opt_set do any different than setting the profile value directly?
follow-up: 4 comment:3 by , 12 years ago
They do not do the same thing at all. One affects the codec private options, the other the codec context. libx264 uses a private option.
comment:4 by , 12 years ago
Replying to Cigaes:
They do not do the same thing at all. One affects the codec private options, the other the codec context. libx264 uses a private option.
Okay, I will try that, but I have problems compiling when using av_opt_set although I do link against avutil.lib (unresolved external symbol, really strange). I'll have to figure that one out, first.
comment:5 by , 12 years ago
Got that one sorted out.
But when I do av_opt_set(avc, "profile", "base", 0), I get the error messages:
"Undefined constant or missing '(' in 'base'"
and
"Unable to parse option value "base""
follow-up: 7 comment:6 by , 12 years ago
"base" is not a x264 profile. You can probably find the list of supported profiles in the documentation of x264. I do not know where is the best place to look for x264 documentation, but "x264 documentation profile" in a search engine would probably be a good start.
comment:7 by , 12 years ago
Well, according to this ( http://mewiki.project357.com/wiki/X264_Settings ), "baseline" should do the trick. But I get the same error message, just with "baseline" instead of "base". I also tried with Baseline, Constrained Baseline, etc. All the same error message.
I also tried this:
av_opt_set_int(codecContext, "profile", (int64_t)FF_PROFILE_H264_CONSTRAINED_BASELINE, AV_OPT_SEARCH_CHILDREN);
The result was: No error, but still "High" profile.
comment:8 by , 12 years ago
The problem with error was, as it seems, that I have to use av_set_opt AFTER avcodec_open2(c, codec, NULL).
When I do it like this:
if (avcodec_open2(c, codec, NULL) < 0) { av_log(c, AV_LOG_ERROR, "%s","could not open video codec\n"); exit(1); } av_opt_set(c, "profile", "baseline", AV_OPT_SEARCH_CHILDREN);
The error is gone, but the video remains of "High" profile. I really start to think that this is a bug.
comment:9 by , 12 years ago
You are right, this is not the correct code: the option must not be set after the codec is opened, but when the codec is opened, using the thirs argument of avcodec_open2
.
comment:10 by , 12 years ago
I got it working!
You need to use the priv_data instead of the context itself. I got the hint when searching for "av_opt_set profile".
So this works:
av_opt_set(c->priv_data, "profile", "baseline", AV_OPT_SEARCH_CHILDREN);
And I actually do it before calling avcodec_open2().
Consider this resolved. And thanks for the support!
Uhm... can I close this or will a dev/mod do that?
comment:11 by , 12 years ago
Keywords: | libx264 added; Profile h264 Baseline removed |
---|---|
Resolution: | → invalid |
Status: | new → closed |
Our ffmpeg dll