Opened 4 years ago

Closed 4 years ago

#9268 closed defect (invalid)

return code 0 when SRT stream fails

Reported by: Elliott Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: libsrt
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

When ffmpeg is playing an SRT stream and that stream disappears (network issue, etc.), I believe it should exit with an error code, so that external scripts can respond appropriately. Instead it returns 0.

On the other hand, if I try to start ffmpeg with a bad SRT URL, it returns 1 which makes sense.

$ /usr/local/bin/ffmpeg -re -i "srt://192.168.4.3:8888?transtype=live&recv_buffer_size=1M&ffs=1048576"   -codec copy -f mpegts pipe:1 > pipe.ts
ffmpeg version git-2021-05-20-ab658db4 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 8 (Raspbian 8.3.0-6+rpi1)
  configuration: --enable-libx264 --enable-libx265 --enable-libsrt --enable-gpl --enable-libopus --enable-shared --enable-omx-rpi --enable-mmal --extra-cflags='-march=armv8-a -mfloat-abi=hard -mfpu=neon-fp-armv8 -mneon-for-64bits'
  libavutil      57.  0.100 / 57.  0.100
  libavcodec     59.  1.100 / 59.  1.100
  libavformat    59.  2.100 / 59.  2.100
  libavdevice    59.  0.100 / 59.  0.100
  libavfilter     8.  0.101 /  8.  0.101
  libswscale      6.  0.100 /  6.  0.100
  libswresample   4.  0.100 /  4.  0.100
  libpostproc    56.  0.100 / 56.  0.100
[aac @ 0x1563d70] Assuming an incorrectly encoded 7.1 channel layout instead of a spec-compliant 7.1(wide) layout, use -strict 1 to decode according to the specification instead.
[aac @ 0x1563d70] This stream seems to incorrectly report its last channel as SCE[7], mapping to LFE[0]
[hevc @ 0x1563390] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x1563390] Error parsing NAL unit #2.
[hevc @ 0x1563390] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x1563390] Error parsing NAL unit #2.
[hevc @ 0x1563390] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x1563390] Error parsing NAL unit #2.
[hevc @ 0x1563390] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x1563390] Error parsing NAL unit #2.
[hevc @ 0x1563390] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x1563390] Error parsing NAL unit #2.
Input #0, mpegts, from 'srt://192.168.4.3:8888?transtype=live&recv_buffer_size=1M&ffs=1048576':
  Duration: N/A, start: 27.769333, bitrate: N/A
  Program 1 
  Stream #0:0[0x3e9]: Video: hevc (Main 10) ([36][0][0][0] / 0x0024), yuv420p10le(tv), 3840x2160 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 90k tbn
  Stream #0:1[0x3ea]: Audio: aac (HE-AAC) ([15][0][0][0] / 0x000F), 48000 Hz, 7.1, fltp, 319 kb/s
Output #0, mpegts, to 'pipe:1':
  Metadata:
    encoder         : Lavf59.2.100
  Stream #0:0: Video: hevc (Main 10) ([36][0][0][0] / 0x0024), yuv420p10le(tv), 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 23.98 fps, 23.98 tbr, 90k tbn
  Stream #0:1: Audio: aac (HE-AAC) ([15][0][0][0] / 0x000F), 48000 Hz, 7.1, fltp, 319 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
srt://192.168.4.3:8888?transtype=live&recv_buffer_size=1M&ffs=1048576: Input/output error1.01x       
frame=  128 fps= 23 q=-1.0 Lsize=   20904kB time=00:00:05.54 bitrate=30873.8kbits/s speed=1.01x    
video:20193kB audio:217kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.424097%

$ echo $?
0

Change History (2)

comment:1 by Carl Eugen Hoyos, 4 years ago

Component: undeterminedavformat
Keywords: libsrt added
Version: unspecifiedgit-master

comment:2 by Marton Balint, 4 years ago

Resolution: invalid
Status: newclosed

This looks invalid, if you don't specify -xerror then don't expect ffmpeg to report input errors as failure.

The usecase seems fishy as well. If ffmpeg quits during a live stream session, how can that be a success? Also -re is harmful for such use, and for passing through mpegts stream from srt, you are most probably better off with srt-live-transmit, remuxing the stream is not necessary / harmful in fact.

Note: See TracTickets for help on using tickets.