From a brief look at FFMPY, you could do this using ffmpy.FFmpeg, as that allows any and all FFMPEG command line options, including -f. -- Click the link for documentation.

You could do the FFMPEG command with os.system. You'll need to import OS anyway to iterate through the files.

You would need to iterate through all the files in a directory though. This would be the more challenging bit, it's quite easy with a for loop though.

for filename in os.listdir(path):
    if (filename.endswith(".mp4")): #or .avi, .mpeg, whatever.
        os.system("ffmpeg -i {0} -f image2 -vf fps=fps=1 output%d.png".format(filename))
    else:
        continue

The above code iterates through the directory at path, and uses command prompt to execute your given FFMPEG command, using the filename (if it's a video file) in place of mymovie.avi

Answer from ocelot on Stack Overflow
🌐
GitHub
github.com › kkroening › ffmpeg-python
GitHub - kkroening/ffmpeg-python: Python bindings for FFmpeg - with complex filtering support · GitHub
Why do I get an import/attribute/etc. error from import ffmpeg? Make sure you ran pip install ffmpeg-python and not pip install ffmpeg (wrong) or pip install python-ffmpeg (also wrong).
Starred by 11K users
Forked by 941 users
Languages   Python
🌐
PyPI
pypi.org › project › python-ffmpeg
python-ffmpeg
JavaScript is disabled in your browser. Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
Discussions

ffmpeg in python script - Stack Overflow
I would like to run the following command in a python script, I also want to make it loop over several videos in a folder. This is the command I want to run. ffmpeg -i mymovie.avi -f image2 -vf fps=fps=1 output%d.png ... import ffmpy import os path = './Videos/MyVideos/' for filename in ... More on stackoverflow.com
🌐 stackoverflow.com
How to import ffmpeg with python - Help - Pipedream
I want to use pydub, but I get a path error and figured that I have to install ffmpeg. Can somebody help me to set it up? More on pipedream.com
🌐 pipedream.com
0
September 20, 2024
How to import ffmpeg into Python?
install python-ffmpeg with pip More on reddit.com
🌐 r/learnpython
2
1
July 18, 2022
Help with writing FFMPEG Python Code
With Python you're probably best using subprocess.run rather than os.system. I would also recommend you expect the '.mp4' in the source name, then you can just drag the file into the terminal window when you get the input prompt. Note you should probably be adding more parameters to your command to specify what codec, bitrate, etc you want new video to have, at the moment you're just letting ffmpeg guess/ import subprocess import sys # get user input file_in = input('Drag mp4 file here: ') # remove escape charachters from file path file_in = file_in.replace("\\", "").strip() print(file_in) # check if the file has an mp4 extention if not file_in.endswith('.mp4'): print('Not an mp4 file') sys.exit(1) file_out = file_in.replace('.mp4', '.mov') # put each argument of the command in a list command = ['ffmpeg', '-i', file_in, file_out] # run the command subprocess.run(command) More on reddit.com
🌐 r/ffmpeg
3
0
March 9, 2023
🌐
Bannerbear
bannerbear.com › blog › how-to-use-ffmpeg-in-python-with-examples
How to Use FFMpeg in Python (with Examples) - Bannerbear
Once you have the tools above installed, open up the terminal/command prompt and run the command below in your working directory to install ffmpeg-python in your Python project using pip: ... Then, create a Python file (eg. index.py), import ...
🌐
Medium
medium.com › @aleksej.gudkov › ffmpeg-python-example-a-guide-to-using-ffmpeg-with-python-020cdb7733e7
FFmpeg Python Example: A Guide to Using FFmpeg with Python | by UATeam | Medium
November 12, 2025 - Combining FFmpeg with Python enables developers to automate media processing workflows and integrate advanced media handling into Python applications. In this article, we’ll provide a simple and practical example of using FFmpeg with Python to manipulate video and audio files.
🌐
FFmpeg Python
kkroening.github.io › ffmpeg-python
ffmpeg-python: Python bindings for FFmpeg — ffmpeg-python documentation
These parameters allow the x and y expressions to refer each other, so you can for example specify y=x/dar. ... Apply custom filter. filter_ is normally used by higher-level filter functions such as hflip, but if a filter implementation is missing from ffmpeg-python, you can call filter_ directly to have ffmpeg-python pass the filter name and arguments to ffmpeg verbatim.
🌐
Cloudinary
cloudinary.com › home › a beginner’s guide to ffmpeg in python
A Beginner’s Guide to FFmpeg in Python | Cloudinary
January 14, 2026 - Here’s an example that compresses the video file using Constant Rate Factor (CRF) and reducing the audio bitrate: import ffmpeg def compress_video(input_file, output_file, crf=23, audio_bitrate='128k'): try: ffmpeg.input(input_file).output( ...
Find elsewhere
🌐
Gumlet
gumlet.com › learn › ffmpeg-python
How to Use FFmpeg with Python in 2026? - Gumlet
January 22, 2026 - Here’s an example of how to use pydub to trim an audio file: from pydub import AudioSegment # Load an MP3 file audio = AudioSegment.from_file("input.mp3") # Trim the audio (first 30 seconds) audio = audio[:30000] # Save the result ...
🌐
PyPI
pypi.org › project › ffmpeg-python
ffmpeg-python · PyPI
Download URL: ffmpeg_python-0.2.0-py3-none-any.whl
      » pip install ffmpeg-python
    
Published   Jul 06, 2019
Version   0.2.0
🌐
Readthedocs
python-ffmpeg.readthedocs.io
python-ffmpeg
from ffmpeg import FFmpeg, Progress def main(): ffmpeg = ( FFmpeg() .option("y") .input( "rtsp://username:password@127.0.0.1/cam", rtsp_transport="tcp", rtsp_flags="prefer_tcp", ) .output("output.mp4", vcodec="copy") ) @ffmpeg.on("progress") def time_to_terminate(progress: Progress): if ...
🌐
Pipedream
pipedream.com › help
How to import ffmpeg with python - Help - Pipedream
September 20, 2024 - I want to use pydub, but I get a path error and figured that I have to install ffmpeg. Can somebody help me to set it up?
🌐
Medium
pjcarroll.medium.com › python-and-ffmpeg-2de5d29a4e2c
Python and ffmpeg. Say goodbye to directory woes | by PJ Carroll | Medium
December 26, 2020 - ... import ffmpeg, os print("This takes mp4 files from ./video and converts them into mp3 files in ./audio") print("\nyou are here:\n") current_directory = os.getcwd() print(current_directory + "\n")
🌐
GitHub
github.com › jonghwanhyeon › python-ffmpeg
GitHub - jonghwanhyeon/python-ffmpeg: A python binding for FFmpeg which provides sync and async APIs · GitHub
from ffmpeg import FFmpeg, Progress def main(): ffmpeg = ( FFmpeg() .option("y") .input( "rtsp://username:password@127.0.0.1/cam", rtsp_transport="tcp", rtsp_flags="prefer_tcp", ) .output("output.mp4", vcodec="copy") ) @ffmpeg.on("progress") ...
Starred by 382 users
Forked by 52 users
Languages   Python
🌐
Readthedocs
ffmpy.readthedocs.io › 1.0.0
ffmpy — ffmpy 1.0.0 documentation
ffmpy requires Python 3.9 or greater. pip install ffmpy · from ffmpy import FFmpeg ff = FFmpeg( inputs={'input.mp4': None}, outputs={'output.avi': None} ) ff.run() This takes input.mp4 file in the current directory as the input, changes the video container from MP4 to AVI without changing ...
🌐
AmazingRDP
amazingrdp.com › home › installing and using ffmpeg in python
Using FFmpeg in Python: Installation & Examples
July 10, 2024 - With FFmpeg installed, we can now install the ffmpeg-python library. This library provides a more Pythonic interface to FFmpeg. ... Here’s a basic example of how to use FFmpeg in Python to convert a video file from one format to another.
🌐
Clipcat
clipcat.com › blog › a-beginners-guide-to-using-ffmpeg-in-python-for-video-processing
A Beginner’s Guide to Using FFmpeg in Python for Video Processing - Clipcat
FFmpeg will automatically convert the video to MP3 using the default audio codec, libmp3lame. Here’s an example of extracting the audio from a video file: import ffmpeg ( ffmpeg.input("input.mp4") .output("audio.mp3") .run() )
🌐
Medium
gradient-drift.medium.com › how-to-use-ffmpeg-on-python-2ba3fa360ba7
How to Use FFmpeg on Python?. I often read the python weekly… | by Gradient Drift | Medium
January 5, 2020 - It can also capture and encode ... refer to its exampleor create your own scriptFor example: change the video quality, change the file type, change the bit rates...........
🌐
Medium
artwilton.medium.com › running-ffmpeg-commands-from-a-python-script-676eaf2b2739
Running FFmpeg commands from a Python Script | by Arthur Wilton | Medium
May 4, 2021 - FFmpeg is one of my favorite tools for encoding video files, but even as someone who has used it for a few years the syntax can still be pretty tricky. To help with this I decided to create a Python script to help automate the common task of taking a video file and encoding it to an MP4 encoded with x264. I’ll go through the process of how I created the script and break down each section. The first thing I do is import ...
🌐
Delft Stack
delftstack.com › home › howto › python › ffmpeg python
FFmpeg in Python Script | Delft Stack
October 10, 2023 - The following example prints the width and height of a specified video in Python. import ffmpeg probe = ffmpeg.probe("output.mp4") video = next( (stream for stream in probe["streams"] if stream["codec_type"] == "video"), None ) width = ...