Skip to content

Instantly share code, notes, and snippets.

@jesstess
Created August 12, 2011 19:13
Show Gist options
  • Save jesstess/1142746 to your computer and use it in GitHub Desktop.
Save jesstess/1142746 to your computer and use it in GitHub Desktop.
Turning NASA images into movies: png2yuv | mpeg2enc
Keith gave me the hook-up on turning NASA images into a high-quality movie. I had tried twiddling knobs starting from a basic ffmpeg incant:
ffmpeg -r 10 -i frame%03d.jpg frames.mov
but the movies looked terrible.
Keith said:
"""
Generally if you're making a movie out of separate frames, I prefer to use png2yuv and mpeg2enc from the mjpegtools package instead of ffmpeg -- it's pretty clean code designed for this task instead of an assemblage of random libraries.
Here is the command line I used to make an MPEG-2 out of a bunch of gnuplot PNG files last year. The "-b 10000" gives a 10 Mbps bitrate, which you can play with if you use a higher resolution or something.
png2yuv -j frame%03d.png -f 25 -I p -b 16 | mpeg2enc -o frames.m2v -a 1 -f 3 -b 10000 --no-constraints
Hope this helps.
"""
The resulting movies look great.
Notes:
1. ffmpeg and png2yuv expect images with sequential numbers. A quick way to achieve this:
x=1; for i in *jpg; do counter=$(printf %03d $x); mv "$i" frame"$counter".jpg; x=$(($x+1)); done
2. image sources:
http://pds-imaging.jpl.nasa.gov/search/
http://saturn.jpl.nasa.gov/photos/raw/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment