I want to convert a sequence of ppm images to avi video (or another possible video format accepted by OpenCV).
First I converted the ppm images with no drop in quality to jpg:
for f in *ppm ; do convert -quality 100 $f `basename $f ppm`jpg; done
Then I used the following command to convert to avi:
ffmpeg -i CS585Bats-FalseColor_frame*.jpg -vcodec mpeg4 test.avi
But I got the following error:
FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers
built on Aug 2 2016 19:05:32 with clang 7.3.0 (clang-703.0.31)
configuration: --enable-libmp3lame --enable-libfaac --enable-gpl --enable-nonfree --enable-shared --disable-mmx --arch=x86_64 --cpu=core2
libavutil 50.36. 0 / 50.36. 0
libavcore 0.16. 1 / 0.16. 1
libavcodec 52.108. 0 / 52.108. 0
libavformat 52.93. 0 / 52.93. 0
libavdevice 52. 2. 3 / 52. 2. 3
libavfilter 1.74. 0 / 1.74. 0
libswscale 0.12. 0 / 0.12. 0
Input #0, image2, from 'CS585Bats-FalseColor_frame000000750.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
Stream #0.0: Video: mjpeg, yuvj444p, 1024x1024 [PAR 1:1 DAR 1:1], 25 tbr, 25 tbn, 25 tbc
ffmpeg(11831,0x7fffa5dc6340) malloc: *** error for object 0x100000001: pointer being realloc'd was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
Then I thought to use this other method but still get error:
$ convert -delay 6 -quality 100 CS585Bats-FalseColor_frame000000*ppm movie.mpg
convert: delegate failed `'ffmpeg' -nostdin -v -1 -i '%M%%d.jpg' '%u.%m' 2> '%u'' @ error/delegate.c/InvokeDelegate/1919.
ppm file names look like below:
$ ls *ppm | head -5
CS585Bats-FalseColor_frame000000750.ppm
CS585Bats-FalseColor_frame000000751.ppm
CS585Bats-FalseColor_frame000000752.ppm
CS585Bats-FalseColor_frame000000753.ppm
CS585Bats-FalseColor_frame000000754.ppm
You have several options available with the image file demuxer.
Using the sequence pattern
You can change the start number with the
-start_number
input option.Using the glob pattern
If these are the only PPM files in the directory your glob pattern can be simpler:
Not sure what bash script will do the task but this Python script works like a charm: