Python 3 FFMPEG Script to Cut, Trim, Change FPS & Scale Videos at Different Resolutions Using Python-FFMPEG Library

Python 3 FFMPEG Script to Cut, Trim, Change FPS & Scale Videos at Different Resolutions Using python-FFMPEG Library

import ffmpeg
import sys
 
sys.path.append(r'C:\ffmpeg\bin') # your ffmpeg file path
 
stream = ffmpeg.input('video.mp4') # video location
 
stream = stream.trim(start = 0, duration=5).filter('setpts', 'PTS-STARTPTS')
 
stream = ffmpeg.output(stream, 'output.mp4')
 
ffmpeg.run(stream)

import ffmpeg
import sys
 
sys.path.append(r'C:\ffmpeg\bin') # your ffmpeg file path
 
stream = ffmpeg.input('video.mp4') # video location
 
stream = stream.trim(start = 0, duration=5).filter('setpts', 'PTS-STARTPTS')
stream = stream.filter('fps', fps=15, round='up').filter('scale', w=128, h=128)
 
stream = ffmpeg.output(stream, 'output.mp4')
 
ffmpeg.run(stream)

Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment