Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffmpeg exits after video is played #3843

Closed
streamingsystems opened this issue Oct 18, 2023 · 1 comment
Closed

ffmpeg exits after video is played #3843

streamingsystems opened this issue Oct 18, 2023 · 1 comment
Assignees
Labels
Codec HEVC, FFmpeg for ingesting, trascoding or codec. EnglishNative This issue is conveyed exclusively in English. Won't fix We won't fix it.

Comments

@streamingsystems
Copy link

Describe the bug
Hi,

I think I found another issue where ffmpeg is crashing when the video is completed similar to this issue:

#3803

After a video is played ffmpeg exists with this:

av_interleaved_write_frame(): Broken pipeq=-1.0 size= 36024kB time=00:02:37.73 bitrate=1870.9kbits/s speed= 1x
[flv @ 0x7fb3d4106880] Failed to update header with correct duration.
[flv @ 0x7fb3d4106880] Failed to update header with correct filesize.
[flv @ 0x7fb3d07159c0] Failed to update header with correct duration.
[flv @ 0x7fb3d07159c0] Failed to update header with correct filesize.
Error writing trailer of rtmp://127.0.0.1:1935/live/map_1: Broken pipe
[flv @ 0x7fb3d0714200] Failed to update header with correct duration.
[flv @ 0x7fb3d0714200] Failed to update header with correct filesize.
Error writing trailer of rtmp://127.0.0.1:1935/live/map_2: Broken pipe
[flv @ 0x7fb3d1110fc0] Failed to update header with correct duration.
[flv @ 0x7fb3d1110fc0] Failed to update header with correct filesize.
Error writing trailer of rtmp://127.0.0.1:1935/live/map_3: Broken pipe
frame= 3950 fps= 25 q=-1.0 Lq=-1.0 q=-1.0 q=-1.0 size= 38958kB time=00:02:38.03 bitrate=2019.4kbits/s speed= 1x
video:37685kB audio:1236kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.094195%
Error closing file rtmp://127.0.0.1:1935/live/map_1: Broken pipe
Error closing file rtmp://127.0.0.1:1935/live/map_2: Broken pipe
Error closing file rtmp://127.0.0.1:1935/live/map_3: Broken pipe

In issue 3803 it was a problem with ffmpeg but you were able to make a change to the server to work around this issue.

Version
Latest
To Reproduce

  1. Download and extract the the ZIP file that contains 4 videos:

https://www.dropbox.com/scl/fi/q9wlzlafb75obu84e64v0/ffmpeg-map.zip?rlkey=7ahs16533ghdnfvddl51or0z6&dl=0

  1. Run this command:

ffmpeg -stream_loop -1 -re -i 1.mp4 -stream_loop -1 -re -i 2.mp4 -stream_loop -1 -re -i 3.mp4 -stream_loop -1 -re -i 4.mp4 -map 0 -c copy -f flv rtmp://127.0.0.1:1935/live/map_0 -map 1 -c copy -f flv rtmp://127.0.0.1:1935/live/map_1 -map 2 -c copy -f flv rtmp://127.0.0.1:1935/live/map_2 -map 3 -c copy -f flv rtmp://127.0.0.1:1935/live/map_3

The video is 2m 38s long, when it reaches the end ffmpeg exits due to "Broken pipe".

Expected behavior

Ffmpeg should start over and loop the video forever.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

@winlinvip winlinvip added the EnglishNative This issue is conveyed exclusively in English. label Oct 18, 2023
@streamingsystems streamingsystems changed the title ffmpeg exists after video is played ffmpeg exits after video is played Oct 18, 2023
@winlinvip winlinvip self-assigned this Mar 24, 2024
@winlinvip winlinvip added the Codec HEVC, FFmpeg for ingesting, trascoding or codec. label Mar 24, 2024
@winlinvip
Copy link
Member

First of all, this issues is entirely a bug of FFmpeg, not SRS. It fails to handle the EOF event, and leads to the failure of loop ingesting file stream.

Second, you should never rely on FFmpeg for IO handling and error handling, because FFmpeg is too complex to handle all events correctly and without bugs. Therefore, you must manage the FFmpeg, restarting it if it gets stuck or fails to run, like what SRS Stack does.

@winlinvip winlinvip closed this as not planned Won't fix, can't repro, duplicate, stale Mar 24, 2024
@winlinvip winlinvip added the Won't fix We won't fix it. label Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Codec HEVC, FFmpeg for ingesting, trascoding or codec. EnglishNative This issue is conveyed exclusively in English. Won't fix We won't fix it.
Projects
None yet
Development

No branches or pull requests

2 participants