kkroening / ffmpeg-python

Python bindings for FFmpeg - with complex filtering support
Apache License 2.0
10.11k stars 893 forks source link

ffmpeg command line equivalent #356

Open wabiloo opened 4 years ago

wabiloo commented 4 years ago

If i use ffmpeg-python to create my configuration, is there a way to output what the equivalent ffmpeg command would be? (as a way to be able to troubleshoot my configuration)

rexmalebka commented 4 years ago

yes compile does the job

import ffmpeg
inp = ffmpeg.input('video.mkv').trim(start=0, end=3).output('output.avi')
print(inp.compile())
['ffmpeg', '-i', 'video.mkv', '-filter_complex', '[0]trim=end=3:start=0[s0]', '-map', '[s0]', 'output.avi']
xcom169 commented 4 years ago

yes compile does the job

import ffmpeg
inp = ffmpeg.input('video.mkv').trim(start=0, end=3).output('output.avi')
print(inp.compile())
['ffmpeg', '-i', 'video.mkv', '-filter_complex', '[0]trim=end=3:start=0[s0]', '-map', '[s0]', 'output.avi']

How can this fluent form to be compiled?

(ffmpeg .input(file) .filter('fps', fps=25, round='up') .output(outputFile, map=0, video_size='hd720', c='copy', {'c:a': 'ac3'}, {'c:v': 'libx264'}) .overwrite_output() .run() )

Another question please: 'Matroska preset = slow 'can be set in ffmpeg-python?

phanirithvij commented 4 years ago

@xcom169 you can do

inp = (ffmpeg
.input(file)
.filter('fps', fps=25, round='up')
.output(outputFile, map=0, video_size='hd720', c='copy', **{'c:a': 'ac3'}, **{'c:v': 'libx264'})
.overwrite_output()
)
print(inp.compile())
inp.run()