当输出使用TLS并且连接失败时,如何从av_interleaved_write_frame
/ av_write_frame
检测到故障?目标变为不可用后,这两个函数将继续返回0。当不使用TLS时,函数立即检测到故障并返回-ve返回代码。
TLS输出:
av_interleaved_write_frame st.tb=90000, result=0
非TLS输出:
av_interleaved_write_frame failed result=-32 - Broken pipe
也可以使用命令行工具演示此行为。
普通连接的预期结果 - 连接失败终止程序:
$ ffmpeg -rtsp_transport tcp -i rtsp://<rtsp_source>:554... -vcodec copy -an -f rtsp "rtsp://<rtsp_dest>:1935..."
ffmpeg version N-68044-g9f9440b Copyright (c) 2000-2014 the FFmpeg developers
built on Nov 27 2014 03:13:44 with gcc 4.9.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-decklink --enable-zlib
libavutil 54. 15.100 / 54. 15.100
libavcodec 56. 13.100 / 56. 13.100
libavformat 56. 15.100 / 56. 15.100
libavdevice 56. 3.100 / 56. 3.100
libavfilter 5. 2.103 / 5. 2.103
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, rtsp, from 'rtsp://<rtsp_source>:554...':
Metadata:
title : Media Presentation
comment : <comment>
Duration: N/A, start: 0.011000, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p, 1920x1080, 30 tbr, 90k tbn, 180k tbc
Stream #0:1: Data: none
Output #0, rtsp, to 'rtsp://<rtsp_dest>:1935...':
Metadata:
title : Media Presentation
comment : <comment>
encoder : Lavf56.15.100
Stream #0:0: Video: h264, yuv420p, 1920x1080, q=2-31, 90k tbn, 90k tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[rtsp @ 0000000004d4e940] Non-monotonous DTS in output stream 0:0; previous: 0, current: 0; changing to 1. This may result in incorrect timestamps in the output file.
av_interleaved_write_frame(): Broken pipe00:00:15.71 bitrate=N/A
frame= 476 fps= 33 q=-1.0 Lsize=N/A time=00:00:15.77 bitrate=N/A
video:2178kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!
$
TLS连接的意外结果 - 程序继续运行,但它知道出现了问题:
$ ffmpeg -rtsp_transport tcp -i rtsp://<rtsp_source>:554... -vcodec copy -an -f rtsp "rtsps://<rtsps_dest>:443..."
ffmpeg version N-68044-g9f9440b Copyright (c) 2000-2014 the FFmpeg developers
built on Nov 27 2014 03:13:44 with gcc 4.9.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-decklink --enable-zlib
libavutil 54. 15.100 / 54. 15.100
libavcodec 56. 13.100 / 56. 13.100
libavformat 56. 15.100 / 56. 15.100
libavdevice 56. 3.100 / 56. 3.100
libavfilter 5. 2.103 / 5. 2.103
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, rtsp, from 'rtsp://<rtsp_source>:554...':
Metadata:
title : Media Presentation
comment : <comment>
Duration: N/A, start: 0.025000, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p, 1920x1080, 30 tbr, 90k tbn, 180k tbc
Stream #0:1: Data: none
Output #0, rtsp, to 'rtsps://<rtsps_dest>:443...':
Metadata:
title : Media Presentation
comment : <comment>
encoder : Lavf56.15.100
Stream #0:0: Video: h264, yuv420p, 1920x1080, q=2-31, 90k tbn, 90k tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[rtsp @ 0000000002d5aa20] Non-monotonous DTS in output stream 0:0; previous: 0, current: 0; changing to 1. This may result in incorrect timestamps in the output file.
[tls @ 00000000056adc00] Error in the push function. bitrate=N/A
[tls @ 00000000056adc00] The specified session has been invalidated for some reason.
Last message repeated 2 times
[tls @ 00000000056adc00] The specified session has been invalidated for some reason.
Last message repeated 31 times
[tls @ 00000000056adc00] The specified session has been invalidated for some reason.
Last message repeated 89 times
[tls @ 00000000056adc00] The specified session has been invalidated for some reason.
Last message repeated 30 times
[tls @ 00000000056adc00] The specified session has been invalidated for some reason.
Last message repeated 92 times
[tls @ 00000000056adc00] The specified session has been invalidated for some reason.
Last message repeated 29 times
[tls @ 00000000056adc00] The specified session has been invalidated for some reason.
Last message repeated 90 times
[tls @ 00000000056adc00] The specified session has been invalidated for some reason.
Last message repeated 29 times
[tls @ 00000000056adc00] The specified session has been invalidated for some reason.
Last message repeated 92 times
...
我需要能够在av_interleaved_write_frame
中检测到失败,以便我可以重新启动连接。