Me and a friend are currently working on a twitter bot which uploads images taken from randomly chosen video files.
We are using ffmpeg, with subprocess.call()
, to get out.jpg from a video file,
which is working fine when the subtitles are hardcoded into the video.
We've also made it burn the subtitles into the out.jpg outside of python, but when trying it inside pyhton with subprocess.call()
it won't work and it will say:
Output /file/path/to/file.mkv same as Input #0 - exiting
FFmpeg cannot edit existing files in-place.
This is the code for harcoded subtitles.
subprocess.call(
['ffmpeg', '-y', '-ss', str(randomTime), '-i', filepath, '-vframes', '1', '-vf', 'scale=1920:1080', '-q:v', '1',
'-qmin', '1', tmpfilename])
And this the code for non hardcoded subtitles.
subprocess.call(
['ffmpeg', '-y', '-ss', str(randomTime), '-copyts', '-i', filepath, '-vf', 'subtitles', filepath, '-vframes', '1', '-vf', 'scale=1920:1080',
'-vf', '-q:v', '1', '-qmin', '1', '-frames:v', '1', tmpfilename])
Also both me and my friend are not so sure if calling ffmpeg using subprocess.call()
is the right way to do it in python.
Any kind of help is welcome and please ask me for more code or more details if needed.