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
[email protected] ~/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?
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.
If you don't want to waste your time with the file naming and order I would recommend to take a look into:
It will also provide several examples.
Answered by thl on November 21, 2021
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:
is the number of frames (images) per second,
this determines the file name sequence it looks for.
image- means all of the files start with this. The
d indicates decimal integers,
5 is number of digits, the leading zero indicates that numbers requiring fewer digits will be filled, in the left, with zeroes so that every number contains exactly 5 digits. Thus the files it will detect are everything from
-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
The file name (
ffmpeg needs a continuous sequence of images to load in. If it jumps from
image-00003 it will stop.
If your images are named like this:
image-1 image-2 ... image-35
then change the
-i part to
Update. Your edit says the pattern is
image-02.jpg. That means you need the
Answered by Tim on November 21, 2021
0 Asked on January 13, 2021 by tushar-joshi
1 Asked on January 13, 2021 by kanehekili
0 Asked on January 12, 2021 by robomaze
0 Asked on January 11, 2021 by clipp-wong
14 Asked on January 11, 2021 by mark-b
1 Asked on January 11, 2021 by estatistics
2 Asked on January 10, 2021 by 4dummies
2 Asked on January 10, 2021 by user133125
1 Asked on January 10, 2021 by paul-cheung
1 Asked on January 10, 2021 by alon-goldenberg
0 Asked on January 9, 2021 by adi
2 Asked on January 9, 2021 by rqomey
2 Asked on January 9, 2021 by pssturges
1 Asked on January 9, 2021 by user895130
Get help from others!