comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » making movies in idl
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: making movies in idl [message #10312 is a reply to message #10249] Fri, 07 November 1997 00:00 Go to previous messageGo to previous message
David Foster is currently offline  David Foster
Messages: 341
Registered: January 1996
Senior Member
Joseph Scott Stuart wrote:
>
> I have a set of IDL generated images that show how a two-dimensional
> system changes as a parameter is varied, and I want to make an
> animation that can go on a web page. How would I go about doing that
> in IDL? A mult-image gif file would probably work nicely, but IDL's
> write_gif routine only makes single image files.
>
> Thanks for you feedback!
>
> scott

Scott:

You can use a WRITE_MPEG routine that I got off this newsgroup
some time ago. You will also need the UNIX utility 'mpeg_encode'
(web site included below):

---------- Cut HERE ------------------------------------------------
; Subject: Re: MPEG creation with IDL
; From: scott@abyss.ATMOS.ColoState.Edu (Scott Denning)
;
; The following idl procedure will produce an mpeg file from a series of
; images stored in a 3D array (width x height x # of frames). It
requires
; the "mpeg_encode" executable to be in the unix search path. This can
be
; obtained from ftp://mm-ftp.cs.berkeley.edu/pub/ .
;
; Multimedia stuff previously at:
; ftp://s2k-ftp.cs.berkeley.edu/pub/multimedia/mpeg/encode.
;
; There are lots of options that can be handled differently, to make
; tradeoffs between image quality, speed, and disk space. See the
; documentation for mpeg_encode for more details.
;
; If your animation is stored in the array "image_array" and you want to
; write it to a file called "movie.mpg," you would do so by typing
;
; WRITE_MPEG, 'movie.mpg', image_array
;


PRO WRITE_MPEG, mpegFileName, image_array

movieSize = SIZE(image_array)
xSize = movieSize(1)
ySize = movieSize(2)
nFrames = movieSize(3)

nDigits = 1+FIX(ALOG10(nFrames))
formatString = STRCOMPRESS('(i'+STRING(nDigits)+'.'+STRING(nDigits)$
+ ')', /REMOVE_ALL)
; Load current color table into byte arrays
TVLCT, red, green, blue, /GET
red = BYTE(red)
green = BYTE(green)
blue = BYTE(blue)

ON_IOERROR, badWrite

; Make a temporary directory if necessary or clear it otherwise'
TMPDIR = '/tmp/idl2mpeg.frames'
SPAWN, 'if (-d ' + TMPDIR + ') echo "exists"', result
dirExists = result(0) EQ 'exists'
IF dirExists THEN command = 'rm ' + TMPDIR + '/*' $
ELSE command = 'mkdir ' + TMPDIR
SPAWN, command

; Write each frame into TMPDIR as an 8-bit .gif image file
FOR frameNum = 0, nFrames-1 DO BEGIN
fileName = TMPDIR + '/frame.' + STRING(frameNum,FORMAT=formatString)$
+ '.gif'
WRITE_GIF, fileName, image_array(*,*,frameNum), red, green, blue
ENDFOR
; Build the mpeg parameter file
paramFile = TMPDIR + '/idl2mpeg.params'
OPENW, unit, paramFile, /GET_LUN
PRINTF, unit, 'PATTERN IBBBBBBBBBBP'
PRINTF, unit, 'OUTPUT ' + mpegFileName
PRINTF, unit, 'GOP_SIZE 12'
PRINTF, unit, 'SLICES_PER_FRAME 5'
PRINTF, unit, 'BASE_FILE_FORMAT PPM'
PRINTF, unit, 'INPUT_CONVERT giftoppm *'
PRINTF, unit, 'INPUT_DIR /tmp/idl2mpeg.frames'
PRINTF, unit, 'INPUT'
PRINTF, unit, '`ls *.gif`'
PRINTF, unit, 'END_INPUT'
PRINTF, unit, 'PIXEL FULL'
PRINTF, unit, 'RANGE 5'
PRINTF, unit, 'PSEARCH_ALG LOGARITHMIC'
PRINTF, unit, 'BSEARCH_ALG SIMPLE'
PRINTF, unit, 'IQSCALE 8'
PRINTF, unit, 'PQSCALE 8'
PRINTF, unit, 'BQSCALE 8'
PRINTF, unit, 'REFERENCE_FRAME DECODED'
PRINTF, unit, 'FORCE_ENCODE_LAST_FRAME'
FREE_LUN, unit

; spawn a shell to process the mpeg_encode command
SPAWN, 'mpeg_encode ' + paramFile

RETURN

badWrite:
alert, 'Unable to write MPEG file!'

END
------------- Cut HERE -----------------------------------------------

Dave
--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2240
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: moving average of a large array
Next Topic: Natural Neighbor Interpolation

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 15:29:53 PDT 2025

Total time taken to generate the page: 2.47909 seconds