Useful Syntax
Monday, January 4th, 2010Although I will only be using still frames from Splotch in my immediate research, it will be useful to have the ability to make movies. Splotch can interpolate between GADGET snapshots and output still frames. The syntax for using FFmpeg to create a movie from still frames is
ffmpeg -i image-base-name-%0Nd.xxx -b (bit rate)k -r (frame rate) output-file.xxx
Example:
ffmpeg -i IMG-%04d.JPG -b 512k -r 30 out.avi
which takes files named IMG-0001.JPG, IMG-0002.JPG, etc. and makes an output file named out.avi with 30 frames per second and a bit rate of 512kbps. The 04d specifies that there are four digits in the file name.
Although the viewing angle and camera position can be controlled using the Splotch parameter file, it may be useful to automatically crop images when making a movie for demonstration / outreach purposes. The syntax for cropping a directory full of jpeg images using ImageMagick is
convert -crop ‘*.jpg[widthxheight+xoffset+yoffset]‘ output_%04d.jpg
The x and y offsets are the coordinates of the upper left corner of the crop box with the specified width and height. Here’s an example:
convert -crop '*.jpg[1280x720+122+60]' img_%04d.jpg
Which creates images named img_0001.jpg, img_0002.jpg, img_0003.jpg, etc. Of course any image format can be cropped and ImageMagick can convert between many different image formats.
