DASH HTTP PUT fails with http_persistent and connection closed
|Reported by:||Chris Ribble||Owned by:|
|Blocking:||Reproduced by developer:||no|
|Analyzed by developer:||no|
Summary of the bug:
When live streaming (HLS) with a persistent HTTP connection, if the web server closes the connection ffmpeg shuts down.
How to reproduce:
Streaming to an Apache web server with "KeepAlive On" and "MaxKeepAliveRequests 10", ffmpeg will fail on the 11th PUT request when Apache closes the TCP connection. Streaming to Tomcat service with default configuration, ffmpeg will fail on the 101st PUT request when Tomcat closes the connection.
ffmpeg -report -i /home/chris/Desktop/B3__1080p29_x264_3_1080-full.mp4 -c copy -f dash -seg_duration 2 -http_persistent 1 http://localhost:8080/Manifest.mpd
[http @ 0x55e4fe65d780] Opening 'http://localhost:8080/chunk-stream1-00100.m4s' for writing [http @ 0x55e4fe639780] URL read error: End of file [http @ 0x55e4fe748a40] Opening 'http://localhost:8080/Manifest.mpd' for writing [http @ 0x55e4fe66e780] Opening 'http://localhost:8080/chunk-stream0-00101.m4s' for writing [dash @ 0x55e4fe658500] Unable to open http://localhost:8080/chunk-stream0-00101.m4s for writing: Broken pipe av_interleaved_write_frame(): Broken pipe [http @ 0x55e4fe65d780] Opening 'http://localhost:8080/chunk-stream1-00101.m4s' for writing [dash @ 0x55e4fe658500] Unable to open http://localhost:8080/chunk-stream1-00101.m4s for writing: Connection reset by peer [http @ 0x55e4fe748a40] Opening 'http://localhost:8080/Manifest.mpd' for writing Error writing trailer of http://localhost:8080/Manifest.mpd: Connection reset by peer frame= 6031 fps=0.0 q=-1.0 Lsize=N/A time=00:03:21.20 bitrate=N/A speed= 965x video:84499kB audio:3186kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown Conversion failed!
This was fixed for HLS by https://trac.ffmpeg.org/ticket/7975 and I have attempted to create a similar patch for libavformat/dashenc.c (attached).
I tested the patch against master and also against the 4.2 branch (with f267a2ac9c740c77cee2f2c5fd2bd9bc048768b1 also applied) and it seems to fix the problem, although I am no C expert and I'm sure there are flaws in my patch.