Re: [LAD] Replaygain for video?

From: Robin Gareus <robin@email-addr-hidden>
Date: Sun Dec 11 2011 - 13:49:10 EET

On 12/10/2011 11:04 PM, Philipp Überbacher wrote:

[..]
> guess I'd need the whole track anyway before making
> calculations.

Yes, but not all of it at the same time. You can calculate it sequentially.

Have a look at https://www.ohloh.net/p/Samplecat it includes a ffmpeg
audio decoder, max. gain calculation, Fons' ebur128 analysis and more..
Comment out the mime-type filter in main.c:788 to read the first audio
track from a video file.

>> https://github.com/avuserow/ffmpeg-replaygain seems to do what you want
>> but requires ffmpeg av* libs <=0.5 and/or a bit of patching.
>
> My ffmpeg is rather recent (20111123) but the program doesn't build, so
> I guess it needs patching. Seems like my ffmpeg is too new. The
> implementation looks insanely complex to me.

edit ffs.c

replace "CODEC_TYPE_AUDIO" with "AVMEDIA_TYPE_AUDIO" and you are good to
go with ffmpeg >0.5.

For ffmpeg <0.5, replace the 'avcodec_decode_audio3() call with:
 int len = avcodec_decode_audio2(ffs->cc, (int16_t *) (buf + rdec),
                                 &size, tmppkt.data, tmppkt.size)

[..]
>> I don't know any command-line apps to modify meta-data on a per track
>> basis in-place (maybe ffmpeg can do that?), but the new liav* meta-data
>> API is pretty nifty.
>
> Do you refer to http://www.libav.org/ ?

Sorry, a typo slipped in. Yes, libavformat, libavcodec, libavutil, etc..
I prefer libav* from ffmpeg.org not the branch libav.org.

>>> Playback
[..]
>> A compressor plugin (for video-players that don't yet have one) would be
>> much more useful in the real world because
>> - purists won't care for neither replaygain nor compression
> Agreed, if purists are people who only watch professionally produced
> movies or similar. In such a case there'd be no need for it.
>
>> - consumers will complain that replay-gain is not sufficient for
>> long[er] films and won't care about sound-degradation by compression
>
> Why would it not be sufficient for longer films? It can't do anything to
> improve bad mixing, that's true, but there's not much one can do about
> that anyway (except maybe apply some eq to make dialogs understandable).

The single loud explosion (show down) or a slammed door will dwarf all
the all whispered (sexy) dialog.

I just ran `fbff` (ffmpeg replay gain) on a The Great Dictator (1940),
Clockwork Orange (1971) and Avatar(2009). as well as
http://www.youtube.com/watch?v=f2bcPIXl8kc

They _all_ came out on zero (Max PCM value found: 1.000000, Title gain:
64.820000). Looks like they have been normalized already. (maybe youtube
and DVD master[er]s do that?!) But the dynamics are completely different.

For comparison, ebur128 reported:
  Loundness-range 19.1 LU; Peak 6.7 LU for the Chaplin movie.
and
  Loundness-range 11.3 LU; Peak 15.3 LU for the youtube video,

(Quite good actually, RHCP's 'Around the world' only features a
 Loundness-range 4.0 LU; Peak. 19.2.)
[..]

>> It's a great educational project with many problems that one will
>> encounter in other /real-world/ projects.
>
> Thank you very much for that, I fear that it might be too hard. Most
> students have very little coding experience. Most courses require little
> coding and that is mostly done in java.
> The course in question is a
> beginner C/C++ course and for many students this was the first experience
> with those languages.

If you want to learn hands-on CS, don't study Informatics.

Two years ago I taught the "advanced programming" class at the
Kunst-universität Linz. 3rd semester *Art* school: > 1/3 of the
students were fluent with openframeworks & openCV C++. The rest knew
either JAVA/processing.org or Pure-data. I was pleasantly surprised.

[..]
>> Did you try http://www.akjmusic.com/software/jackctl20110317.py ??!
>
> I thought I knew them all...
> Thanks, this is great and pretty close to what I/we imagined. I don't
> fully understand the alsa midi mode, I think it doesn't use a pager for
> many ports and I guess a way to connect a range of ports to another
> would be useful as well, but it's really close to what I had in mind.
> Julien will be happy to hear about this.
> That pretty much takes care of this idea :)

I think Aaron is on the LAD list. IIRC he announced it on LAU and LAA
and may be willing to add a pager or other features. - just change the
subject-line :)

>>> More detailed ideas exist
>>> thanks to Julien Claasen.
>>>
>>> - A simple but hopefully sane mplayer GUI
>>
>> RFTL.
>
> I sadly don't what that means :)
AWW snap. ROFL.

meaning: Mission impossible.
"Die Idee ist gut, die Welt noch nicht bereit." (Tocotronic)

>> http://www.mplayerosx.ch/ :(
>
> It looks reasonably nice, similar to smplayer, but the devil is in the
> details. And this one seems to be for OSX only.

That's why I'm sad.

>>> - A new GUI for ecasound
>>>
>>> Another problem I might have is that most students in the course are
>>> Windows users, not sure whether I can go solo.
>>
>> You can x-compile for windows and test with wine. ffmpeg is x-platform,
>> as is mplayer and gstreamer. ..just be prepared to throw in a day or two
>> to set up a x-platform build-environment.

install mingw32 and wine. As long as a project uses autoconf:

 #export WINEBASEDIR=$HOME/.wine/drive_c/x-prefix
 #export PKG_CONFIG_PATH=$WINEBASEDIR/lib/pkgconfig/
 #./configure --host=i586-mingw32msvc --build=i386-linux \
  --prefix=$HOME/.wine/drive_c/x-prefix/
 #make install

Problem is: for ffmpeg you'll need a lot of time consuming dependencies.
http://nsis.sf.net is the packager/installer tool of choice.

but I'm getting more off-topic.

> That's another possibility, thanks.
> I guess I'll need to do something
> like this no matter what the project will be.

qemu or virtualbox? is nice for running or testing apps; but IMO
developing in a VM - esp windows sucks much more than setting up a
x-compile environment.

> Thanks a lot Robin,
> I'm pretty much back at square one now, but that's ok. Maybe I can
> develop the ecasound GUI idea, maybe I should find a team first and try
> to come up with an idea together with the others.

I know that a /real wold use-case/ greatly excites students. Just you
trade that for /real world experience/. The project is superb and IMHO
not too complex:

The /lazy/ student could just write a batch script:
call `ffmpeg.exe` - parse output.., call `replaygain.exe` - parse output
call `ffmpeg.exe -acodec copy -vcodec copy -metadata replaygain=X ..`
and finish while you're still struggling with a gst-launch pipeline...

Those students who are into C/C++ will at least manage to glue existing
code and may learn about the basic mathematical complexities involved:
bit-depth, logarithms..

The rich student will outsource it, and the creative student just
delivers a remote-control for manual Volume control..

How many movies are you going to watch in your life vs. how long does it
take to adjust the volume?

robin
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Sun Dec 11 16:15:02 2011

This archive was generated by hypermail 2.1.8 : Sun Dec 11 2011 - 16:15:03 EET