Show
Ignore:
Timestamp:
10/16/06 21:55:16 (2 years ago)
Author:
conrad
Message:

add a bunch of cleanup code, and encode via a fifo.
This removes intermediate .png files on exit, and avoids creating an
intermediate yuv4 file at all.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • blender-scripts/spinning-text/generate-logo.sh

    r182 r183  
    11#!/bin/sh 
    22 
    3 blender -P scene-model.py 
    4 mplayer mf:///tmp/renderfarm/*.png -mf type=png:fps=25 -vf scale -vo yuv4mpeg -ao null -nosound 
    5 ffmpeg2theora stream.yuv 
     3THIS="$0" 
     4 
     5VERBOSE="" 
     6DRYRUN="" 
     7 
     8BASE="logo" 
     9OUTDIR="$PWD" 
     10#WORKDIR="${TMPDIR-/tmp}/$BASE.$$" 
     11WORKDIR="/tmp/renderfarm" 
     12ENCODEFIFO="$WORKDIR/stream.yuv" 
     13 
     14############################################################ 
     15## General functions 
     16############################################################ 
     17 
     18verbose_echo () { 
     19  if test "x$VERBOSE" != "x"; then 
     20    echo $* 
     21  fi 
     22
     23 
     24
     25# try_run desc cmd 
     26
     27try_run () { 
     28  desc=$1 
     29  shift 
     30 
     31  verbose_echo ========================================================================== 
     32  verbose_echo $desc ... 
     33 
     34  if test "x$DRYRUN" != "x" || test "x$VERBOSE" != "x"; then 
     35    echo $* 
     36  fi 
     37  if test "x$DRYRUN" = "x" ; then 
     38    eval $* 
     39    if test "$?" != "0"; then 
     40      echo "$THIS: Failed command:" 
     41      echo $* 
     42      exit 1 
     43    fi 
     44  fi 
     45
     46 
     47############################################################ 
     48## Initialize for cleanup 
     49############################################################ 
     50 
     51# exit status 
     52stat=1 
     53 
     54cleanup () { 
     55  try_run "Removing video encode fifo" rm -f $ENCODEFIFO 
     56  try_run "Removing temporary working directory" rm -rf $WORKDIR 
     57  exit $stat 
     58
     59 
     60trap cleanup 0 
     61trap 'echo $THIS: Interrupted, cleaning up ...' INT QUIT KILL 
     62 
     63############################################################ 
     64## Prepare 
     65############################################################ 
     66 
     67try_run "Creating temporary working directory" mkdir $WORKDIR 
     68try_run "Making video encode fifo" mkfifo $ENCODEFIFO 
     69 
     70############################################################ 
     71## Render 
     72############################################################ 
     73 
     74try_run "Rendering animation" \ 
     75  "blender -P scene-model.py" 
     76 
     77#try_run "Encoding to yuv4mpeg" \ 
     78#  "(cd $WORKDIR && mplayer mf://$WORKDIR/*.png -mf type=png:fps=25 -vf scale -vo yuv4mpeg -ao null -nosound)" & 
     79 
     80cd $WORKDIR 
     81mplayer mf://$WORKDIR/*.png -mf type=png:fps=25 -vf scale -vo yuv4mpeg -ao null -nosound & 
     82 
     83cd - 
     84try_run "Encoding to Ogg Theora" \ 
     85  "ffmpeg2theora -o logo.ogg $ENCODEFIFO" 
     86 
     87# Set exit status to 0 
     88stat=0