2

I am trying to extract a single frame at every second from a video , Using this command on command line using ffmpeg ffmpeg -i input_file.mp4 -r 1 %04d.jpg

I am able to do this task using ffmpeg on command line.

But I want to use same command in python script, how do I do that and what should be the code? I am very new to this field.

1 Answer 1

2

You could you os.system or you could use the ffmpeg library, but since it is only one command I would just use the os.system method

# importing os module  
import os  

input_file = 'something.mp4' # You should enter the file's path here
# Using fstring for variable file name
# Command to execute 
# Using Windows OS command 
cmd = f'ffmpeg -i {input_file} -r 1 %04d.jpg'
# Using os.system() method 
os.system(cmd) 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.