Mp4 export to vlc
Contents
Mp4 export to vlc
These scripts are what I use to convert mythtv recordings to smaller versions able to be stored on inexpensive 1GB thumb drives and played with VLC
The video and audio bit rates, as well as the resolution, were painstakingly tweaked to find an acceptable rate for the specific player and thumb drive I use. These files may prove to be a good starting point for someone else.
Note: I placed all these files in my home directory in a bin directory (/home/Bob/bin/) you'll probably want to use a different, yet similar, location.
Set up a User Job
/home/Bob/bin/myth_small_mp4_no_commercials %CHANID% %STARTTIME% "%TITLE%" "%SUBTITLE%"
/home/Bob/bin/myth_small_mp4 %CHANID% %STARTTIME% "%TITLE%" "%SUBTITLE%"
The Code
NOTE: This code was tested on an HP Pavilion Elite M9040N Medica Center PC running Fedora 14 kernel 2.6.35.11-83.fc14.x86_64 and ffmpeg ffmpeg-0.6-4.20100704svn.fc14.x86_64 with MythTV mythtv-0.24-6.fc14.x86_64. It may need tweaked on other distros. The playback was tested on an old Dell Dimension B120 with only 512 mb ram.
mk_thumb_mp4
This script is used by both of the previous example scripts. This is where the conversion actually happens. A crf rather than a bitrate is specified. Also the newer libx264 library is used for video.
#!/bin/sh # programs NICE="/bin/nice -n19" FFMPEG="/usr/bin/ffmpeg" # can switch to following when mythtv ffmpeg supports lx264 and video presets FFMPEG="/usr/bin/mythffmpeg" # set up the options (hard coded 4:3 right now) displayresolution="vga" vbitrate="22" abitrate="96k" FM_ARGS=" -i $1 -acodec mp2 -ab $abitrate -ac 2 -vcodec libx264 -s $displayresolution -vpre slow -crf $vbitrate -threads 0 -y $2" # run the commands $NICE $FFMPEG $FM_ARGS echo $OUTFILE
myth_small_mp4_no_commercials
myth_small_mp4_no_commercials.sh
#!/bin/sh # expecting: CHANID="$1" STARTTIME="$2" TITLE="$3" SUBTITLE="$4" OUTDIR="/video/videos" # programs NICE="/bin/nice -n19" MYTHTRANSCODE="/usr/bin/mythtranscode" MYTHCOMMFLAG="/usr/bin/mythcommflag" CONVERT="/home/Bob/bin/mk_thumb_mp4.sh" SED="/bin/sed" # convert space laden variables to have underscores instead (not used in lookup) sed_str="s/[$\!@\/:;~#%^&*\`\(\)\"\'<>,.?]//g" OTITLE=`echo $TITLE | $SED -e 's/[[ \t]]*/_/g' | $SED -e $sed_str` OSUBTITLE=`echo $SUBTITLE | $SED -e 's/[[ \t]]*/_/g' | $SED -e $sed_str` # files TMPFILE="/tmp/$1_$2.tmp" OUTFILE="$OUTDIR/$OTITLE-$OSUBTITLE-$STARTTIME.mp4" # options MC_ARGS="-c $CHANID -s $STARTTIME --gencutlist" MT_ARGS="--showprogress -p autodetect -c $CHANID -s $STARTTIME --honorcutlist --mpeg2 -o $TMPFILE" # bring it all together: echo flag commercials $NICE $MYTHCOMMFLAG $MC_ARGS echo export commercial-free video stream $NICE $MYTHTRANSCODE $MT_ARGS echo reduce commercial-free video stream $CONVERT $TMPFILE $OUTFILE echo remove temporary files rm -f $TMPFILE rm -f $TMPFILE.map
myth_small_mp4
#!/bin/sh # expecting: CHANID="$1" STARTTIME="$2" TITLE="$3" SUBTITLE="$4" OUTDIR="/video/videos" # programs NICE="/bin/nice -n19" MYTHTRANSCODE="/usr/bin/mythtranscode" MYTHCOMMFLAG="/usr/bin/mythcommflag" CONVERT="/home/Bob/bin/mk_thumb_mp4.sh" SED="/bin/sed" # convert space laden variables to have underscores instead (not used in lookup) sed_str="s/[$\!@\/:;~#%^&*\`\(\)\"\'<>,.?]//g" OTITLE=`echo $TITLE | $SED -e 's/[[ \t]]*/_/g' | $SED -e $sed_str` OSUBTITLE=`echo $SUBTITLE | $SED -e 's/[[ \t]]*/_/g' | $SED -e $sed_str` # files TMPFILE="/tmp/$1_$2.tmp" OUTFILE="$OUTDIR/$OTITLE-$OSUBTITLE-$STARTTIME.mp4" # options MC_ARGS="-c $CHANID -s $STARTTIME --gencutlist" MT_ARGS="--showprogress -p autodetect -c $CHANID -s $STARTTIME --mpeg2 -o $TMPFILE" # bring it all together: echo flag commercials $NICE $MYTHCOMMFLAG $MC_ARGS echo export commercial-laden video stream $NICE $MYTHTRANSCODE $MT_ARGS echo reduce commercial-laden video stream $CONVERT $TMPFILE $OUTFILE echo remove temporary files rm -f $TMPFILE rm -f $TMPFILE.map