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

Home » Public Forums » archive » XINTERANIMATE -> MPEG?
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: XINTERANIMATE -> MPEG? [message #6928 is a reply to message #6801] Fri, 30 August 1996 00:00 Go to previous messageGo to previous message
A. Scott Denning is currently offline  A. Scott Denning
Messages: 5
Registered: July 1996
Junior Member
Pierre Maxted wrote:
>
> Hello fellow IDLers,
> We have a nice animation running using XINTERANIMATE (IDl V4.0 on a SPARC)
> of a binary star and we want to show it to the public at a forthcoming open
> day. We only have a PC available at the open day so:
> Does anyone have a routine for writing MPEG files from IDL?
>
Enclosed below is a procedure "write_mpeg.pro" which does what you need.
Load your sequential images into a single array (imageWidth x
imageHeight x nFrames), then call this procedure as follows:

write_mpeg, 'myMovie.mpg', imageArray

NOTE: This procedure uses SPAWN to call an executable called
"mpeg_encode", which actually creates the mpeg file. This is freely
available at

file://s2k-ftp.cs.berkeley.edu/pub/multimedia/mpeg/

For more information about recording or playing mpeg files, please see

http://www.arc.umn.edu/GVL/Software/mpeg.html

--
A. Scott Denning scott@abyss.Atmos.ColoState.edu
Dept. of Atmospheric Science Phone (970)491-2134
Colorado State University Fax1 (970)491-8428
Fort Collins, CO 80523-1371 Fax2 (970)491-8449

============================== C U T H E R E ======================

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)
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 a 24-bit .ppm image file
FOR frameNum = 0, nFrames-1 DO BEGIN
fileName = TMPDIR + '/frame.' + STRING(frameNum,FORMAT=formatString)$
+ '.ppm'
image = pseudo_to_true(image_array(*,*,frameNum))
WRITE_PPM, fileName, image
PRINT, 'Wrote temporary PPM file for frame ', frameNum+1
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 *'
PRINTF, unit, 'INPUT_DIR /tmp/idl2mpeg.frames'
PRINTF, unit, 'INPUT'
PRINTF, unit, '`ls *.ppm`'
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 6'
PRINTF, unit, 'PQSCALE 6'
PRINTF, unit, 'BQSCALE 6'
PRINTF, unit, 'REFERENCE_FRAME ORIGINAL'
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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Mouse and window problem
Next Topic: (x)emacs support for IDL

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

Current Time: Fri Oct 10 17:17:00 PDT 2025

Total time taken to generate the page: 0.63945 seconds