Is there a way to pipe the output live to ffplay so it can be viewed immediately?
One way is to run the ffmpeg process with raw video output over a pipe, and then have ffplay decode the raw video. Something like this:
import ffmpeg
import subprocess
in_filename = 'in.mp4'
width, height = 1920, 1080 # (or use ffprobe or whatever)
process1 = (
ffmpeg
.input(in_filename)
# (filters/etc. go here)
.output('pipe:', format='rawvideo', pix_fmt='rgb24')
.run_async(pipe_stdout=True)
)
process2 = subprocess.Popen(
[
'ffplay',
'-f', 'rawvideo',
'-pix_fmt', 'rgb24',
'-s', '{}x{}'.format(width, height),
'-i', 'pipe:',
],
stdin=process1.stdout,
)
process1.wait()
process2.wait()
FYI there's no direct support for ffplay in ffmpeg-python currently.
@kkroening thanks so much for this! I wanted to ask a question related to the code above:
If I implement any kind of filtering in the section you marked with: # (filters/etc. go here) I seem to be unable to live affect the args given to the filters. So if for example blur the image by calling:
.filter('gblur', sigma=blurIndex)
and I try to increment blur index in time only the first value seems to affect the video. Do you know if it's even possible to affect the filter parameters live?
Do you know if it's even possible to affect the filter parameters live?
There is no way that I know of to change ffmpeg filter graphs dynamically.
Most helpful comment
One way is to run the ffmpeg process with raw video output over a pipe, and then have ffplay decode the raw video. Something like this:
FYI there's no direct support for
ffplayinffmpeg-pythoncurrently.