Skip to content

How to Use FFmpeg in Python?

Command line one-liners are great for quick and one off FFMPEG experiences but sooner or later you’re going to want to start building custom applications for efficiency. FFMPEG can be used with almost any programming language with a couple of simple tricks. Some languages might even have libraries of their own to extend FFMPEG natively. Below are a few examples of various languages using FFMPEG:

Python using 3rd party library ffmpy, More information: https://pypi.org/project/ffmpy/

>>> import ffmpy
>>> ff = ffmpy.FFmpeg(
...    inputs={'input.mp4': None},
...    outputs={'output.mp3': None}
... )
>>> ff.run()

Python using os.system

>>> import os
>>> os.system("ffmpeg -i input.mp4 output.mp3") 

Love FFmpeg? Grab a copy of FFmpeg For Beginners on Kindle or Paperback to learn over 120 ways to master FFmpeg!

buy now on amazon