Skip to content

Instantly share code, notes, and snippets.

@jesstess
Created August 12, 2011 19:13
Show Gist options
  • Select an option

  • Save jesstess/1142746 to your computer and use it in GitHub Desktop.

Select an option

Save jesstess/1142746 to your computer and use it in GitHub Desktop.

Revisions

  1. jesstess created this gist Aug 12, 2011.
    30 changes: 30 additions & 0 deletions NASA_images_png2yuv
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    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/