Skip to content

Instantly share code, notes, and snippets.

@taojy123
Created February 1, 2022 04:55
Show Gist options
  • Save taojy123/c410a5db3d564614439ad41b86ebc1b1 to your computer and use it in GitHub Desktop.
Save taojy123/c410a5db3d564614439ad41b86ebc1b1 to your computer and use it in GitHub Desktop.
使用 ffmpeg 裁剪视频
import sys
import os
fnames = os.listdir('s1')
fnames.sort()
for fname in fnames:
if 'mp4' not in fname:
continue
if 'mini' in fname:
continue
print(fname)
fname2 = fname.replace('.mp4', '_mini.mp4')
# cmd = f"./ffmpeg -i s1/{fname} -vf crop='in_w:in_h*0.643:0:in_h*0.15' -acodec copy -t 120 s1/{fname2}"
cmd = f"./ffmpeg -i s1/{fname} -vf crop='in_w:in_h*0.643:0:in_h*0.15' s1/{fname2}"
print(cmd)
os.system(cmd)
print('========================== finish ===================================')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment