Matt
Matt

Reputation: 161

Converting jpg's to mp4 using FFmPy

I have a file full of jpg images that I would like to convert into an mp4 video. I have managed to do this on the command line using

cat path/to/pictures/%d.jpg | ffmpeg -f image2pipe -i - output.mp4

However when I try and go about doing it via FFmPy:

ff = ffmpy.FFmpeg(
inputs={'path/to/pictures/%d.jpg': None},
outputs={'output.mp4': None})

ff.cmd
ff.run()

I will run into the error:

    FFRuntimeError: `ffmpeg -i path/to/pictures/1.jpg -f output.mp4` exited with status 1

STDOUT:


STDERR:

I'm really not sure what the issue is here, any change I make results in the same error. Any help would be appreciated, thanks.

Upvotes: 0

Views: 2923

Answers (1)

unutbu
unutbu

Reputation: 879351

Since you know the ffmpeg command which works from the command line, it might be easier to simply call it using subprocess:

import subprocess

cmd = ['ffmpeg', '-i', '/path/to/pictures/%d.jpg', 'output.mp4']
retcode = subprocess.call(cmd)
if not retcode == 0:
   raise ValueError('Error {} executing command: {}'.format(retcode, ' '.join(cmd)))    

Upvotes: 2

Related Questions