[mythtv-users] tips on auto-transcoding a recording?

Karl Newman newmank1 at asme.org
Tue May 24 23:38:05 UTC 2016


On Tue, May 24, 2016 at 3:48 PM, James Miller <gajs-f0el at dea.spamcon.org>
wrote:

> Preparing for a trip overseas and would like to have the ability to view a
> particular recording that my Myth machine is set to auto-record. Mythweb is
> correctly configured for this, so that part of the equation is in place.
> But how to set up the more crucial part--auto-transcoding the recording so
> that it is substantially smaller and thus quicker to download--is escaping
> me. The recording winds up as an mpg file, one recorded from an unencrypted
> NTSC cable connection. I don't care whether commercials get cut out, btw.
>
> I was able to set up just this sort of auto-transcoding on my old Myth
> system by just ferreting around through the menu system. This time, either
> my memory and technical acumen have become seriously degraded, thus
> preventing me from accomplishing what I previously had done, or some
> changes to how auto-transcoding is done have been introduced--changes that
> are proving much more difficult for me to grasp.
>
> As to what I'm trying to do more specifically, I would like for that mpg
> file that gets recorded each weekday to, once recording has been completed,
> be transcoded into a file roughly one-tenth the size of the original.
> Replacing the original with the lower-quality transcoded version is what
> I'm after. I realize, based on past experience, that the video quality will
> be pretty terrible at the specified file size--I will be viewing it on a
> netbook, btw. But I can live with the quality degradation for the short
> period during which I will be needing to do this. Format of the re-encoded
> file is not terribly important as I will be using mplayer on the netbook
> end to view it, and mplayer seems to handle just about any format I've ever
> tried with it.
>
> As I said, I've ferreted through the Myth menus and have not thus far
> discovered a way to accomplish what I'm aiming for. I also took a look at
> the wiki and tried and experiment or two, but without success so far.
> Finally, I am trying to set this up at the last minute, as departure is
> slated for tomorrow. So it may be asking too much--given my pretty modest
> technical acumen--to try and set this up on such notice.
>
> Any tips on how to accomplish my aims will be appreciated.
>
> PS This is MythTV 27 running under Gentoo.
>

I have a script that I use that I found somewhere. It just uses mythffmpeg
so no extra dependencies. I use it on SD source material so it starts out
pretty rough, but the result is viewable. You can set it up as a user job
and then select it to run for a given recording rule. Give this a shot:

#!/bin/bash

#Call with $0 "%DIR%/%FILE%" "%TITLE%" "%SUBTITLE%" "%STARTTIMEUTC%"
%CHANID% "%ORIGINALAIRDATE%"

file="$1"
title=$(echo "$2" | sed -e s/[^\]\[A-Za-z0-9~.,_\ {}\(\)\'\+\-]/_/g )
subtitle=$(echo "$3" | sed -e s/[^\]\[A-Za-z0-9~.,_\ {}\(\)\'\+\-]/_/g )
date=$6
nice_title="$title"
if [ -n "$date" ]
then
    nice_title="$nice_title-$date"
fi
if [ -n "$subtitle" ]
then
    nice_title="$nice_title-$subtitle"
fi

WORKING="/tmp/transcode_work"
mkdir -p $WORKING
cd $WORKING

#DEST="/var/lib/mythtv/recordings/phone"
DEST="/home/shared/export/"
mkdir -p $DEST

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

#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
#fi;

/usr/bin/mythffmpeg -y -i "$file" \
 -c:v libx264 -preset slower -profile:v baseline \
 -strict experimental -c:a libfaac -b:a 96k \
 -vf yadif,scale="trunc(oh*a/2)*2:480" -crf 23 -r 25 \
 "$nice_title.mp4"

#Alternate, from https://www.mythtv.org/wiki/Transcode_Mpeg2_to_H264.
#Key feature is automatic deinterlacing (yadif filter)
#        output = task('-i "%s"' % tmpfile,
#                      '-filter:v yadif=0:-1:1',
#                      '-c:v libx264',
#                      '-preset:v slow',
#                      '-crf:v 18',
#                      '-strict -2',
#                      '-metadata:s:a:0',
#                      'language="eng"',
#                      '"%s"' % outfile,
#                      '2> /dev/null')

mv -f "$nice_title.mp4" $DEST
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mythtv.org/pipermail/mythtv-users/attachments/20160524/42c16429/attachment.html>


More information about the mythtv-users mailing list