50

I am attempting to create a video file from a set of JPG images. I have adapted the instructions given in this question but have experienced some issues.

Firstly, not all of the required packages are available, but are replaced by libav-tools, which is already installed - so I think that's not an actual problem?

My files are named image-NN.jpg (NN being an integer) and I have used the command

avconv -i "image-%d.jpg" -r 25 -c:v libx264 -crf 20  -pix_fmt yuv420p movie.mov

as per the linked question, but this just gives a No such file image-%d.jpg error. I

I tried changing it to

avconv -i "image-*.jpg" -r 25 -c:v libx264 -crf 20  -pix_fmt yuv420p movie.mov

and this produces a video file of length 0:00 that appears to only contain one frame. (I am guessing that the * has used the first match, rather than every match).

This question gives a slightly different way of formatting the file name, so I tried

avconv -i "image-%02d.jpg" -r 25 -c:v libx264 -crf 20  -pix_fmt yuv420p movie.mov

This produces a larger file, and makes a video that lasts for about 3 seconds (approx the length I was expecting) but it contains just the first frame.

Another answer on the first linked question suggests using ImageMagick, so I gave this a try

convert -delay 1 image-*.jpg output.mp4

But this produced an error

convert.im6: delegate failed `"ffmpeg" -v -1 -mbd rd -trellis 2 -cmp 2 -subcmp 2 -g 300 -i "%M%%d.jpg" "%u.%m" 2> "%Z"' @ error/delegate.c/InvokeDelegate/1065.

The version of avconv is

carl@number1 ~/Scott's stop-motion/1 $ avconv -version
avconv version 9.18-6:9.18-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
built on Mar 16 2015 13:19:10 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
avconv 9.18-6:9.18-0ubuntu0.14.04.1
libavutil     52.  3. 0 / 52.  3. 0
libavcodec    54. 35. 0 / 54. 35. 0
libavformat   54. 20. 4 / 54. 20. 4
libavdevice   53.  2. 0 / 53.  2. 0
libavfilter    3.  3. 0 /  3.  3. 0
libavresample  1.  0. 1 /  1.  0. 1
libswscale     2.  1. 1 /  2.  1. 1

Where am I going wrong, and what do I need to do?

Additional: It was suggested that I list every file individually, so with a bit of Python I generated this

avconv -i image-01.jpg image-02.jpg image-03.jpg image-04.jpg image-05.jpg image-06.jpg image-07.jpg image-08.jpg image-09.jpg image-10.jpg image-11.jpg image-12.jpg image-13.jpg image-14.jpg image-15.jpg image-16.jpg image-17.jpg image-18.jpg image-19.jpg image-20.jpg image-21.jpg image-22.jpg image-23.jpg image-24.jpg image-25.jpg image-26.jpg image-27.jpg image-28.jpg image-29.jpg image-30.jpg image-31.jpg image-32.jpg image-33.jpg image-34.jpg image-35.jpg image-36.jpg image-37.jpg image-38.jpg image-39.jpg image-40.jpg image-41.jpg image-42.jpg image-43.jpg image-44.jpg image-45.jpg image-46.jpg image-47.jpg image-48.jpg image-49.jpg image-50.jpg image-51.jpg image-52.jpg image-53.jpg image-54.jpg image-55.jpg image-56.jpg image-57.jpg image-58.jpg image-59.jpg image-60.jpg image-61.jpg image-62.jpg image-63.jpg image-64.jpg image-65.jpg image-66.jpg image-67.jpg image-68.jpg image-69.jpg image-70.jpg image-71.jpg image-72.jpg image-73.jpg image-74.jpg image-75.jpg image-76.jpg image-77.jpg image-78.jpg image-79.jpg image-80.jpg image-81.jpg image-82.jpg image-83.jpg image-84.jpg image-85.jpg image-86.jpg image-87.jpg image-88.jpg  -r 25 -c:v libx264 -crf 20  -pix_fmt yuv420p movie.mov

This had the same effect as previous - only the first frame is used.

Additional: This question has been suggested as a possible duplicate, but it relates to acquiring images using a webcam connected to a PC. This is not the issue I am having. I already have the photos; they were taken with an ordinary digital camera.

  • You could try just listing every single frame, instead of a * or a %02d. – TheWanderer Apr 18 '15 at 15:53
  • @Zacharee1 Thanks for the suggestion. I've edited that into the question. – Carl H Apr 18 '15 at 16:19
  • Read this thread. It might help. ubuntuforums.org/showthread.php?t=1538209 – TheWanderer Apr 18 '15 at 17:44
  • @CarlH that makes your question a subset of the linked one - it covers acquiring images and converting them. – muru Apr 20 '15 at 21:32
  • @CarlH I agree that this question is not a duplicate of the linked question, no webcam involved here at all! I have nominated for reopening... – andrew.46 Jan 11 at 5:38
69

You can use ffmpeg, which you can install with the command:

sudo apt install ffmpeg

This is the command all together:

ffmpeg -framerate 25 -i image-%05d.jpg -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p output.mp4

Let me break it down:

-framerate

is the number of frames (images) per second,

-i image-%05d.jpg

this determines the file name sequence it looks for. image- means all of the files start with this. 0 is the number repeated, and the 5 is number of times (so it is looking for any file starting at image-00000.jpg. The d is telling it to count up in whole numbers, so that the files it will detect are everything from image-00001 to image-99999.

-c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p

-c:v libx264 - the video codec is libx264 (H.264).

-profile:v high - use H.264 High Profile (advanced features, better quality).

-crf 20 - constant quality mode, very high quality (lower numbers are higher quality, 18 is the smallest you would want to use).

-pix_fmt yuv420p - use YUV pixel format and 4:2:0 Chroma subsampling

output.mp4

The file name (output.mp4)

Remember that ffmpeg needs a continuous sequence of images to load in. If it jumps from image-00001 to image-00003 it will stop.

If your images are named like this:

image-1
image-2
...
image-35

then change the -i part to -i image-%00d.


Update. Your edit says the pattern is image-01.jpg to image-02.jpg. That means you need the image-%02d.jpg pattern.

| improve this answer | |
  • 1
    -c:v libx264 — the video codec is libx264 (H.264). -profile:v high — use H.264 High Profile (advanced features, better quality). -crf 20 — constant quality mode, very high quality (lower numbers are higher quality, 18 is the smallest you would want to use). -pix_fmt yuv420p — use YUV pixel format and 4:2:0 Chroma subsampling – hobbs Apr 18 '15 at 23:10
  • 1
    Typo in your update: should be image-%02d.jpg, not image-%20d.jpg. – hobbs Apr 18 '15 at 23:11
  • 1
    @LuísdeSousa Ubuntu uses an ffmpeg fork: avconv. So the command starts with avconv -framerate ... – Governa Feb 27 '18 at 21:04
  • How do you change the resolution with this? I tried the -s option but it just got ignored... – Ferdinando Randisi Jan 22 '19 at 16:26
  • how about without a pattern? – moeiscool Mar 25 '19 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.