Skip to content

AP-Atul/pympeg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pympeg (python + ffmpeg)

A simple to use ffmpeg binding in python. Simple filters command can be implemented using simple functions without worrying about the ffmpeg syntax. Useful in situation when you know how to construct ffmpeg command but don't want it to look ugly with for loops.

Usage

Four functions to work with:

pympeg.input(name="example.mp4")
pympeg.filter(intputs=any, filter_name="trim", params={"start": 3, "duration": 10})
pympeg.arg(caller=any, args="concat=n=1", outputs=["audio", "video"]) # inputs= is available
pympeg.run() # default adds overwrite file option (ffmpeg -y )
graph = pympeg.graph() # returns a list of nodes, use print to get representation

Examples

  1. Adding filters
out  = (
        pympeg.input(name="example.mp4")
        .filter(filter_name="trim", params={"start": 2, "duration": 10})
        .output(name="output.mp4")
        .run()
)

command generated :: ffmpeg -i example.mp4  -y -filter_complex \
"[0] trim=start=2:duration=10 [nyQ]" -map "[nyQ]" output.mp4 
  1. Implementing simple file conversion
out = (
    pympeg.input(name="example.mp4")
    .output(name="example.wav")
    .run()
)

command generated :: ffmpeg -i example.mp4 example.wav 

Note: Use pympeg.init() when using multiple run commands

Contribute

Yes! all/any contributions are welcome.