[mythtv-users] A Myther can dream, right?

Another Sillyname anothersname at googlemail.com
Mon Aug 18 23:09:49 UTC 2014


When you're doing you transcode.......make it a 2 pass transcode.

Pass 1.....

ffmpeg -i /some/path/to/file -af "volumedetect" -c:v libx264 -b:v 750k
-preset slow -bf 2 -pass 1 -threads 6 -map_chapters -1 -f null 2>&1
/dev/null

This will give you an output table of the volume throughout the video
and some 'ranges'

For example.......

[Parsed_volumedetect_0 @ 0x1e80540] n_samples: 491579136
[Parsed_volumedetect_0 @ 0x1e80540] mean_volume: -23.1 dB
[Parsed_volumedetect_0 @ 0x1e80540] max_volume: -0.5 dB
[Parsed_volumedetect_0 @ 0x1e80540] histogram_0db: 12
[Parsed_volumedetect_0 @ 0x1e80540] histogram_1db: 93
[Parsed_volumedetect_0 @ 0x1e80540] histogram_2db: 768
[Parsed_volumedetect_0 @ 0x1e80540] histogram_3db: 3141
[Parsed_volumedetect_0 @ 0x1e80540] histogram_4db: 9842
[Parsed_volumedetect_0 @ 0x1e80540] histogram_5db: 28496
[Parsed_volumedetect_0 @ 0x1e80540] histogram_6db: 63683
[Parsed_volumedetect_0 @ 0x1e80540] histogram_7db: 134674
[Parsed_volumedetect_0 @ 0x1e80540] histogram_8db: 274456

Now you might well think as the max_volume is -0.5 dB that this file
needs no modification.....

I however, after a lot of testing and sampling took a different approach.

I divide n_samples by 10,000 (X) and then look at the histogram_db
values to find the first one, in reducing order, that's less then X so
in the example above it would be histogram_5db.

My script then tests to ensure that the histogram_Ydb value is more
then 3db, if it is then it adjusts the volume by the amount calculated
(so in this case 5db)

Pass 2..................

ffmpeg -i '/some/path/to/file' -strict -2 -af "volume=5dB" -c:a aac
-b:a 128k -c:v libx264 -b:v 750k -preset slow -bf 2 -pass 2
-map_chapters -1 -threads 6 -f matroska '/some/path/to/outputfile'

************************************************************

The methodology is based on trial and error frankly, there were far
too many instances where a file would say max_volume < 1db (as near as
you can get to 0db is supposedly optimal) however the program would
still have to many quiet spots.  However the -af "volumedetect" gives
you a histogram range of volumes within each db level below 0db.  If
you boost above 0db you'll get clipping, but my method really only
allows about 1 in say 6-7,000 samples to be above 0db (in the example
above add histogram_0db through histogram_4db and these become the
possible > 0db values, so 4db=9842, 3db=3141, 2db=768,1db=93,0db=12
in total 13,856 samples out of 491,579,136 (n_samples) could be
getting boosted above 0db.......if you can hear such a low amount of
clipping you're a much much better man then me!!


Hope this makes sense and if you need any more info let me know.

Tony






On 18 August 2014 22:57, Mark Perkins <perkins1724 at hotmail.com> wrote:
>
>
>> On 18 Aug 2014, at 4:03 pm, "Another Sillyname" <anothersname at googlemail.com> wrote:
>>
>> I bought the REDS as at the time they were the only 6TB drives I could
>> get, it is software RAID6 on a Fedora 20 build.....I'm migrating my
>> library at the moment (every SD file is getting re-transcoded to x264
>> and all audio volume is getting normalised).....and before anyone says
>> you'll lose quality I accept there can be 'some' small quality loss
>> say taking an XVID avi and turning it into a x264 mkv, but I'm on
>> average saving about 12% space so far and to be honest I can't notice
>> an visual difference even on the 50" screens.
>>
>> I reckon the convert and moves will take me about 6-8 months
>> altogether but it's a very nice compact box at the end!!
>> _______________________________________________
>
> Can I hijack the thread now? Too late!
>
> "Another Sillyname" how are you normalising the audio volume? I normally transcode everything so I can view on mobile / stream while out-and-about and have noticed that some shows seem very quite compared to others at what seems to be the same volume setting. I would be interested in your code for normalising the volume because I might be able to do that at the same time.
> _______________________________________________
> mythtv-users mailing list
> mythtv-users at mythtv.org
> http://www.mythtv.org/mailman/listinfo/mythtv-users
> http://wiki.mythtv.org/Mailing_List_etiquette
> MythTV Forums: https://forum.mythtv.org


More information about the mythtv-users mailing list