<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>I cannot get this script to work. There must be a line feed
somewhere in my copy that shouldn&#8217;t be.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Chris, can you email it to me as an attachment?<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Marc<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>
mythtv-users-bounces@mythtv.org [mailto:mythtv-users-bounces@mythtv.org] <b>On
Behalf Of </b>Chris Isip<br>
<b>Sent:</b> Monday, February 18, 2008 9:30 PM<br>
<b>To:</b> Discussion about mythtv<br>
<b>Subject:</b> [mythtv-users] Encoding to h264 to save space<o:p></o:p></span></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='margin-bottom:12.0pt'>I am able to shrink 1 hour of
video to approximately 150 MB at 200 kbit with ffmpeg using h264.&nbsp; Seems
to work well except with seeking.&nbsp; I wonder if this is a keyframe
issue.&nbsp; When I forward or rewind, there is distortion for a few seconds
and then the video fixes itself.&nbsp; If I forward or rewind before the video
is fixed, the progress bar seems to jump back.&nbsp; Seeking is more reliable
when the distrotion is allowed to clear first.&nbsp; Also, I cannot jump to the
very first frame of the recording.&nbsp; If I exit the recording and play it
again, I start on the first frame.&nbsp; Here is a copy of my latest
script.&nbsp; Single pass for now (hoping to go to 2 pass).&nbsp; I was
wondering if anyone could give me any ideas as to how to fix this issue. <br>
<br>
Thanks<br>
Chris<br>
<br>
<br>
#!/bin/bash<br>
VIDEO_DIR=/mnt/VIDEO<br>
<br>
#subq to 7 trellis to 2 threads 2<br>
#need to clear the cutlist and generate it again<br>
<br>
<br>
<br>
<br>
function convert-to-h264 ()<br>
{<br>
#argument is file only (no path)<br>
#need to dereference a symlink<br>
inputfile=`ls -ld $VIDEO_DIR/$1 | awk -F&quot; &quot; '{ print&nbsp; $NF }'`<br>
<br>
echo &quot;Will encode $inputfile&quot;<br>
basedname=`echo $inputfile | sed 's,^\(.*/\)\?\([^/]*\),\2,'`<br>
vidformat=`mplayer -vo null -ao null -frames 0 -identify &quot;$inputfile&quot;
2&gt;/dev/null | grep &quot;ID_VIDEO_FORMAT&quot; | sed -e
's/ID_VIDEO_FORMAT=//'`<br>
<br>
<br>
<br>
if !&nbsp; [ &quot;$vidformat&quot; == &quot;H264&quot; ]; then<br>
/usr/bin/ffmpeg -threads 2 -i&nbsp; $inputfile&nbsp; -acodec mp3 -ac 2 -ar
44100 -ab 128k -s 320x240 -vcodec h264 -sameq&nbsp; -flags +loop -cmp +chroma
-partitions +parti4x4+partp8x8+partb8x8 -me umh -subq 7 -trellis 2 -refs 1
-coder 0 -me_range 16 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71
-bt 300k -maxrate 300k -bufsize 300k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6
-qmin 15 -qmax 51 -qdiff 4 -level 30 -aspect 320:240&nbsp; $inputfile.avi<br>
<br>
<br>
mv $inputfile $inputfile.old<br>
mv $inputfile.avi $inputfile<br>
<br>
<br>
echo &quot;Building seek table&quot;<br>
mythcommflag --rebuild -f &quot;$inputfile&quot;<br>
<br>
echo &quot;Clearing the cut list&quot;<br>
mythcommflag --clearcutlist -f $inputfile<br>
<br>
echo &quot;Commercial skip to cutlist&quot;<br>
mythcommflag --gencutlist -f $inputfile<br>
<br>
filesize=$(wc -c $inputfile | awk '{print $1}')<br>
echo &quot;Updating database&quot;<br>
mysql -umythtv -pmythtv -hmymythtv mythconverg -se&quot;UPDATE recorded SET
cutlist=0,filesize=$filesize WHERE basename=\&quot;$basedname\&quot;;&quot;<br>
else<br>
echo &quot;Already an H264&quot;<br>
<br>
fi<br>
}<br>
<br>
<br>
CONVLIST=`mysql -umythtv -pmythtv -hmymythtv mythconverg -se&quot;select
basename from recorded where title like \&quot;%$1%\&quot;;&quot;`<br>
<br>
for i in ${CONVLIST[@]} ; do<br>
&nbsp; if ! test -L $VIDEO_DIR/$i ; then #its not a symnlink<br>
&nbsp;&nbsp;&nbsp;&nbsp; #Check if this recording is done -mmin +5<br>
&nbsp;&nbsp;&nbsp;&nbsp; filetoconvert=`find $VIDEO_DIR -name $i -mmin +5 | sed
's,^\(.*/\)\?\([^/]*\),\2,'`<br>
&nbsp;&nbsp;&nbsp;&nbsp; if [ -z &quot;$filetoconvert&quot; ]; then<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &quot;$i is not finnished
recording...Skipping&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp; else<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &quot;Moving $i to
/mnt/VIDEO1&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mv $VIDEO_DIR/$i /mnt/VIDEO1<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ln -sf /mnt/VIDEO1/$i $VIDEO_DIR/$i<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; convert-to-h264 $i<br>
&nbsp;&nbsp;&nbsp;&nbsp; fi<br>
&nbsp; else<br>
&nbsp;&nbsp;&nbsp;&nbsp; echo &quot;$i is already a symlink...Skipping&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp; convert-to-h264 $i<br>
&nbsp; fi<br>
<br>
<br>
<br>
<br>
done<br>
&nbsp; [root@mygamepc cmisip]# cat /usr/local/bin/RECconv2.sh<br>
#!/bin/bash<br>
VIDEO_DIR=/mnt/VIDEO<br>
<br>
#subq to 7 trellis to 2 threads 2<br>
#need to clear the cutlist and generate it again<br>
<br>
<br>
<br>
<br>
function convert-to-h264 ()<br>
{<br>
#argument is file only (no path)<br>
#need to dereference a symlink<br>
inputfile=`ls -ld $VIDEO_DIR/$1 | awk -F&quot; &quot; '{ print&nbsp; $NF }'`<br>
<br>
echo &quot;Will encode $inputfile&quot;<br>
basedname=`echo $inputfile | sed 's,^\(.*/\)\?\([^/]*\),\2,'`<br>
vidformat=`mplayer -vo null -ao null -frames 0 -identify &quot;$inputfile&quot;
2&gt;/dev/null | grep &quot;ID_VIDEO_FORMAT&quot; | sed -e
's/ID_VIDEO_FORMAT=//'`<br>
<br>
<br>
<br>
if !&nbsp; [ &quot;$vidformat&quot; == &quot;H264&quot; ]; then<br>
/usr/bin/ffmpeg -threads 2 -i&nbsp; $inputfile&nbsp; -acodec mp3 -ac 2 -ar
44100 -ab 128k -s 320x240 -vcodec h264 -sameq&nbsp; -flags +loop -cmp +chroma
-partitions +parti4x4+partp8x8+partb8x8 -me umh -subq 7 -trellis 2 -refs 1
-coder 0 -me_range 16 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71
-bt 300k -maxrate 300k -bufsize 300k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6
-qmin 15 -qmax 51 -qdiff 4 -level 30 -aspect 320:240&nbsp; $inputfile.avi<br>
<br>
<br>
mv $inputfile $inputfile.old<br>
mv $inputfile.avi $inputfile<br>
<br>
<br>
echo &quot;Building seek table&quot;<br>
mythcommflag --rebuild -f &quot;$inputfile&quot;<br>
<br>
echo &quot;Clearing the cut list&quot;<br>
mythcommflag --clearcutlist -f $inputfile<br>
<br>
echo &quot;Commercial skip to cutlist&quot;<br>
mythcommflag --gencutlist -f $inputfile<br>
<br>
filesize=$(wc -c $inputfile | awk '{print $1}')<br>
echo &quot;Updating database&quot;<br>
mysql -umythtv -pmythtv -hmymythtv mythconverg -se&quot;UPDATE recorded SET
cutlist=0,filesize=$filesize WHERE basename=\&quot;$basedname\&quot;;&quot;<br>
else<br>
echo &quot;Already an H264&quot;<br>
<br>
fi<br>
}<br>
<br>
<br>
CONVLIST=`mysql -umythtv -pmythtv -hmymythtv mythconverg -se&quot;select
basename from recorded where title like \&quot;%$1%\&quot;;&quot;`<br>
<br>
for i in ${CONVLIST[@]} ; do<br>
&nbsp; if ! test -L $VIDEO_DIR/$i ; then #its not a symnlink<br>
&nbsp;&nbsp;&nbsp;&nbsp; #Check if this recording is done -mmin +5<br>
&nbsp;&nbsp;&nbsp;&nbsp; filetoconvert=`find $VIDEO_DIR -name $i -mmin +5 | sed
's,^\(.*/\)\?\([^/]*\),\2,'`<br>
&nbsp;&nbsp;&nbsp;&nbsp; if [ -z &quot;$filetoconvert&quot; ]; then<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &quot;$i is not finnished
recording...Skipping&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp; else<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &quot;Moving $i to
/mnt/VIDEO1&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mv $VIDEO_DIR/$i /mnt/VIDEO1<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ln -sf /mnt/VIDEO1/$i $VIDEO_DIR/$i<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; convert-to-h264 $i<br>
&nbsp;&nbsp;&nbsp;&nbsp; fi<br>
&nbsp; else<br>
&nbsp;&nbsp;&nbsp;&nbsp; echo &quot;$i is already a symlink...Skipping&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp; convert-to-h264 $i<br>
&nbsp; fi<br>
<br>
<br>
<br>
<br>
done<o:p></o:p></p>

</div>

</body>

</html>