0

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.

Matt
  • 161
  • 1
  • 10
  • What happens if you run the command from the error directly? Rather than the piping command. – FamousJameous Jun 29 '18 at 15:55
  • If you mean run the ff.cmd output in the command line directly, it will get to `/path/to/pictures/101.jpg` and ask `'File '/home/matthewl/Downloads/Eyes_side_to_side/101.jpg' already exists. Overwrite ? [y/N]`, continuously till the last jpg` – Matt Jun 29 '18 at 16:01
  • Are you using a python for-loop? How is the `%d` in `'/path/to/pictures/%d.jpg'` getting substituted by numeric strings? (We need to prevent that from happening...) – unutbu Jun 29 '18 at 16:06
  • I'm not using any loops, literally just the code above, it's more or less a copy from the examples FFmPy give in their documentation, i thought the `%d` would list all my jpg files which are '1.jpg' all the way to '500.jpg' – Matt Jun 29 '18 at 16:10
  • I mean if it helps get to the core of the problem, I can write the path incorrectly or just try and convert one image to an mp4 and I will still get the same error. – Matt Jun 29 '18 at 16:19

1 Answers1

2

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)))    
unutbu
  • 842,883
  • 184
  • 1,785
  • 1,677