I'm trying to write a program that pipes PNG data into FFMPEG to render it into a video. The program's video output wasn't working so I am using PNG screenshots as debug input.
The screenshots are all valid PNG files that open normally in any image viewer. However when I run the command:
cat 2017*.png | ./ffmpeg -f image2pipe -r 1 -vcodec png -i - -vcodec libx264 out.mp4
I do get a video output that has 1 second of video for each screenshot starting with 2017 in the directory. However, the video is entirely black and finishes instantly after starting to play the video. (Not one second or frame for each frame).
This is on MSYS on Windows, using a Windows version of FFMPEG, if it makes any difference.
What can I change so it will actually make a video out of the piped input? My first guess is that it might have something to do with either incorrect args or a lack of an appropriate codec.
cat 2017*.png | ./ffmpeg -f image2pipe -framerate 1 -i - -c:v libx264 -vf format=yuv420p -r 25 -movflags +faststart out.mp4
Use the -framerate
input option instead of -r
for image2pipe demuxer.
Many players have trouble with such low frame rate MP4. Add the -r
output option to give it a more normal output rate. ffmpeg
will duplicate frames to match but it will still look as if it is 1 fps.
Add -vf format=yuv420p
(or the alias -pix_fmt yuv420p
) to make the output use a widely compatible pixel format.
Use -movflags +faststart
to enable faster starting playback.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With