I am able to shrink 1 hour of video to approximately 150 MB at 200 kbit with ffmpeg using h264. Seems to work well except with seeking. I wonder if this is a keyframe issue. When I forward or rewind, there is distortion for a few seconds and then the video fixes itself. If I forward or rewind before the video is fixed, the progress bar seems to jump back. Seeking is more reliable when the distrotion is allowed to clear first. Also, I cannot jump to the very first frame of the recording. If I exit the recording and play it again, I start on the first frame. Here is a copy of my latest script. Single pass for now (hoping to go to 2 pass). 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" " '{ print $NF }'`<br><br>echo "Will encode $inputfile"<br>basedname=`echo $inputfile | sed 's,^\(.*/\)\?\([^/]*\),\2,'`<br>
vidformat=`mplayer -vo null -ao null -frames 0 -identify "$inputfile" 2>/dev/null | grep "ID_VIDEO_FORMAT" | sed -e 's/ID_VIDEO_FORMAT=//'`<br><br><br><br>if ! [ "$vidformat" == "H264" ]; then<br>
/usr/bin/ffmpeg -threads 2 -i $inputfile -acodec mp3 -ac 2 -ar 44100 -ab 128k -s 320x240 -vcodec h264 -sameq -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 $inputfile.avi<br>
<br><br>mv $inputfile $inputfile.old<br>mv $inputfile.avi $inputfile<br><br><br>echo "Building seek table"<br>mythcommflag --rebuild -f "$inputfile"<br><br>echo "Clearing the cut list"<br>mythcommflag --clearcutlist -f $inputfile<br>
<br>echo "Commercial skip to cutlist"<br>mythcommflag --gencutlist -f $inputfile<br><br>filesize=$(wc -c $inputfile | awk '{print $1}')<br>echo "Updating database"<br>mysql -umythtv -pmythtv -hmymythtv mythconverg -se"UPDATE recorded SET cutlist=0,filesize=$filesize WHERE basename=\"$basedname\";"<br>
else<br>echo "Already an H264"<br><br>fi<br>}<br><br><br>CONVLIST=`mysql -umythtv -pmythtv -hmymythtv mythconverg -se"select basename from recorded where title like \"%$1%\";"`<br><br>for i in ${CONVLIST[@]} ; do<br>
if ! test -L $VIDEO_DIR/$i ; then #its not a symnlink<br> #Check if this recording is done -mmin +5<br> filetoconvert=`find $VIDEO_DIR -name $i -mmin +5 | sed 's,^\(.*/\)\?\([^/]*\),\2,'`<br> if [ -z "$filetoconvert" ]; then<br>
echo "$i is not finnished recording...Skipping"<br> else<br> echo "Moving $i to /mnt/VIDEO1"<br> mv $VIDEO_DIR/$i /mnt/VIDEO1<br> ln -sf /mnt/VIDEO1/$i $VIDEO_DIR/$i<br>
convert-to-h264 $i<br> fi<br> else<br> echo "$i is already a symlink...Skipping"<br> convert-to-h264 $i<br> fi<br><br><br><br><br>done<br> [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" " '{ print $NF }'`<br><br>echo "Will encode $inputfile"<br>basedname=`echo $inputfile | sed 's,^\(.*/\)\?\([^/]*\),\2,'`<br>vidformat=`mplayer -vo null -ao null -frames 0 -identify "$inputfile" 2>/dev/null | grep "ID_VIDEO_FORMAT" | sed -e 's/ID_VIDEO_FORMAT=//'`<br>
<br><br><br>if ! [ "$vidformat" == "H264" ]; then<br>/usr/bin/ffmpeg -threads 2 -i $inputfile -acodec mp3 -ac 2 -ar 44100 -ab 128k -s 320x240 -vcodec h264 -sameq -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 $inputfile.avi<br>
<br><br>mv $inputfile $inputfile.old<br>mv $inputfile.avi $inputfile<br><br><br>echo "Building seek table"<br>mythcommflag --rebuild -f "$inputfile"<br><br>echo "Clearing the cut list"<br>mythcommflag --clearcutlist -f $inputfile<br>
<br>echo "Commercial skip to cutlist"<br>mythcommflag --gencutlist -f $inputfile<br><br>filesize=$(wc -c $inputfile | awk '{print $1}')<br>echo "Updating database"<br>mysql -umythtv -pmythtv -hmymythtv mythconverg -se"UPDATE recorded SET cutlist=0,filesize=$filesize WHERE basename=\"$basedname\";"<br>
else<br>echo "Already an H264"<br><br>fi<br>}<br><br><br>CONVLIST=`mysql -umythtv -pmythtv -hmymythtv mythconverg -se"select basename from recorded where title like \"%$1%\";"`<br><br>for i in ${CONVLIST[@]} ; do<br>
if ! test -L $VIDEO_DIR/$i ; then #its not a symnlink<br> #Check if this recording is done -mmin +5<br> filetoconvert=`find $VIDEO_DIR -name $i -mmin +5 | sed 's,^\(.*/\)\?\([^/]*\),\2,'`<br> if [ -z "$filetoconvert" ]; then<br>
echo "$i is not finnished recording...Skipping"<br> else<br> echo "Moving $i to /mnt/VIDEO1"<br> mv $VIDEO_DIR/$i /mnt/VIDEO1<br> ln -sf /mnt/VIDEO1/$i $VIDEO_DIR/$i<br>
convert-to-h264 $i<br> fi<br> else<br> echo "$i is already a symlink...Skipping"<br> convert-to-h264 $i<br> fi<br><br><br><br><br>done<br><br>