0
\$\begingroup\$

I'm encountering an issue with an ffmpeg process in my Unity application. My application receives an encoded video frame every 0.1 seconds (encoded with H.265). I have a script that creates and starts an ffmpeg process using the following command:

ffmpeg -c:v hevc -i - -pix_fmt rgba -f rawvideo -

I pass the encoded frame to this process' stdin, and it properly decodes it. I then render the results from stdout to a texture in my application.

However, the problem arises when the ffmpeg process automatically exits after detecting the end of data in its input stream. This behavior poses a challenge because I need the ffmpeg process to continue running to properly decode subsequent frames.

Creating a new process every time the existing one exits is not a viable solution because the new process lacks the context of decoding the previous I-frame, causing errors when decoding P-frames.

I've tried using the -re flag and using a named input stream (-i pipe:0) instead of stdin, but neither of these solutions worked. Despite these attempts, the ffmpeg process still exits after decoding the first frame.

Is there a way to force the ffmpeg process to remain active even after decoding the first frame? Perhaps there is a flag or setting that instructs ffmpeg to wait for new input data, even after reaching the end of the input stream?

Any insights or suggestions would be greatly appreciated. Thank you.

\$\endgroup\$
1
  • \$\begingroup\$ From a quick google search (I cant guarantee it will work though) A simple method is to suspend it with ctrl + z. Or you could get the PID with pgrep ffmpeg then use kill -s SIGSTOP <PID> to suspend. Then resume with fg command or kill -s SIGCONT <PID>. Unfortunately this will not survive a reboot. \$\endgroup\$
    – Pow
    Commented Feb 12 at 10:29

0

You must log in to answer this question.

Browse other questions tagged .