[FFmpeg-devel] [PATCH]lavc/avcodec: Allow libavcodec to overwrite profile and level
sw at jkqxz.net
Fri Nov 24 13:13:07 EET 2017
On 24/11/17 02:54, Jeyapal, Karthick wrote:
> On 11/24/17, 5:17 AM, "Carl Eugen Hoyos" <ceffmpeg at gmail.com> wrote:
>> 2017-11-23 22:58 GMT+01:00 Michael Niedermayer <michael at niedermayer.cc>:
>>> On Thu, Nov 23, 2017 at 04:01:06PM +0100, Carl Eugen Hoyos wrote:
>>>> The (external) encoders may overwrite level and profile because of
>>>> requested encoding properties, allowing libavcodec to (also) overwrite
>>>> them in the context makes sense (and is already done in some cases
>>>> Please comment, Carl Eugen
>>> If a user needs to generate a file with a specific profile/level
>>> for example because its for broadcast, some specification or a hw
>>> How could he after this patch ensure that exactly the needed profile
>>> is used?
> There is no way of ensuring the same even without this patch.
>> Afair, x264 does change profile and / or level depending on properties
>> set by the user. Currently there is no way for the libavcodec user to
>> know that libx264 changed something.
>> With this change the user can know that he does not get the
>> requested values.
>> Or am I wrong and libx264 never overwrites requested values
>> for level and / or profile?
> I just tested x264 by giving contradicting profiles and levels.
> Following are the results:
> Case 1:
> Input : 1080p30, 420p
> Config : Set level wrongly to 1.1
> Output : Throws some warnings, but level is still written wrongly as 1.1 is the SPS header.
> Impact of overwrite : None. Both the user set value and header’s value are same.
> Case 2:1080p30, 422p
> Config : Set profile wrongly to baseline
> Output : Throws errors, doesn’t encode
> Impact of overwrite : None.
> Case 3:1080p30, 420p
> Config : Set profile wrongly to high422
That's not wrong. High 4:2:2 profile admits bit_depth_*_minus8 == 0 and chroma_format_idc == 1.
> Output : No warnings or errors. Automatically switches to high profile. SPS header also has high profile.
That feels like ffmpeg and libx264 aren't quite agreeing about what the profile field should mean. libx264 is using it as an extra set of constraints and then picking a profile conforming to everything specified later, whereas the usual ffmpeg use is to apply that specific setting. The libx264-in-ffmpeg documentation does admittedly say "Set profile restrictions." kindof suggesting that use, but it is still at odds with most other encoders.
> Impact of overwrite : User will get to know the correct profile being encoded.
I don't like this overwrite, but I'm not sure what a better answer is.
More information about the ffmpeg-devel