Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting ts to mp4 with Python [closed]

I've tried what feels like a million ffmpeg wrappers and none of them seem to work, so I thought I'd ask here. How would one go about losslessly converting .ts files to .mp4 with Python? Every ffmpeg wrapper I've tried has not worked despite both the ffmpeg bin and .exe being in the PATH and every installation step followed. Is there a simple wrapper that I can use? I hate to ask for a step-by-step, but I must be doing something wrong, right?

like image 296
displayname Avatar asked Apr 08 '26 20:04

displayname


1 Answers

Since your conversion requirements are specific, why don't you just call ffmpeg directly from Python with subprocess.run() (Python >= 3.5) or subprocess.call() (Python < 3.5)?

import subprocess

infile = 'video.ts'
outfile = 'video.mp4'

subprocess.run(['ffmpeg', '-i', infile, outfile])

You can capture the output if wanted. Refer to the documentation for that.

like image 119
mhawke Avatar answered Apr 10 '26 09:04

mhawke



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!