1

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.

Rotem
  • 30,366
  • 4
  • 32
  • 65
amit
  • 21
  • 1
  • 5
  • There are many alternatives for concatenating strings and integers in Python. See: [Python String and Integer concatenation](https://stackoverflow.com/questions/2847386/python-string-and-integer-concatenation). And [String Concatenation and Formatting](https://www.pythonforbeginners.com/concatenation/string-concatenation-and-formatting-in-python). In Python 3.6 and above you can also use "f-Strings". See [Python 3's f-Strings](https://realpython.com/python-f-strings/). – Rotem Jun 06 '21 at 20:09

0 Answers0