Skip to content

Enable pausing and resuming of stream#93

Open
yannikwirbs wants to merge 1 commit intoDiscord-RE:masterfrom
yannikwirbs:master
Open

Enable pausing and resuming of stream#93
yannikwirbs wants to merge 1 commit intoDiscord-RE:masterfrom
yannikwirbs:master

Conversation

@yannikwirbs
Copy link

@yannikwirbs yannikwirbs commented Apr 26, 2024

Video and audio output pipe are on hold while paused.
There is no video or audio in discord.
Maybe there is a way to implement a way to send a still image to the video.
Video and audio are not desyncing.

REFERENCE ISSUE: #5

Video and audio output pipe are on hold while paused.
@longnguyen2004
Copy link
Member

longnguyen2004 commented Apr 26, 2024

I'm wondering how this will behave in an actual live stream, and whether stream backpressure will be a problem.
Also, eloquent-ffmpeg has a built-in pause and resume function, maybe we should look at that as well?

Repeating the last frame is definitely not possible, since it'll break the bitstream.

@longnguyen2004
Copy link
Member

longnguyen2004 commented Apr 26, 2024

Investigating RFC 7728 is also interesting Ignore, this is for a receiver to request a pause

@s074
Copy link
Member

s074 commented Apr 28, 2024

This will also only work if noSleep is disabled.

From looking at eloquent-ffmpeg it seems it just suspends the process and then resumes it, like some people were already doing using SIGSTOP and SIGCONT

@longnguyen2004
Copy link
Member

longnguyen2004 commented Apr 28, 2024

like some people were already doing using SIGSTOP and SIGCONT

And it also works on Windows using the undocumented NtSuspendProcess and NtResumeProcess functions, so that's a plus.

I also wonder how the functionality should be exposed to user code. Maybe we'd need to create some kind of playback controller object, with play(), pause() and stop() functions.

@BitcircuitEU
Copy link

@longnguyen2004 while implementing ffmpeg api in nodejs maybe make a pause function that stores current timecode of demuxing and continue from there if possible. Not sure if SIGSTOP and SIGCONT is that reliable.

@Giggitybyte
Copy link

Anybody taken a look at this recently? Would be nice if this was built-in to the library.

@longnguyen2004
Copy link
Member

I've thought about it a few times, and I think that video playback management should be best left to a proper video playout system, such as ffplayout or CasparCG. Bare ffmpeg doesn't give much in terms of control, and the method in this PR can cause problems when pausing for a long time

@yannikwirbs
Copy link
Author

yannikwirbs commented Jul 26, 2025

What problems are there? I am by no means familiar with ffmpeg, but it seemed like a good idea suspending the callback. The only things coming to my mind that might be causing problems for long periods is the pipe breaking or ffmpeg to stop after long idle, right? But I get that you would rather have proper handling. It's been some time, do you want to close the PR?

@longnguyen2004
Copy link
Member

I'll close it when I can come up with something better. Maybe it'll be something over at https://github.com/Discord-RE/FFmpeg-input-premade that integrates CasparCG for a complete solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants