home / blog

Mythtv transcode for Android

  • After a number of issues with avconv I switched to ffmpeg. Out of memory (OOM) errors. Non-monotonic timestamp issues, and audio/video sync problems
  • Sometimes mythtranscode can fail. If it does, the recommended way to fix it is to stream copy the .mpg using ffmpeg, replace the original file and try again.
  • Android only supports H264 baseline profiles.
  • 480p works quite nicely on a Samsung S3 screen
  • Built-in mythtv editor for cut-points easy and quick to use – in conjunction with “honorcutlist” option.

Custom job command to invoke

/home/mythtv/bin/transcode.sh "%DIR%/%FILE%" "%TITLE%" "%SUBTITLE%" "%STARTTIMEUTC%" %CHANID%



title=$(echo $2 |  tr -c "[^A-Za-z0-9]" "." )
subtitle=$(echo $3 |  tr -c "[^A-Za-z0-9]" "." )
date=$(echo $4 | perl -pe 's/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/\1.\2.\3-\4.\5/')

DEST="$(dirname $file)/phone"
mkdir -p $DEST

WORKING="$(dirname $file)/working"
mkdir -p $WORKING

if [ -f "$DEST/$nice_title.mp4" ]; then
  echo "$DEST/$nice_title.mp4 already exists. Exiting"

mythtranscode --mpeg2 --chanid $5 --starttime $4 --honorcutlist
if [ ! "$?" == "0" ]; then
 echo "Transcode failed. Attempting to fix with stream copy"
 $HOME/bin/ffmpeg -i $1 -acodec copy -vcodec copy $1.fixed.mpg
 mv $1 $1.backup
 mv $1.fixed.mpg $1
 mythtranscode --mpeg2 --chanid $5 --starttime $4 --honorcutlist
$HOME/bin/ffmpeg -y -i $1.tmp \
 -c:v libx264 -preset slower -profile:v baseline \
 -strict experimental -c:a libfdk_aac -b:a 96k \
 -vf yadif,scale="trunc(oh*a/2)*2:480" -crf 23 -r 25 \

mv -f "$nice_title.mp4" $DEST
This entry was posted in geek. Bookmark the permalink.

Leave a Reply

Your email address will not be published.