I have to create a video using earlier extracted frames and the following code works fine:
import os
fps = 25
os.system("ffmpeg -r fps -i Encode/encode_image%01d.png -vcodec mpeg4 -y movie.mp4")
But storing framerate (which is 25 in this case) in fps
variable and passing it in -r
, I am getting following error:
"Error parsing framerate fps."
Meanwhile, the code below, creates a video:
import os
fps = 25
os.system("ffmpeg -r 25 -i Encode/encode_image%01d.png -vcodec mpeg4 -y movie.mp4")
But the framerate is different for every one of my videos (that's why I am storing it in a variable). Due to above error I am unable to pass different frame rate value each time and, I cannot type the value (like 25) directly.
Please suggest me some way to tackle this problem or provide me with another Python code to combine frames into video.