ffmpeg pause and resume live stream encode

Viewed 831

I am trying to use ffmpeg to create a live stream from a video file, encoded on the fly, that can be paused and resumed (like what Plex does). Suspending the ffmpeg process pauses the encoding, but resuming it causes ffmpeg to try to catch up to where it would have been in the stream. I assume there is some kind of internal timestamp that ffmpeg is looking at to keep track of timing. I would like ffmpeg to continue encoding from where it left off.

I am using the "-re" switch to read the file at it's native framerate. I have tried hls and dash formats; as far as I can tell, they both behave the same. Segmenting the entire file beforehand is not an option, I would like to be able to stream using only temporary files created on the fly.

Here are simplified commands I've been using.

HLS: ffmpeg -y -re -i "input.mkv" -movflags +frag_keyframe+empty_moov+faststart -f hls -hls_time 2 -hls_list_size 10 -hls_delete_threshold 1 -hls_flags split_by_time+delete_segments+second_level_segment_index -strftime playlist.m3u8

DASH: ffmpeg -re -i input.mkv" -f dash -seg_duration 2 -window_size 5 -extra_window_size 0 -remove_at_exit 1 playlist.m3u8

0 Answers
Related