[FFmpeg-user] how to avoid broken pi
meex
meex at rbox.me
Wed Jan 26 18:10:55 EET 2022
in a bash script i'm using ffmpeg to create a spectrogram movie and pipe
the output to a decoder (mpv in this case, but it doesn't matter)
as expected, if the user exits mpv before ffmpeg completes, it returns a
broke pipe error and i would like to avoid that if possible
the problem is that the terminal may refuse to accept any user input
when this happens (this occurs ~20% of the time)
is there a way to have ffmpeg exit gracefully when the pipe is broken?
$ ffmpeg -i 'a.flac' -filter_complex
"[0:a]showspectrum=mode=separate:color=intensity:scale=cbrt:s=1280x518[top];
[0:a]showwaves=s=1280x202:mode=point:colors=white[bottom];
[top][bottom]vstack" -map 0:a -codec:v libx264 -preset fast -crf 18
-codec:a copy -f matroska - | mpv --no-config -- -
ffmpeg version n4.4.1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11.1.0 (GCC)
configuration: --prefix=/usr --disable-debug --disable-static
--disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm
--enable-lto --enable-fontconfig --enable-gmp --enable-gnutls
--enable-gpl --enable-ladspa --enable-libaom --enable-libass
--enable-libbluray --enable-libdav1d --enable-libdrm
--enable-libfreetype --enable-libfribidi --enable-libgsm
--enable-libiec61883 --enable-libjack --enable-libmfx
--enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb
--enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus
--enable-libpulse --enable-librav1e --enable-librsvg --enable-libsoxr
--enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1
--enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf
--enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264
--enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid
--enable-libzimg --enable-nvdec --enable-nvenc --enable-shared
--enable-version3
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
Input #0, flac, from 'a.flac':
Metadata:
GENRE : Soft
TITLE : 17th Street
ARTIST : 2 Good To Go
COMMENT : Muzik Faktry v20211226 12/26/2021
REPLAYGAIN_REFERENCE_LOUDNESS: 89.0 dB
REPLAYGAIN_TRACK_GAIN: -6.36 dB
REPLAYGAIN_TRACK_PEAK: 1.00000000
REPLAYGAIN_ALBUM_GAIN: -6.36 dB
REPLAYGAIN_ALBUM_PEAK: 1.00000000
Duration: 00:03:38.00, start: 0.000000, bitrate: 953 kb/s
Stream #0:0: Audio: flac, 44100 Hz, stereo, s16
Side data:
replaygain: track gain - -6.360000, track peak - 0.000023, album
gain - -6.360000, album peak - 0.000023,
Stream mapping:
Stream #0:0 (flac) -> showspectrum
Stream #0:0 (flac) -> showwaves
vstack -> Stream #0:0 (libx264)
Stream #0:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
[libx264 @ 0x5627f9f5aa00] using SAR=1/1
[libx264 @ 0x5627f9f5aa00] MB rate (158760000) > level limit (16711680)
[libx264 @ 0x5627f9f5aa00] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x5627f9f5aa00] profile High 4:4:4 Predictive, level 6.2,
4:4:4, 8-bit
[libx264 @ 0x5627f9f5aa00] 264 - core 163 r3060 5db6aa6 - H.264/MPEG-4
AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html -
options: cabac=1 ref=2 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=6
psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1
8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=12
lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0
bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1
b_bias=0 direct=1 weightb=1 open_gop=0 weightp=1 keyint=250
keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=30 rc=crf
mbtree=1 crf=18.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40
aq=1:1.00
Output #0, matroska, to 'pipe:':
Metadata:
GENRE : Soft
TITLE : 17th Street
ARTIST : 2 Good To Go
COMMENT : Muzik Faktry v20211226 12/26/2021
REPLAYGAIN_REFERENCE_LOUDNESS: 89.0 dB
REPLAYGAIN_TRACK_GAIN: -6.36 dB
REPLAYGAIN_TRACK_PEAK: 1.00000000
REPLAYGAIN_ALBUM_GAIN: -6.36 dB
REPLAYGAIN_ALBUM_PEAK: 1.00000000
encoder : Lavf58.76.100
Stream #0:0: Video: h264 (H264 / 0x34363248), yuv444p(progressive),
1280x720 [SAR 1:1 DAR 16:9], q=2-31, 1k tbn (default)
Metadata:
encoder : Lavc58.134.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1: Audio: flac ([172][241][0][0] / 0xF1AC), 44100 Hz,
stereo, s16
Side data:
replaygain: track gain - -6.360000, track peak - 0.000023, album
gain - -6.360000, album peak - 0.000023,
[file] Reading from stdin...
frame= 1 fps=0.0 q=0.0 size= 1kB time=00:00:00.74 bitrate=
11.0kbits/s speed= 127x (+) Video --vid=1 (*) (h264 1280x720)
(+) Audio --aid=1 (*) (flac 2ch 44100Hz)
File tags:
Artist: 2 Good To Go
Comment: Muzik Faktry v20211226 12/26/2021
Genre: Soft
Title: 17th Street
AO: [pulse] 44100Hz stereo 2ch s16
VO: [gpu] 1280x720 yuv444p
frame= 78 fps=0.0 q=28.0 size= 155kB time=00:00:01.85 bitrate=
684.4kbits/s speed=3.65frame= 174 fps=172 q=26.0 size= 977kB
time=00:00:03.25 bitrate=2461.8kbits/s speed=3.22frame= 279 fps=184
q=27.0 size= 1635kB time=00:00:04.83 bitrate=2773.3kbits/s
speed=3.19frame= 384 fps=191 q=28.0 size= 2449kB time=00:00:06.31
bitrate=3176.2kbits/s speed=3.14frame= 496 fps=197 q=26.0 size=
3072kB time=00:00:07.89 bitrate=3187.6kbits/s speed=3.14AV: 00:00:02 /
00:00:06 (31%) A-V: 0.000 Cache: 4.3s/2MB
Exiting... (Quit)
av_interleaved_write_frame(): Broken pipe
Error writing trailer of pipe:: Broken pipe
frame= 530 fps=187 q=27.0 Lsize= 3259kB time=00:00:08.45
bitrate=3158.4kbits/s speed=2.98x
video:2518kB audio:949kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: unknown
[libx264 @ 0x5627f9f5aa00] frame I:6 Avg QP:16.07 size: 30391
[libx264 @ 0x5627f9f5aa00] frame P:150 Avg QP:22.19 size: 9980
[libx264 @ 0x5627f9f5aa00] frame B:374 Avg QP:25.77 size: 2972
[libx264 @ 0x5627f9f5aa00] consecutive B-frames: 2.1% 10.6% 2.8% 84.5%
[libx264 @ 0x5627f9f5aa00] mb I I16..4: 15.8% 76.1% 8.1%
[libx264 @ 0x5627f9f5aa00] mb P I16..4: 2.1% 1.0% 4.5% P16..4:
4.6% 0.3% 0.2% 0.0% 0.0% skip:87.3%
[libx264 @ 0x5627f9f5aa00] mb B I16..4: 0.7% 0.1% 0.6% B16..8:
4.0% 0.5% 0.1% direct: 0.6% skip:93.4% L0:57.6% L1:41.0% BI: 1.4%
[libx264 @ 0x5627f9f5aa00] 8x8 transform intra:28.0% inter:8.3%
[libx264 @ 0x5627f9f5aa00] coded y,u,v intra: 32.0% 1.4% 1.6% inter:
0.8% 0.2% 0.2%
[libx264 @ 0x5627f9f5aa00] i16 v,h,dc,p: 66% 27% 7% 0%
[libx264 @ 0x5627f9f5aa00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 57% 10% 32%
0% 0% 0% 0% 0% 0%
[libx264 @ 0x5627f9f5aa00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 20% 35%
3% 3% 2% 3% 1% 3%
[libx264 @ 0x5627f9f5aa00] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x5627f9f5aa00] ref P L0: 51.4% 48.6%
[libx264 @ 0x5627f9f5aa00] ref B L0: 86.4% 13.6%
[libx264 @ 0x5627f9f5aa00] ref B L1: 95.5% 4.5%
[libx264 @ 0x5627f9f5aa00] kb/s:2909.26
Conversion failed!
More information about the ffmpeg-user
mailing list