I have a directory with .jpg
images named in UNIX timestamp format. How can I convert all images starting with the oldest timestamp to the newest in .mp4
video format?
I found a solution but it uses incremental naming, like image001
, image002
.
I would appreciate any help. Thanks.
Using aergistal's solution, i get an error in output: I did as you told me, but i get an output error:
Input #0, concat, from 'list.txt':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 540x405 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
[swscaler @ 0x14751c0] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x14b7120] height not divisible by 2 (540x405)
Output #0, mp4, to 'out.mp4':
Stream #0:0: Video: h264, none, q=2-31, 128 kb/s, SAR 1:1 DAR 0:0, 30 fps
Metadata:
encoder : Lavc56.26.100 libx264
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Make a list of files in the order in which you want them to appear using the format:
file '<path/to/file>'
On Linux you can fetch the files using the timestamp order and create the list using:
ls /path/to/*.jpg | sort -V | xargs -I {} echo "file '{}'" > list.txt
From the sort
man page:
-V, --version-sort natural sort of (version) numbers within text
Example list:
file '1.jpg'
file '2.jpg'
file '3.jpg'
Then use the FFmpeg concat demuxer with your list:
ffmpeg -r 1/5 -f concat -i list.txt -c:v libx264 -r 25 -pix_fmt yuv420p -t 15 out.mp4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With