mirror of
https://github.com/blw1138/Zordon.git
synced 2025-12-17 16:58:12 +00:00
Initial commit
This commit is contained in:
32
utilities/ffmpeg_presets.py
Normal file
32
utilities/ffmpeg_presets.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import ffmpeg
|
||||
|
||||
|
||||
def file_info(path):
|
||||
try:
|
||||
return ffmpeg.probe(path)
|
||||
except Exception as e:
|
||||
print('Error getting ffmpeg info: ' + str(e))
|
||||
return None
|
||||
|
||||
|
||||
def generate_fast_preview(source_path, dest_path, max_width=1280, run_async=False):
|
||||
stream = ffmpeg.input(source_path)
|
||||
stream = ffmpeg.output(stream, dest_path, **{'vf': 'format=yuv420p,scale={width}:-2'.format(width=max_width), 'preset': 'ultrafast'})
|
||||
return _run_output(stream, run_async)
|
||||
|
||||
|
||||
def generate_prores_trim(source_path, dest_path, start_frame, end_frame, handles=10, run_async=False):
|
||||
stream = ffmpeg.input(source_path)
|
||||
stream = stream.trim(**{'start_frame': max(start_frame-handles, 0), 'end_frame': end_frame + handles})
|
||||
stream = stream.setpts('PTS-STARTPTS') # reset timecode
|
||||
stream = ffmpeg.output(stream, dest_path, strict='-2', **{'c:v': 'prores_ks', 'profile:v': 4})
|
||||
return _run_output(stream, run_async)
|
||||
|
||||
|
||||
def _run_output(stream, run_async):
|
||||
return ffmpeg.run_async(stream) if run_async else ffmpeg.run(stream)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
x = file_info("/Users/brettwilliams/Desktop/dark_knight_rises.mp4")
|
||||
print(x)
|
||||
Reference in New Issue
Block a user