;; ppmmpeg.ini - Create an MPEG file.
;;
;; URL: http://student.uq.edu.au/~s002434/mpeg.html
;;
;; Author:
;;   Version 1.1
;;     Fixed for >9 frame animations
;;     Warwick Allison (warwick@cs.uq.edu.au)
;;     23 March 1996
;;   Version 1.0
;;     Initial version - as posted to comp.graphics.raytracing.rendering
;;     Warwick Allison (warwick@cs.uq.edu.au)
;;     21 March 1996
;;
;; Sample usage (myfile.ini):
;;   ;; My animation
;;   ppmmpeg.ini
;;   Width=160
;;   Height=160
;;   Input_File_Name=myfile.pov  ;; myfile.pov assumes "clock" from 0.0 to 1.0
;;   Final_frame=20
;;   Cyclic_Animation=true
;;
;; Environment:
;;   POV_MPEGOPTS   - Additional arguments to pass to mpeg encoder
;;                         eg. To ask encoder to produce a 1000 bps file:
;;                               POV_MPEGOPTS="-r 1000" povray myfile.ini
;;                         eg. To ask encoder to produce a 8192 bit (1K) file:
;;                               POV_MPEGOPTS="-x 8192" povray myfile.ini
;;                    Read the manual for mpeg for more information.
;;
;; Disk usage:
;;   Each frame traced generates a .Y, .U, and .V file in a subdirectory
;;   called <scenename>-frames.  The total size of these files is 1.5 bytes
;;   for each pixel in the frame (because there is one byte of luminance
;;   per pixel and 1 byte of U and V per 4-pixels).
;;
;;   For example, a 320x240 frame will create three files totalling 115200
;;   bytes, and a 100 frame animation would thus use about 11.5Mbytes prior
;;   to MPEG compression.
;;
;;   If you are rendering extremely large animations, or are very short on
;;   disk space, you could modify the (free) Stanford encoder such that it
;;   could support reading compressed (gzipped) files, then you could add
;;   a compression command (gzip %s%n.[YUV]) to the Post_Frame_Command.
;;
;; Required Unix commands:
;;   rm, expr, etc. - Standard Unix
;;   ppmtoyuvsplit  - Standard NetPPM
;;   mpeg           - Stanford MPEG encoder/decoder
;;                      havefun.stanford.edu:pub/mpeg/MPEGv1.2.tar.Z
;;

;; PPM output
Output_to_File=On
Output_File_Type=p

;; Ensure frames directory is created
Pre_Frame_Command=mkdir -p %s-frames
Pre_Frame_Return=

;; After frame, split PPM file into Y,U,V files, then delete PPM
;; Remove leading 0s from frame number.
Post_Frame_Command=ppmtoyuvsplit %s-frames/`expr %n + 0` %o && rm %o
;; If error, crash
Post_Frame_Return=f

;; Nothing special prior to scene
Pre_Scene_Command=
Pre_Scene_Return=

;; After scene, generate mpeg file.  Note that current frame is 1 more than
;; final frame number, so we subtract 1 using expr.  $POV_MPEGOPTS can be
;; set to give additional options to the mpeg encoder.
;;
Post_Scene_Command=mpeg -PF -h %w -v %h -a 1 -b $(expr %n - 1) %s-frames/ -s %s.mpeg $POV_MPEGOPTS
;;If error, crash
Post_Scene_Return=f

;; Don't pause if displaying!
Pause_When_Done=Off

Continue_Trace=On                ;;Lets you resume

