Split/Crop, Join and Create Video from a Sequence of Images. Also: Create 3d Videos.
This HowTo gives a short account on how to split a sequence of images, crop them, join them together into a new sequence and create a video by using onlyconvert
and ffmpeg
/mencoder
.
There are various scenarios when these tool can be applied.
The main motivation for this HowTo was for removing a black bar within a sequence of images
created by Paraview, as seen here:
Split/Crop the Image
These are two steps in one, but can easily be separated if needed.for file in *.png; do convert $file -crop 959x1124+1511 r-$file; done
*.png
to whatever
ending you have.
The convert
to cut the image into one
of size 959x1124 starting at pixel 1511 to the right.
As output files we simply reuse the original file name $file
with a trailing "r".
Extracting the left part of the image is done the same way:
for file in *.png; do convert $file -crop 953x1124-0 l-$file; done
Join Two Sequences of Images (Create Stereographic Images)
At this point we have two sequences of images starting with "l" and with "r". This scenario could also occur with a sequence of left eye and right eye images for a stereographic video, e.g. from Paraview. For joining them we use the same command:for file in l*.png; do convert $file "${file/l/r}" +append ${file/l/j}; done
${file/l/r}
).
The output file name is the same as the files l*.png
but with a "j" instead of "l"
(${file/l/j}
).
The output image should then look like this:
Create the Video from the Sequence of Images
Suppose we have a sequence if images with increasing number in their name likej-animation.0000.png
, j-animation.0001.png
, ... .
With ffmpeg
one can create a video file from such a sequence of images:
ffmpeg -framerate 30 -i j-animation.%04d.png -pix_fmt yuv420p animation.mp4
mencoder
:
mencoder mf://j-animation*.png -mf type=png:fps=30 -ovc xvid -xvidencopts bitrate=15000 -o animation.avi
References
http://www.imagemagick.org/script/command-line-options.php#crop https://trac.ffmpeg.org/wiki/Create%20a%20video%20slideshow%20from%20images http://www.mplayerhq.hu/DOCS/HTML/en/mencoder.html