[FFmpeg-user] Mapping of stream to filter

Gerion Entrup gerion.entrup at t-online.de
Wed Dec 25 18:57:36 CET 2013


Hello,

I want to use the volumedetect filter in a script and have a problem with the 
mapping of the hexadecimal number in the filter to the audiostream.

Here is an example:
% ffmpeg -i sample.mkv -filter:a volumedetect -map 0:a -f null -t 30 /dev/null
ffmpeg version N-57946-gea6331b Copyright (c) 2000-2013 the FFmpeg developers
  built on Nov  7 2013 13:04:48 with gcc 4.7.3 (Gentoo 4.7.3-r1 p1.3, 
pie-0.5.5)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --
mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --
cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --optflags='-
march=native -O2 -pipe' --extra-cflags='-march=native -O2 -pipe' --extra-
cxxflags='-march=native -O2 -pipe' --disable-static --enable-gpl --enable-
postproc --enable-avfilter --enable-avresample --disable-stripping --enable-
version3 --enable-nonfree --disable-indev=v4l2 --disable-outdev=v4l2 --
disable-indev=oss --disable-outdev=oss --enable-bzlib --disable-runtime-
cpudetect --disable-debug --disable-doc --disable-gnutls --enable-hardcoded-
tables --enable-iconv --enable-network --disable-openssl --enable-ffplay --
enable-vaapi --disable-vdpau --enable-zlib --enable-libvo-aacenc --disable-
libvo-amrwbenc --enable-libmp3lame --enable-libaacplus --enable-libfaac --
enable-libtheora --disable-libtwolame --disable-libwavpack --enable-libx264 --
enable-libxvid --disable-libcdio --disable-libiec61883 --disable-libdc1394 --
disable-libcaca --disable-openal --disable-libv4l2 --disable-libpulse --
enable-x11grab --disable-libflite --disable-frei0r --disable-fontconfig --
enable-ladspa --disable-libass --enable-libfreetype --disable-libsoxr --
enable-pthreads --disable-libopencore-amrwb --disable-libopencore-amrnb --
disable-libfdk-aac --disable-libopenjpeg --enable-libbluray --disable-libcelt 
--disable-libgme --disable-libgsm --disable-libmodplug --enable-libopus --
enable-libquvi --disable-librtmp --disable-libssh --disable-libschroedinger --
enable-libspeex --enable-libvorbis --enable-libvpx --disable-libzvbi --
disable-amd3dnow --disable-amd3dnowext --disable-altivec --disable-avx --
disable-avx2 --disable-ssse3 --disable-vis --disable-neon --cpu=host
  libavutil      52. 52.100 / 52. 52.100
  libavcodec     55. 41.100 / 55. 41.100
  libavformat    55. 21.100 / 55. 21.100
  libavdevice    55.  5.100 / 55.  5.100
  libavfilter     3. 90.102 /  3. 90.102
  libavresample   1.  1.  0 /  1.  1.  0
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
  ...
Input #0, matroska,webm, from 'sample.mkv':
...
    Stream #0:0: Video: h264 (High), yuv420p, 1916x800 [SAR 1:1 DAR 479:200], 
23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Stream #0:1(ger): Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s (default)
    Stream #0:2(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s
    ...
Output #0, null, to '/dev/null':
    Stream #0:0(ger): Audio: pcm_s16le, 48000 Hz, 5.1(side), s16, 4608 kb/s 
(default)
    Stream #0:1(eng): Audio: pcm_s16le, 48000 Hz, 5.1(side), s16, 4608 kb/s
Stream mapping:
  Stream #0:1 -> #0:0 (ac3 -> pcm_s16le)
  Stream #0:2 -> #0:1 (ac3 -> pcm_s16le)
Press [q] to stop, [?] for help
size=N/A time=00:00:30.01 bitrate=N/A    
video:0kB audio:33624kB subtitle:0 global headers:0kB muxing overhead 
-100.000064%
[Parsed_volumedetect_0 @ 0x81a950] n_samples: 8616960
[Parsed_volumedetect_0 @ 0x81a950] mean_volume: -29.2 dB
[Parsed_volumedetect_0 @ 0x81a950] max_volume: -7.4 dB
[Parsed_volumedetect_0 @ 0x81a950] histogram_7db: 16
[Parsed_volumedetect_0 @ 0x81a950] histogram_8db: 217
[Parsed_volumedetect_0 @ 0x81a950] histogram_9db: 792
[Parsed_volumedetect_0 @ 0x81a950] histogram_10db: 1728
[Parsed_volumedetect_0 @ 0x81a950] histogram_11db: 2928
[Parsed_volumedetect_0 @ 0x81a950] histogram_12db: 5012
[Parsed_volumedetect_0 @ 0x7c0090] n_samples: 8616960
[Parsed_volumedetect_0 @ 0x7c0090] mean_volume: -29.1 dB
[Parsed_volumedetect_0 @ 0x7c0090] max_volume: -9.1 dB
[Parsed_volumedetect_0 @ 0x7c0090] histogram_9db: 137
[Parsed_volumedetect_0 @ 0x7c0090] histogram_10db: 983
[Parsed_volumedetect_0 @ 0x7c0090] histogram_11db: 2482
[Parsed_volumedetect_0 @ 0x7c0090] histogram_12db: 4531
[Parsed_volumedetect_0 @ 0x7c0090] histogram_13db: 8359

Here you cannot see the direct mapping of 0x81a950 to stream 0:1 etc.. So I 
tried to do it verbose:

% ffmpeg -i sample.mkv -filter:a volumedetect -map 0:a -loglevel verbose -f null 
-t 30 /dev/null
ffmpeg version N-57946-gea6331b Copyright (c) 2000-2013 the FFmpeg developers
  built on Nov  7 2013 13:04:48 with gcc 4.7.3 (Gentoo 4.7.3-r1 p1.3, 
pie-0.5.5)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --
mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --
cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --optflags='-
march=native -O2 -pipe' --extra-cflags='-march=native -O2 -pipe' --extra-
cxxflags='-march=native -O2 -pipe' --disable-static --enable-gpl --enable-
postproc --enable-avfilter --enable-avresample --disable-stripping --enable-
version3 --enable-nonfree --disable-indev=v4l2 --disable-outdev=v4l2 --
disable-indev=oss --disable-outdev=oss --enable-bzlib --disable-runtime-
cpudetect --disable-debug --disable-doc --disable-gnutls --enable-hardcoded-
tables --enable-iconv --enable-network --disable-openssl --enable-ffplay --
enable-vaapi --disable-vdpau --enable-zlib --enable-libvo-aacenc --disable-
libvo-amrwbenc --enable-libmp3lame --enable-libaacplus --enable-libfaac --
enable-libtheora --disable-libtwolame --disable-libwavpack --enable-libx264 --
enable-libxvid --disable-libcdio --disable-libiec61883 --disable-libdc1394 --
disable-libcaca --disable-openal --disable-libv4l2 --disable-libpulse --
enable-x11grab --disable-libflite --disable-frei0r --disable-fontconfig --
enable-ladspa --disable-libass --enable-libfreetype --disable-libsoxr --
enable-pthreads --disable-libopencore-amrwb --disable-libopencore-amrnb --
disable-libfdk-aac --disable-libopenjpeg --enable-libbluray --disable-libcelt 
--disable-libgme --disable-libgsm --disable-libmodplug --enable-libopus --
enable-libquvi --disable-librtmp --disable-libssh --disable-libschroedinger --
enable-libspeex --enable-libvorbis --enable-libvpx --disable-libzvbi --
disable-amd3dnow --disable-amd3dnowext --disable-altivec --disable-avx --
disable-avx2 --disable-ssse3 --disable-vis --disable-neon --cpu=host
  libavutil      52. 52.100 / 52. 52.100
  libavcodec     55. 41.100 / 55. 41.100
  libavformat    55. 21.100 / 55. 21.100
  libavdevice    55.  5.100 / 55.  5.100
  libavfilter     3. 90.102 /  3. 90.102
  libavresample   1.  1.  0 /  1.  1.  0
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
...
Input #0, matroska,webm, from 'sample.mkv':
...
    Stream #0:0: Video: h264 (High), yuv420p, 1916x800 [SAR 1:1 DAR 479:200], 
23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Stream #0:1(ger): Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s (default)
    Stream #0:2(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s
    ...
[graph 0 input from stream 0:1 @ 0x81aa30] tb:1/48000 samplefmt:fltp 
samplerate:48000 chlayout:0x60f
[Parsed_volumedetect_0 @ 0x81a970] auto-inserting filter 'auto-inserted 
resampler 0' between the filter 'graph 0 input from stream 0:1' and the filter 
'Parsed_volumedetect_0'
[auto-inserted resampler 0 @ 0x99b9a0] ch:6 chl:5.1(side) fmt:fltp r:48000Hz -> 
ch:6 chl:5.1(side) fmt:s16 r:48000Hz
[graph 1 input from stream 0:2 @ 0xd32230] tb:1/48000 samplefmt:fltp 
samplerate:48000 chlayout:0x60f
[Parsed_volumedetect_0 @ 0x7c00b0] auto-inserting filter 'auto-inserted 
resampler 0' between the filter 'graph 1 input from stream 0:2' and the filter 
'Parsed_volumedetect_0'
[auto-inserted resampler 0 @ 0x7fb3f0] ch:6 chl:5.1(side) fmt:fltp r:48000Hz -> 
ch:6 chl:5.1(side) fmt:s16 r:48000Hz
...
Output #0, null, to '/dev/null':
    Stream #0:0(ger): Audio: pcm_s16le, 48000 Hz, 5.1(side), s16, 4608 kb/s 
(default)
    Stream #0:1(eng): Audio: pcm_s16le, 48000 Hz, 5.1(side), s16, 4608 kb/s
    ...
Stream mapping:
  Stream #0:1 -> #0:0 (ac3 -> pcm_s16le)
  Stream #0:2 -> #0:1 (ac3 -> pcm_s16le)
Press [q] to stop, [?] for help
No more output streams to write to, finishing.
size=N/A time=00:00:30.01 bitrate=N/A    
video:0kB audio:33624kB subtitle:0 global headers:0kB muxing overhead 
-100.000064%
[Parsed_volumedetect_0 @ 0x81a970] n_samples: 8616960
[Parsed_volumedetect_0 @ 0x81a970] mean_volume: -29.2 dB
[Parsed_volumedetect_0 @ 0x81a970] max_volume: -7.4 dB
[Parsed_volumedetect_0 @ 0x81a970] histogram_7db: 16
[Parsed_volumedetect_0 @ 0x81a970] histogram_8db: 217
[Parsed_volumedetect_0 @ 0x81a970] histogram_9db: 792
[Parsed_volumedetect_0 @ 0x81a970] histogram_10db: 1728
[Parsed_volumedetect_0 @ 0x81a970] histogram_11db: 2928
[Parsed_volumedetect_0 @ 0x81a970] histogram_12db: 5012
[Parsed_volumedetect_0 @ 0x7c00b0] n_samples: 8616960
[Parsed_volumedetect_0 @ 0x7c00b0] mean_volume: -29.1 dB
[Parsed_volumedetect_0 @ 0x7c00b0] max_volume: -9.1 dB
[Parsed_volumedetect_0 @ 0x7c00b0] histogram_9db: 137
[Parsed_volumedetect_0 @ 0x7c00b0] histogram_10db: 983
[Parsed_volumedetect_0 @ 0x7c00b0] histogram_11db: 2482
[Parsed_volumedetect_0 @ 0x7c00b0] histogram_12db: 4531
[Parsed_volumedetect_0 @ 0x7c00b0] histogram_13db: 8359

Here you can find out the mapping, because the resampling filter is inserted and 
the debug message "casually" mentioned 0:1 and 81a970 in one line. There are 
streams that do not need a resampling filter. Is there a possibility to do the 
mapping anyway?

regards,
Gerion



More information about the ffmpeg-user mailing list