Note: You are viewing an old version of this page. View the current version.

#!/bin/bash

# Encode

old="${PWD}"
dst="${old}/out"
cleanup() {
  cd "${old}"
#  rm -Rf "${tmp}"
}
trap cleanup exit hup int term kill

for file in src/*
do
  out="$(basename "${file%.*}")"
  tmp="$(mktemp -d enc.XXXXXXXX)"
  cd "${tmp}"
  if [ "${old}" == "${PWD}" ]
  then
    echo "mktemp failed!"
    exit 1
  fi

  echo ">${tmp}> ${file} -> ${out}.dpg"

  fps=15
  v_kbps=1536
  hz=32000
  a_kbps=128
  echo "Transcoding audio..."
  "${old}/makemp2.php" "${old}/${file}" "${a_kbps}" "${hz}" output
  echo "Transcoding video..."
  "${old}/makem1v.php" "${old}/${file}" "${v_kbps}" "${fps}" output
  echo "Generating TOC..."
  eval $("${old}/makegop.php" output)
  echo "Generating header..."
  "${old}/makehdr.php" "${frames}" "${fps}" "${hz}" output
  echo "Assembling DPG..."
  if [ -f output.hdr -a -f output.mp2 -a -f output.m1v -a -f output.gop ]
  then
    cat output.{hdr,mp2,m1v,gop} > output.dpg
  fi
  echo "All done!"
  ln -vf output.dpg "${dst}/${out}.dpg"
  cd "${old}"
done