[FFmpeg-devel] [PATCH] audio dialog level

Justin Ruggles justinruggles
Mon Dec 17 00:58:30 CET 2007


Michael Niedermayer wrote:
> Hi
> 
> On Sun, Dec 16, 2007 at 03:30:07PM -0500, Justin Ruggles wrote:
>> Hello,
>>
>> Here is a more generic patch to handle the dialog level.  I've tried to
>> make it not AC3-specific.
>>
>> I've changed the default value to 1.0.  Positive numbers are not valid
>> for actual values because having dialog above the maximum audio level is
>> not possible.  Really 0 doesn't make sense in practice, but in theory
>> the audio could just be really loud dialog at or near 0 dB.  Picking an
>> arbitrary default or using the one from AC3 isn't ideal either.  So I've
>> made positive values indicate that the dialog level is not specified.
>> If that's ok.  If not, I guess I could use the one from AC3 (-31.0 dB).
>>
>> The patch does not do anything with the value from the decoder in
>> ffmpeg.c.  The only logical things I can think of that could be done are
>> to have the user specify a target dialog level and apply gain
>> accordingly, or pass the value along to the encoder.  I think the first
>> one is outside the normal scope of ffmpeg...  The 2nd option would be a
>> mess to implement cleanly when you take into account having to know
>> whether the user specified the dialog level or if it should be copied
>> >from the decoder (which could change mid-stream).  Also, if the audio
>> volume is changed in ffmpeg.c, the dialog level will no longer be correct.
> 
> there is no mess at all, its only a mess if its implemented like you did
> 1. the dialog level should be exported in the AVFrame (yes this needs an
>    API change so that decoders output AVFrames)
> 2. these AVFrames are just passed to the encoder (again little API change
>    needed)
> 3. all encoders supporting dialog level have a CODEC_CAP_DIALOG_LEVEL flag
>    set in the AVCodec struct
> 4. if the encoder doesnt have CODEC_CAP_DIALOG_LEVEL set than the audio is
>    "scaled" to match the user specified volume at an appropriate place in
>    ffmpeg.c (later this could be moved into an audio filter)
> 
> ffplay would then always rescale to what the user wants
> 
> (and the user should at least be able to specify to honor as well as ignore
>  the dialog level and for each of these 2 be able to change the volume)
> 
> this can be done in several patches
> 1. AVFrame used in decoders
> 2. AVFrame used in encoders
> 3. export dialog_level from decoders
> 4. import dialog_level for encoders
> 5. ffmpeg.c rescaling to user specified level
> 6. ffplay.c rescaling to user specified leve

I like it, but I don't think I'm up to the task right now.  I will need
to study the code some more.

So unless someone else wants to go ahead and make the API changes, I
think I should at least disable dialog normalization in the AC3 decoder.
 No other codecs use such a value, and since it's essentially metadata,
I would prefer to skip it until such time as it can be put to good use
at the user level.

-Justin





More information about the ffmpeg-devel mailing list