Ametadata output for each frame with file option

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Ametadata output for each frame with file option

kaeric
Hello all,
 
I'm using astats and ametadata filters to measure and print the audio levels for each frame. I would like to pipe each result to another process stdin.
 
That works for the following command:
 
1) ffmpeg.exe -f dshow -i audio="Microphone (Realtek High Definition Audio)" -af astats=metadata=1:reset=1,ametadata=print:key=lavfi.astats.Overall.Peak_level -f null -
 
But in this case the output is printed to stderr. I would like to print it to a separate pipe. Therefore I want use the "file"-option and the pipe protocol ("-" / "pipe:1", "pipe:4" etc.). For an example command see 2). The PowerShell stuff behind the "|" can be ignored (I just added it as an example):

2) ffmpeg.exe -f dshow -i audio="Microphone (Realtek High Definition Audio)" -af astats=metadata=1:reset=1,ametadata=print:key=lavfi.astats.Overall.Peak_level:file=- -f null - | Select-String -Pattern lavfi
 
Unfortunately, with the file option it does not print the audio levels for each frame separately to stdout/pipe:x. It kind of buffers a huge amount of values and then it releases them periodically. I suspect it's optimized for writing "normal" files but in this case a switch would be needed that allows immediate output of the values per frame.
 
Is it possible to achieve the same behaviour like in case 1) so that each frames audio levels are send asap to stdout/pipe:x ?
 
Best Regards,
Richard

-------

Output case 1) - send q to stdin after 4 seconds:

ffmpeg.exe -f dshow -i audio="Microphone (Realtek High Definition Audio)" -af astats=metadata=1:reset=1,ametadata=print:key=lavfi.astats.Overall.Peak_level -f null -
ffmpeg version N-91666-g70d2bab80b Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 8.2.0 (Rev1, Built by MSYS2 project)
  configuration:  --disable-autodetect --enable-amf --enable-bzlib --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-iconv --enable-lzma --enable-nvenc --enable-zlib --enable-sdl2 --disable-debug --enable-ffnvcodec --enable-nvdec --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libx264 --enable-libx265 --enable-fontconfig --enable-libass --enable-libbluray --enable-libfreetype --enable-libmfx --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libwavpack --enable-libwebp --enable-libxml2 --enable-libzimg --enable-libshine --enable-gpl --enable-avisynth --enable-libxvid --enable-libaom --enable-version3 --enable-chromaprint --enable-decklink --enable-frei0r --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libfdk-aac --enable-libflite --enable-libfribidi --enable-libgme --enable-libgsm --enable-libilbc --enable-libkvazaar --enable-libmodplug --enable-libopenmpt --enable-librtmp --enable-librubberband --enable-libssh --enable-libtesseract --enable-libxavs --enable-libzmq --enable-libzvbi --enable-opencl --enable-opengl --enable-libcodec2 --enable-libsrt --enable-ladspa --enable-openssl --extra-cflags=-fopenmp --extra-libs=-lgomp --extra-cflags=-DLIBTWOLAME_STATIC --extra-libs=-lstdc++ --extra-cflags=-DLIBSSH_STATIC --extra-ldflags='-Wl,--allow-multiple-definition' --extra-cflags=-DCACA_STATIC --extra-cflags=-DMODPLUG_STATIC --extra-cflags=-DCHROMAPRINT_NODLL --extra-libs=-lstdc++ --extra-cflags=-DZMQ_STATIC --extra-libs=-lpsapi --extra-cflags=-DLIBXML_STATIC --extra-libs=-liconv --disable-w32threads --extra-cflags=-DKVZ_STATIC_LIB --enable-nonfree
  libavutil      56. 19.100 / 56. 19.100
  libavcodec     58. 24.101 / 58. 24.101
  libavformat    58. 17.103 / 58. 17.103
  libavdevice    58.  4.101 / 58.  4.101
  libavfilter     7. 26.100 /  7. 26.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, dshow, from 'audio=Microphone (Realtek High Definition Audio)':
  Duration: N/A, start: 281939.928000, bitrate: 1411 kb/s
    Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_s16le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
[Parsed_ametadata_1 @ 000001997fc5fb40] frame:0    pts:0       pts_time:0
[Parsed_ametadata_1 @ 000001997fc5fb40] lavfi.astats.Overall.Peak_level=-62.009267
Output #0, null, to 'pipe:':
  Metadata:
    encoder         : Lavf58.17.103
    Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
    Metadata:
      encoder         : Lavc58.24.101 pcm_s16le
[Parsed_ametadata_1 @ 000001997fc5fb40] frame:1    pts:22579   pts_time:0.511995
[Parsed_ametadata_1 @ 000001997fc5fb40] lavfi.astats.Overall.Peak_level=-57.053577
[Parsed_ametadata_1 @ 000001997fc5fb40] frame:2    pts:44717   pts_time:1.01399
[Parsed_ametadata_1 @ 000001997fc5fb40] lavfi.astats.Overall.Peak_level=-57.639365
[Parsed_ametadata_1 @ 000001997fc5fb40] frame:3    pts:66812   pts_time:1.51501
[Parsed_ametadata_1 @ 000001997fc5fb40] lavfi.astats.Overall.Peak_level=-55.344973
[Parsed_ametadata_1 @ 000001997fc5fb40] frame:4    pts:88773   pts_time:2.01299
[Parsed_ametadata_1 @ 000001997fc5fb40] lavfi.astats.Overall.Peak_level=-54.050466
[Parsed_ametadata_1 @ 000001997fc5fb40] frame:5    pts:110823  pts_time:2.51299
[Parsed_ametadata_1 @ 000001997fc5fb40] lavfi.astats.Overall.Peak_level=-54.745709
[Parsed_ametadata_1 @ 000001997fc5fb40] frame:6    pts:132829  pts_time:3.012
[Parsed_ametadata_1 @ 000001997fc5fb40] lavfi.astats.Overall.Peak_level=-58.487441
[Parsed_ametadata_1 @ 000001997fc5fb40] frame:7    pts:154923  pts_time:3.51299
[Parsed_ametadata_1 @ 000001997fc5fb40] lavfi.astats.Overall.Peak_level=-58.487441
size=N/A time=00:00:04.01 bitrate=N/A speed=1.15x
video:0kB audio:689kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[Parsed_astats_0 @ 0000019906736e80] Channel: 1
[Parsed_astats_0 @ 0000019906736e80] DC offset: 0.000000
[Parsed_astats_0 @ 0000019906736e80] Min level: -31.000000
[Parsed_astats_0 @ 0000019906736e80] Max level: 32.000000
[Parsed_astats_0 @ 0000019906736e80] Min difference: 0.000000
[Parsed_astats_0 @ 0000019906736e80] Max difference: 13.000000
[Parsed_astats_0 @ 0000019906736e80] Mean difference: 2.324731
[Parsed_astats_0 @ 0000019906736e80] RMS difference: 2.941151
[Parsed_astats_0 @ 0000019906736e80] Peak level dB: -60.205734
[Parsed_astats_0 @ 0000019906736e80] RMS level dB: -71.810185
[Parsed_astats_0 @ 0000019906736e80] RMS peak dB: -71.560064
[Parsed_astats_0 @ 0000019906736e80] RMS trough dB: -72.614405
[Parsed_astats_0 @ 0000019906736e80] Crest factor: 3.803843
[Parsed_astats_0 @ 0000019906736e80] Flat factor: 4.436975
[Parsed_astats_0 @ 0000019906736e80] Peak count: 3
[Parsed_astats_0 @ 0000019906736e80] Bit depth: 16/16
[Parsed_astats_0 @ 0000019906736e80] Dynamic range: 36.123599
[Parsed_astats_0 @ 0000019906736e80] Channel: 2
[Parsed_astats_0 @ 0000019906736e80] DC offset: 0.000000
[Parsed_astats_0 @ 0000019906736e80] Min level: -32.000000
[Parsed_astats_0 @ 0000019906736e80] Max level: 39.000000
[Parsed_astats_0 @ 0000019906736e80] Min difference: 0.000000
[Parsed_astats_0 @ 0000019906736e80] Max difference: 14.000000
[Parsed_astats_0 @ 0000019906736e80] Mean difference: 2.476393
[Parsed_astats_0 @ 0000019906736e80] RMS difference: 3.141702
[Parsed_astats_0 @ 0000019906736e80] Peak level dB: -58.487441
[Parsed_astats_0 @ 0000019906736e80] RMS level dB: -71.233572
[Parsed_astats_0 @ 0000019906736e80] RMS peak dB: -70.720147
[Parsed_astats_0 @ 0000019906736e80] RMS trough dB: -71.798276
[Parsed_astats_0 @ 0000019906736e80] Crest factor: 4.338170
[Parsed_astats_0 @ 0000019906736e80] Flat factor: 0.000000
[Parsed_astats_0 @ 0000019906736e80] Peak count: 3
[Parsed_astats_0 @ 0000019906736e80] Bit depth: 16/16
[Parsed_astats_0 @ 0000019906736e80] Dynamic range: 37.841892
[Parsed_astats_0 @ 0000019906736e80] Overall
[Parsed_astats_0 @ 0000019906736e80] DC offset: 0.000000
[Parsed_astats_0 @ 0000019906736e80] Min level: -32.000000
[Parsed_astats_0 @ 0000019906736e80] Max level: 39.000000
[Parsed_astats_0 @ 0000019906736e80] Min difference: 0.000000
[Parsed_astats_0 @ 0000019906736e80] Max difference: 14.000000
[Parsed_astats_0 @ 0000019906736e80] Mean difference: 2.400562
[Parsed_astats_0 @ 0000019906736e80] RMS difference: 3.043079
[Parsed_astats_0 @ 0000019906736e80] Peak level dB: -58.487441
[Parsed_astats_0 @ 0000019906736e80] RMS level dB: -71.512316
[Parsed_astats_0 @ 0000019906736e80] RMS peak dB: -70.720147
[Parsed_astats_0 @ 0000019906736e80] RMS trough dB: -72.614405
[Parsed_astats_0 @ 0000019906736e80] Flat factor: 2.498775
[Parsed_astats_0 @ 0000019906736e80] Peak count: 3.000000
[Parsed_astats_0 @ 0000019906736e80] Bit depth: 16/16
[Parsed_astats_0 @ 0000019906736e80] Number of samples: 22050


Output case 2) - send q to stdin after 4 seconds:

ffmpeg.exe -f dshow -i audio="Microphone (Realtek High Definition Audio)" -af astats=metadata=1:reset=1,ametadata=print:key=lavfi.astats.Overall.Peak_level:file=- -f null - | Select-String -Pattern lavfi
ffmpeg version N-91666-g70d2bab80b Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 8.2.0 (Rev1, Built by MSYS2 project)
  configuration:  --disable-autodetect --enable-amf --enable-bzlib --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-iconv --enable-lzma --enable-nvenc --enable-zlib --enable-sdl2 --disable-debug --enable-ffnvcodec --enable-nvdec --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libx264 --enable-libx265 --enable-fontconfig --enable-libass --enable-libbluray --enable-libfreetype --enable-libmfx --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libwavpack --enable-libwebp --enable-libxml2 --enable-libzimg --enable-libshine --enable-gpl --enable-avisynth --enable-libxvid --enable-libaom --enable-version3 --enable-chromaprint --enable-decklink --enable-frei0r --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libfdk-aac --enable-libflite --enable-libfribidi --enable-libgme --enable-libgsm --enable-libilbc --enable-libkvazaar --enable-libmodplug --enable-libopenmpt --enable-librtmp --enable-librubberband --enable-libssh --enable-libtesseract --enable-libxavs --enable-libzmq --enable-libzvbi --enable-opencl --enable-opengl --enable-libcodec2 --enable-libsrt --enable-ladspa --enable-openssl --extra-cflags=-fopenmp --extra-libs=-lgomp --extra-cflags=-DLIBTWOLAME_STATIC --extra-libs=-lstdc++ --extra-cflags=-DLIBSSH_STATIC --extra-ldflags='-Wl,--allow-multiple-definition' --extra-cflags=-DCACA_STATIC --extra-cflags=-DMODPLUG_STATIC --extra-cflags=-DCHROMAPRINT_NODLL --extra-libs=-lstdc++ --extra-cflags=-DZMQ_STATIC --extra-libs=-lpsapi --extra-cflags=-DLIBXML_STATIC --extra-libs=-liconv --disable-w32threads --extra-cflags=-DKVZ_STATIC_LIB --enable-nonfree
  libavutil      56. 19.100 / 56. 19.100
  libavcodec     58. 24.101 / 58. 24.101
  libavformat    58. 17.103 / 58. 17.103
  libavdevice    58.  4.101 / 58.  4.101
  libavfilter     7. 26.100 /  7. 26.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, dshow, from 'audio=Microphone (Realtek High Definition Audio)':
  Duration: N/A, start: 282074.377000, bitrate: 1411 kb/s
    Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_s16le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
  Metadata:
    encoder         : Lavf58.17.103
    Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
    Metadata:
      encoder         : Lavc58.24.101 pcm_s16le
size=N/A time=00:00:04.01 bitrate=N/A speed=1.02x
video:0kB audio:689kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[Parsed_astats_0 @ 00000299f85b6ec0] Channel: 1
[Parsed_astats_0 @ 00000299f85b6ec0] DC offset: 0.000001
[Parsed_astats_0 @ 00000299f85b6ec0] Min level: -41.000000
[Parsed_astats_0 @ 00000299f85b6ec0] Max level: 42.000000
[Parsed_astats_0 @ 00000299f85b6ec0] Min difference: 0.000000
[Parsed_astats_0 @ 00000299f85b6ec0] Max difference: 13.000000
[Parsed_astats_0 @ 00000299f85b6ec0] Mean difference: 2.225543
[Parsed_astats_0 @ 00000299f85b6ec0] RMS difference: 2.834058
[Parsed_astats_0 @ 00000299f85b6ec0] Peak level dB: -57.843748
[Parsed_astats_0 @ 00000299f85b6ec0] RMS level dB: -69.769283
[Parsed_astats_0 @ 00000299f85b6ec0] RMS peak dB: -69.418594
[Parsed_astats_0 @ 00000299f85b6ec0] RMS trough dB: -70.098472
[Parsed_astats_0 @ 00000299f85b6ec0] Crest factor: 3.947088
[Parsed_astats_0 @ 00000299f85b6ec0] Flat factor: 0.000000
[Parsed_astats_0 @ 00000299f85b6ec0] Peak count: 2
[Parsed_astats_0 @ 00000299f85b6ec0] Bit depth: 16/16
[Parsed_astats_0 @ 00000299f85b6ec0] Dynamic range: 38.485586
[Parsed_astats_0 @ 00000299f85b6ec0] Channel: 2
[Parsed_astats_0 @ 00000299f85b6ec0] DC offset: 0.000000
[Parsed_astats_0 @ 00000299f85b6ec0] Min level: -41.000000
[Parsed_astats_0 @ 00000299f85b6ec0] Max level: 42.000000
[Parsed_astats_0 @ 00000299f85b6ec0] Min difference: 0.000000
[Parsed_astats_0 @ 00000299f85b6ec0] Max difference: 13.000000
[Parsed_astats_0 @ 00000299f85b6ec0] Mean difference: 2.428319
[Parsed_astats_0 @ 00000299f85b6ec0] RMS difference: 3.080871
[Parsed_astats_0 @ 00000299f85b6ec0] Peak level dB: -57.843748
[Parsed_astats_0 @ 00000299f85b6ec0] RMS level dB: -69.183627
[Parsed_astats_0 @ 00000299f85b6ec0] RMS peak dB: -68.286678
[Parsed_astats_0 @ 00000299f85b6ec0] RMS trough dB: -69.762932
[Parsed_astats_0 @ 00000299f85b6ec0] Crest factor: 3.689725
[Parsed_astats_0 @ 00000299f85b6ec0] Flat factor: 6.020600
[Parsed_astats_0 @ 00000299f85b6ec0] Peak count: 4
[Parsed_astats_0 @ 00000299f85b6ec0] Bit depth: 16/16
[Parsed_astats_0 @ 00000299f85b6ec0] Dynamic range: 38.485586
[Parsed_astats_0 @ 00000299f85b6ec0] Overall
[Parsed_astats_0 @ 00000299f85b6ec0] DC offset: 0.000001
[Parsed_astats_0 @ 00000299f85b6ec0] Min level: -41.000000
[Parsed_astats_0 @ 00000299f85b6ec0] Max level: 42.000000
[Parsed_astats_0 @ 00000299f85b6ec0] Min difference: 0.000000
[Parsed_astats_0 @ 00000299f85b6ec0] Max difference: 13.000000
[Parsed_astats_0 @ 00000299f85b6ec0] Mean difference: 2.326931
[Parsed_astats_0 @ 00000299f85b6ec0] RMS difference: 2.960038
[Parsed_astats_0 @ 00000299f85b6ec0] Peak level dB: -57.843748
[Parsed_astats_0 @ 00000299f85b6ec0] RMS level dB: -69.466591
[Parsed_astats_0 @ 00000299f85b6ec0] RMS peak dB: -68.286678
[Parsed_astats_0 @ 00000299f85b6ec0] RMS trough dB: -70.098472
[Parsed_astats_0 @ 00000299f85b6ec0] Flat factor: 4.436975
[Parsed_astats_0 @ 00000299f85b6ec0] Peak count: 3.000000
[Parsed_astats_0 @ 00000299f85b6ec0] Bit depth: 16/16
[Parsed_astats_0 @ 00000299f85b6ec0] Number of samples: 22050

lavfi.astats.Overall.Peak_level=-59.182684
lavfi.astats.Overall.Peak_level=-55.660858
lavfi.astats.Overall.Peak_level=-55.344973
lavfi.astats.Overall.Peak_level=-56.157330
lavfi.astats.Overall.Peak_level=-52.139033
lavfi.astats.Overall.Peak_level=-48.096939
lavfi.astats.Overall.Peak_level=-55.988667
lavfi.astats.Overall.Peak_level=-57.843748
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".