Clay Haapala wrote:
Roger,

I'm trying to run more makempeg2 jobs and get the timings, but I'm having codec troubles. Below is the output of makempeg2, where it seems at the last step mencoder declares it cannot open a codec. Which codec or video-out device does it want? Is it sensitive to something in the particular content I'm transcoding? I've had success with some other hi-def video files.

This is a Mandriva 2008 64-bit system. I have compiled up the latest MPlayer (RC2), but its complaint is the same as the PLF packages that accompany the distro.

The actual "latest" of MPlayer is always SVN they are kind of funny on the releases (they don't like to do releases-so they don't). I have both older RC2 and the SVN release, but am probably going to go to using the SVN on everything as I submitted a feature to mencoder to improve cropdetect to remove usless crap (a couple of the TV stations here add logos slowly scrolling around the 4:3 content in digital widescreen broadcasts).



Here's the output, with the FATAL error at the bottom:

[EMAIL PROTECTED] tmp]$ makempeg2 home/mythtv/recordings/2051_20080801214700.mpg
Ext = mpg
Base = /home/mythtv/recordings/2051_20080801214700
/usr/local/bin/makempeg2: Temp file is /tmp/2051_20080801214700_tmp
Using SSE optimized IMDCT transform
Using MMX optimized resampler
The selected video_out device is incompatible with this codec.
Try appending the scale filter to your filter list,
e.g. -vf spp,scale instead of -vf spp.
Limiting audio preload to 0.4s.
Increasing audio density to 4.

1 duplicate frame(s)!
New_Face failed. Maybe the font path is wrong.
Please supply the text font file (~/.mplayer/subfont.ttf).
subtitle font: load_sub_face failed.
[...]
1 duplicate frame(s)!
/usr/local/bin/makempeg2: Oldfile= /home/mythtv/recordings/2051_20080801214700.mpg newfile= /home/mythtv/recordings/2051_20080801214700.mpg.tmp

/usr/local/bin/makempeg2: ABITRATE = 384 TMPFILE is /tmp/2051_20080801214700_tmp

/usr/local/bin/makempeg2: abitrate is 384 limited to 320kbit/second
Cropping calculation with hsize=1280 vsize=720
/usr/local/bin/makempeg2: size:1280x720 is 1280 x 720 with vtype = MPEG2 at 38810 bps and atype liba52 with crop=976:704:154:8,
/usr/local/bin/makempeg2: New Average bps = 3333 Max bps = 6666
/usr/local/bin/makempeg2: Crop is: crop=976:704:154:8,
/usr/local/bin/makempeg2: srate = 48000 abitrate=320
/usr/local/bin/makempeg2: FPS = 30000:1001
/usr/local/bin/makempeg2: scale = scale=640:456
/usr/local/bin/makempeg2: 1280x720 convertion selected
/usr/local/bin/makempeg2: Command line:
/usr/local/bin/makempeg2: nice -n 10 /usr/local/bin/mencoder -of mpeg -mpegopts format=dvd -ovc lavc -vf crop=976:704:154:8,scale=640:456,expand=640:480,harddup -lavcopts vcodec=mpeg2video:keyint=18:vrc_buf_size=1835:vrc_maxrate=6666:vbitrate=3333 -srate 48000 -oac mp3lame -lameopts cbr:br=320:preset=320 -audio-preload 0.0 /home/mythtv/recordings/2051_20080801214700.mpg -o /home/mythtv/recordings/2051_20080801214700.mpg.mpg
MEncoder 1.0rc2-4.2.2 (C) 2000-2007 MPlayer Team
CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 6000+ (Family: 15, Model: 67, Stepping: 3)
CPUflags: Type: 15 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
Compiled for x86 CPU with extensions: MMX MMX2 3DNow 3DNowEx SSE SSE2

success: format: 0  data: 0x0 - 0x50abf7b0
TS file format detected.
VIDEO MPEG2(pid=65) AUDIO A52(pid=68) NO SUBS (yet)!  PROGRAM N. 1
VIDEO: MPEG2 1280x720 (aspect 3) 59.940 fps 38810.4 kbps (4851.3 kbyte/s)
[V] filefmt:29  fourcc:0x10000002  size:1280x720  fps:59.94  ftime:=0.0167
==========================================================================
Opening audio decoder: [liba52] AC3 decoding with liba52
Using SSE optimized IMDCT transform
Using MMX optimized resampler
AUDIO: 48000 Hz, 2 ch, s16le, 384.0 kbit/25.00% (ratio: 48000->192000)
Selected audio codec: [a52] afm: liba52 (AC3-liba52)
==========================================================================
PACKET SIZE: 2048 bytes, deltascr: 43885
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
Opening video filter: [harddup]
Opening video filter: [expand w=640 h=480]
Expand: 640 x 480, -1 ; -1, osd: 0, aspect: 0.000000, round: 1
Opening video filter: [scale w=640 h=456]
Opening video filter: [crop w=976 h=704 x=154 y=8]
Crop: 976 x 704, 154 ; 8
==========================================================================
Opening video decoder: [mpegpes] MPEG 1/2 Video passthrough
VDec: vo config request - 1280 x 720 (preferred colorspace: Mpeg PES)
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
The selected video_out device is incompatible with this codec.
Try appending the scale filter to your filter list,
e.g. -vf spp,scale instead of -vf spp.
VDecoder init failed :(
Opening video decoder: [libmpeg2] MPEG 1/2 Video decoder libmpeg2-v0.4.0b
Selected video codec: [mpeg12] vfm: libmpeg2 (MPEG-1 or 2 (libmpeg2))
==========================================================================
MP3 audio selected.
Increasing audio density to 4.
VDec: vo config request - 1280 x 720 (preferred colorspace: Planar YV12)
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.
SwScaler: reducing / aligning filtersize 2 -> 4
SwScaler: reducing / aligning filtersize 2 -> 4
SwScaler: reducing / aligning filtersize 2 -> 2
SwScaler: reducing / aligning filtersize 2 -> 2
[swscaler @ 0xd1cdf0]SwScaler: FAST_BILINEAR scaler, from yuv420p to yuv420p using MMX2 [swscaler @ 0xd1cdf0]SwScaler: using 4-tap MMX scaler for horizontal luminance scaling [swscaler @ 0xd1cdf0]SwScaler: using 4-tap MMX scaler for horizontal chrominance scaling [swscaler @ 0xd1cdf0]SwScaler: using n-tap MMX scaler for vertical scaling (YV12 like)
[swscaler @ 0xd1cdf0]SwScaler: 976x704 -> 640x456
videocodec: libavcodec (640x480 fourcc=3267706d [mpg2])
[mpeg2video @ 0xd245c0]MPEG1/2 does not support 19001/317 fps
Could not open codec.
FATAL: Cannot initialize video driver.

Exiting...

Clay,

Which version of makempeg2 are you running (date and version number).

Is this a normal 720p ATSC type recording?

The mpeg1/2 codec is very picky about the frame rate, the codec is refusing to do the stream because it does not like the frame reate. If the frame rate was forced it would probably work right. Try the included version, it is the latest version I have and forces the frame rate (I did find some issues with the
frame rate causing issues in some cases).

The new version also samples the video and if the resolution is correct but the bitrate is too high >10Mbps it converts the video also, one of the stations here had their HDTV encoder break, and used a SD encoder (with a resolution that would be ok with MVPMC) with a really high bitrate for SD (14-15Mbps) and my mvpmc choked (lots of pauses) on that video.

                             Roger


#!/bin/bash
# Written by: Roger Heflin ([EMAIL PROTECTED])
#
# script to convert a video file into a form that is playable on a
# mvpmc box, used inside of MYTHTV to convert HD signals and other 
# files into forms that will work on the MVPMC box without using VLC
#
# Version 0.5   8/10/2007
#
# Version 0.52  11/05/2007 
# Changes:
#     Added code to use audio bitrate from original
#     Added code to use audio srate from original
#     Added code to remove audio preload - this seems to cause mvpmc to be
#          out of sync on *all* bitrates, not having the preload appears to
#          make the audio sync be wrong with mplayer - but we aren't using
#          mplayer for this are we.
#     Removed extra crap from mencoder sampling code
#     mplayer -identify only works with mplayer - not with mencoder - not sure
#              whoever added this option thought it out, and mplayer does not
#              appear to have a way to redirect to nowhere.
#     Added -lameopts and removed some lavcopts for audio that were basically
#          ignored
#     Changed scale to be in the y rather than the x (640) and use 400 rather
#          than 480, I found mencoder to sometimes decide to expand to 484 
#          with 480 as the setting and 484 won't play
#          on mvpmc
#     Set a lower audio srate and audio bps as some lower audio rates fail -
#          ie a srate of 12000 fails to produce any sound.
#
# Version 0.53  11/18/2007
# Changes:
#       Added code to rename the files, when the extension is .mpg
#       Used variables to reduce duplication of options in different locations
#       Change the default sws option from default to 0. (def=31.2fps/0=37.8fps)
#               on the conversion of video.  
#       Added code to print out cpu time and cpu percent used and to produce
#               a speed summary line.
#       Added more complicated code for scaling things to get to the biggest
#               size, 400 fails with some videos resulting in too large for
#               the mvpmc to play, and using 640 results in the y being too
#               big sometimes.
#
# Version 0.54  12/06/2007
# Changes:
#       On 1920x1080 video use -sws 2 (this is interlaced I believe)
#               otherwise you get some annoying artifacts, this may
#               need to be used on more than just that.   Not sure that
#               I understand this, only some programming on one of my
#               channels have these artifacts, it does not appear to be
#               releated to bit rate, and I cannot identify the difference
#               between the two programs.
#
# Version 0.55  1/9/2008
# Changes:
#       Corrected reporting of 0 size on missing filename
#       Changed debug to be > 0 rather than =0.
#       
# Version 0.56  1/11/2008
# Changes:
#       Added code to detect 528x480 mpeg file with ac3 (from qam cable
#               I believe, this also claims to have a bps of 15000 but
#               actually appears to really have 3000 bps that will actually
#               play on a mvpmc - reported by Mark Paulus.
#       Added code to catch any > 10000 bps and lower the bit rate.
#       Corrected a later if statement that did not have both possible mp3lib
#               strings that could be returned.
#
# Version 0.57  1/18/2008
# Changes:
#       Added nice  to mencoder to attempt to prevent slowness with 
#               backend operations
#       Increased crop frames to get past small regions with different 
#               crop - we may eventually have to do the entire show or
#               somehow sample the show and figure out from a number
#               of samples what the crop should be.
# Version 0.58  1/30/2008
# Changes:
#       Added code to deal with clips with no audio in them.
#
# Version 0.59  7/28/2008
# Changes:
#       Added code to check the average bitrate from the cropdetect since some 
videos
#               appear to claim high bitrates and really have low bitrates and 
don't
#               need a video transcode, and some claim high bitrates and have 
high bitrates,
#               often when the broadcasters screw up (ie 704x480 with abps of 
14.5mbit on a
#               subchannel that just days ago was 1920x1080).
#       Reduced abps default from 5500 to 2500.
#               
#
# How to add as a mythtv user job:
#
#       mythtv-setup -> general -> screen with user jobs
#               Add to a user job this:
#               "/usr/local/bin/makempeg2 mythjob %DIR% %FILE% >> 
/tmp/makempeg2_out.log"
#
#       You will need to enable user job and set it up to actually run on 
#               new recordings.
#       To test:
#               Watch Recordings -> Right Arrow -> Job Options -> select run 
user job 
#               The job should start in a minute or two.
#
echo $* >> /tmp/makempeg2.log
export DEBUG=1
export srate=48000
export abitrate=320
export mencoder=mencoder

if [ "${1}" == "mythjob" ] ; then
  export filename="${2}/${3}"
  cd ${2}
  export mythjob=1
else
  export mythjob=0
  export filename=${1}
fi

#
if [ ! -s "$filename" ] ; then
  echo "${0}: $filename has 0 size"
  exit -1
fi
if [ -L "$filename" ] ; then
  echo "${0}: $filename is a link - this program will not copy and replace 
properly with a link"
  exit -1
fi
#
# sample in several places
# -ovc copy fails to check for audio with DX50 file ... but appears to be fine 
with 
# everything else
#

# -vf scale=720:480 -vf expand=576:432
if [ -f "$filename" ] ; then
  # this really should work in bash - it is documented but does not actually 
appear to work
  ext=`echo "${filename}" | awk  '{ NF=split($0,parts,".") ;print parts[NF] }'`
  echo "Ext = ${ext}"
  obase=`echo "${filename}" | awk  '{ NF=split($0,parts,".") ;for 
(i=1;i<NF;i++) printf("%s",parts[i]) }'`
  echo "Base = ${obase}"
  fnonly=`echo "${obase}" | awk '{ NF=split($0,parts,"/") 
;printf("%s",parts[NF]) }'`
  export TMPFILE=/tmp/${fnonly}_tmp
  if [ $DEBUG -gt 0 ] ; then
    echo "${0}: Temp file is $TMPFILE"
  fi
  nice -n 10 ${mencoder} -of mpeg -frames 4000 -vf cropdetect -oac mp3lame -ovc 
raw -o /dev/null "$filename" 2>&1 > ${TMPFILE}
  nice -n 10 ${mencoder} -of mpeg -frames 4000 -oac mp3lame -ovc copy -o 
/dev/null "$filename" 2>&1 > ${TMPFILE}.avbps

else
  echo "Usage: ${0} <videofiletoconvert>"
  echo " "
  exit -1
fi

export oldfile="$filename"
export newfile="${filename}.tmp"
if [ $DEBUG -gt 0 ] ; then
  echo "${0}: Oldfile= $oldfile   newfile= $newfile"
fi


#
# success: format: 0  data: 0x0 - 0x5ae43e0c
#TS file format detected.
#DEMUX OPEN, AUDIO_ID: -1, VIDEO_ID: -1, SUBTITLE_ID: -1,
#PROBING UP TO 2000000, PROG: 0
#VIDEO MPEG2(pid=49)AUDIO A52(pid=52) NO SUBS (yet)!  PROGRAM N. 1
#Opened TS demuxer, audio: 2000(pid 52), video: 10000002(pid 49)...POS=564
#VIDEO:  MPEG2  1920x1080  (aspect 3)  29.970 fps  65000.0 kbps (8125.0 kbyte/s)
#[V] filefmt:29  fourcc:0x10000002  size:1920x1080  fps:29.97  ftime:=0.0334
#Opening audio decoder: [liba52] AC3 decoding with liba52
#AC3: 2.0 (stereo)  48000 Hz  384.0 kbit/s
#AUDIO: 48000 Hz, 2 ch, s16le, 384.0 kbit/25.00% (ratio: 48000->192000)
#Selected audio codec: [a52] afm:liba52 (AC3-liba52)

export vtype=`cat ${TMPFILE} | awk '$1 ~ "VIDEO:" { print $2}'`
export vbps=`cat ${TMPFILE} | awk '$1 ~ "VIDEO:" { for (i=1;i<NF;i++) if ($i ~ 
"kbps" ) printf("%6.0f", $(i-1))}'`
export avbps=`cat ${TMPFILE}.avbps | awk '$1 ~ "Video" { printf("%d",$3)}'`
export size=`cat ${TMPFILE} | awk '$4 ~ "size:" { print $4}'`
export hsize=`echo $size | awk -F: '{split($2,parts,"x");print parts[1]}'`
export vsize=`echo $size | awk -F: '{split($2,parts,"x");print parts[2]}'`
export atype=`cat ${TMPFILE} | awk '$1 ~ "Selected" && $2 ~ "audio" { print $6 
}'`
export abitrate=`cat ${TMPFILE} | awk '$1 ~ "AUDIO:" { printf("%d",$7) }'`
export srate=`cat ${TMPFILE} | awk '$1 ~ "AUDIO:" { print $2 }'`
export fps=`cat ${TMPFILE} | awk '$1 ~ "VIDEO:" && $6 ~ "fps" { print $5 } $1 ~ 
"VIDEO:" && $7 ~ "fps" { print $6} '`

export SWS="-sws 0"
if [ ${hsize} -eq 1920 ] && [ ${vsize} -eq 1080 ] ; then
  echo "${0}: Interlaced video - using default sws of 2"
fi

if [ ${vbps} -eq 0 ] ; then 
  vbps=2000
fi
echo " "
echo "${0}: ABITRATE = ${abitrate} TMPFILE is ${TMPFILE}"
echo " "
#cat ${TMPFILE}

export AUDIOEXTRA="-audio-preload 0.0"

if [ ! $?srate ] ; then
  echo "No audio found in this clip"
  export AUDIOEXTRA="-nosound"  
  # some options to get to to pass through without audio
  export srate=22050
  export atype=none
  export abitrate=192
else
  if [ ${srate} -le 22050 ] ;  then
  # certain audio rates seem to fail.
  # ie 12000 fails either with VLC or transcoded, so set
  # a lower limit.   Lower limits may work, and/or only certain
  # ones may not work - not enough testing has been done to determine
  # which work and which fail.
    export srate=22050
    export abitrate=128
  fi
  if [ ${abitrate} -gt 320 ] ; then
  #
  # lame limits to 320
  #
    echo "${0}: abitrate is ${abitrate} limited to 320kbit/second"
    export abitrate=320
  elif [ ${abitrate} -lt 64 ] ; then
    echo "${0}: abitrate is ${abitrate} limited to min of 64kbit/second"
    export abitrate=64
  fi
fi

if [ -z "$vsize" ] || [ -z "$hsize" ] || [ -z "$atype" ] || [ -z "$vbps" ] ||
  [ -z "$atype" ] || [ -z "$vtype" ] ; then
  cat ${TMPFILE}
  echo "${0}: ERROR: file $filename had a empty size or video or audio decoder 
- or "
  echo "${0}:       the information was parsed incorrectly"
  echo "${0}: $size is $hsize x $vsize with vtype = $vtype at $vbps bps and 
atype $atype with $crop"
  exit -1
fi
echo "Cropping calculation with hsize=${hsize} vsize=${vsize}"
export crop=`grep  "Crop area" ${TMPFILE}*  | awk -v hsize=${hsize} -v 
vsize=${vsize} 'BEGIN { cropminx=hsize;cropminy=vsize;cropmaxx=0;cropmaxy=0} 
{for (i=1;i<NF;i++) { if ($i ~ "-vf") split($(i+1),crop,"[=:)]") ; if ( crop[1] 
== "crop" ) { if ( crop[2] > cropmaxx ) cropmaxx=crop[2] ; if ( crop[3] > 
cropmaxy ) cropmaxy=crop[3] ; if (crop[4] < cropminx ) cropminx=crop[4] ; if 
(crop[5] < cropminy ) cropminy=crop[5]}}} END { if ((cropmaxx != 0) && ( 
cropmaxy != 0) ) 
printf("crop=%d:%d:%d:%d,",cropmaxx,cropmaxy,cropminx,cropminy)}'`
if [ "${crop}" == "" ] ; then
  echo "No crop found - using full size"
  export crop=","
fi
if [ $? != 0 ] ; then
  exit
fi
if [ $DEBUG -gt 0 ] ; then
  #echo "START >>>>>>"
  #cat ${TMPFILE}*
  #echo "<<<<<<<END"
  #grep -i CROP ${TMPFILE}*
  echo "${0}: $size is $hsize x $vsize with vtype = $vtype at $vbps bps and 
atype $atype with $crop"
fi

if [ ${vbps} -gt 20000 ] ; then 
  # ATSC is limited to about 20Mbps
  export vbps=20000
fi
# Cut the bps down by replacing 480 with 360 to reduece by 75%, 
# a factor of 2 causes some annoying artifacts.
export abps=`expr ${vbps} \* 640 / ${hsize} \* 480 / ${vsize} / 2`
if [ "${vtype}" != "MPEG1" ] && [ "${vtype}" != "MPEG2" ] ; then
  export abps=`expr ${abps} \* 6`
fi
if [ ${abps} -gt 2500 ] ; then 
  export abps=2500
fi

if [ ${abps} -eq 0 ] ; then 
  # probably not needed unless doing the / 2 to reduce size
  # this reduces to just above 1GB/hour.
  if [ ${hsize} -eq 848 ] && [ ${vsize} -eq 480 ] ; then
    # video from digital camera
    export abps=3000
  else
    export abps=1000
  fi
fi
export mbps=`expr ${abps} \* 2`

echo "${0}: New Average bps = ${abps} Max bps = ${mbps}"
echo "${0}: Crop is: ${crop}"
echo "${0}: srate = ${srate} abitrate=${abitrate}"

#rm ${TMPFILE}*

export AUDIOOPTS="-srate ${srate}  -oac mp3lame -lameopts 
cbr:br=${abitrate}:preset=${abitrate}"
#
# Note that the -ofps is only needed if the original file is at a different 
fps, this may
# need to be adjusted for PAL usage.
#
# 1000.000 seems to come out of wmv files
# 29.970 comes from avi and is not supported for mpeg
#if [ "${fps}" == "29.970" ] || [ "${fps}" == "1000.000" ] || [ "${fps}" == 
"59.940" ] ; then
  export fps="30000:1001"
#fi
echo "${0}: FPS = ${fps}"
export MENCODEROPTS="nice -n 10 ${mencoder} -of mpeg -mpegopts format=dvd -ofps 
${fps}"


export SCALE=`echo "${crop} 640 480" | awk ' { thsize=$2; tvsize=$3 ; 
split($1,cropd,"=") ; split(cropd[2],croplim,":") ; hsize=croplim[1]-cromlim[3] 
; vsize=croplim[2]-croplim[4]; factor=thsize/hsize ; nhsize=thsize ; 
nvsize=factor*vsize ; if ( nvsize > tvsize ){ factor=tvsize/vsize ; 
nhsize=factor*hsize ; nvsize=tvsize } ; printf("scale=%d:%d",nhsize,nvsize)}'`
if [ $? != 0 ] ; then
  exit
fi
if [ ${DEBUG} -gt 0 ] ; then
  echo "${0}: scale = ${SCALE}"
fi
export EXPAND="expand=640:480"
if [ $hsize == 1920 ] && [ $vsize == 1080 ] ; then
  export CONVERSION="1920x1080 convertion selected"
  # this is interlaced video - sws 0 produces annoying artificats
  export SWS="-sws 2"
  export VIDOPTS="-ovc lavc -vf ${crop}${SCALE},${EXPAND},harddup -lavcopts 
vcodec=mpeg2video:keyint=18:vrc_buf_size=1835:vrc_maxrate=${mbps}:vbitrate=${abps}"
elif [ $hsize == 1280 ] && [ $vsize == 720 ] ; then

  export CONVERSION="1280x720 convertion selected"
  export VIDOPTS="-ovc lavc -vf ${crop}${SCALE},${EXPAND},harddup -lavcopts 
vcodec=mpeg2video:keyint=18:vrc_buf_size=1835:vrc_maxrate=${mbps}:vbitrate=${abps}"
elif ( ( [ $hsize == 704 ] && [ $vsize == 480 ] ) ||
       ( [ $hsize == 720 ] && [ $vsize == 480 ] ) || 
       ( [ $hsize == 528 ] && [ $vsize == 480 ] ) || 
       ( [ $hsize == 640 ] && [ $vsize == 480 ] ) ) &&  
       ( [  "$vtype" == "MPEG1" ] || [ "$vtype" == "MPEG2" ] ) ; then

    export VIDOPTS="-ovc copy"
    if [ $avbps -gt 10000 ] ; then
      echo "${0}: Warning this files actual average bps is sampled as ${avbps} 
and is likely too high"
      echo "${0}:      to play on the mvpmc - reducing the bitrate to ${abps}"
      export VIDOPTS="-ovc lavc -vf harddup -lavcopts 
vcodec=mpeg2video:keyint=18:vrc_buf_size=1835:vrc_maxrate=${mbps}:vbitrate=${abps}"
    fi
    if [ "${atype}" != "(mp3lib" ]  && [ "${atype}" != "mp3lib" ] ; then
      echo "${0}: Audio is $atype and will not work - transcoding the audio"
      export CONVERSION="Audio is ${atype} and will not work - transcoding the 
audio"
    elif [ "${VIDOPTS}" == "-ovc copy" ] ; then
      echo "${0}: This movie should play on the MVPMC - no transcoding needed"
      echo " "
      exit 0
    fi
elif [ $hsize == 320 ] && [ $vsize == 240 ] && [ "$vtype" != "MPEG2" ] ; then 
    # plays as postage stamp size
    # rescale to something that will play
    abps=`expr ${abps} / 4`
    mbps=`expr ${mbps} / 4`
    export CONVERSION="320x240 non-mpeg2 to mpeg2 conversion selected"
    export VIDOPTS="-ovc lavc -vf ${crop}scale=320:240,harddup -lavcopts 
vcodec=mpeg2video:acodec=mp3:keyint=18:vrc_buf_size=1835:vrc_maxrate=${mbps}:vbitrate=${abps}"
elif [ $vbps -gt 10000 ] ; then
  echo "${0}: This file has a bit rate of $vbps and is to high to play on MVPMC 
- transcoding video to lower rate"
  export CONVERSION="bps to high convertion selected"
  export VIDOPTS="-ovc lavc -vf ${crop}${SCALE},${EXPAND},harddup -lavcopts 
vcodec=mpeg2video:keyint=18:vrc_buf_size=1835:vrc_maxrate=${mbps}:vbitrate=${abps}"
elif [ "$vtype" != "MPEG1" ] && [ "$vtype" != "MPEG2" ] ; then
  echo "${0}: This file is not MPEG1 or MPEG2 - transcoding"
  export CONVERSION="non-mpeg2/mpeg1 to mpeg2 conversion selected"
  abps=`expr ${abps} / 2`
  mbps=`expr ${mbps} / 2`
if [ $hsize -eq 480 ] && [ $vsize -eq 480 ] ; then   
    export mbps=`expr ${vbps} \* 2`
    export VIDOPTS="-ovc lavc -vf ${crop}scale=640:480,harddup -lavcopts 
vcodec=mpeg2video:keyint=18:vrc_buf_size=1835:vrc_maxrate=${mbps}:vbitrate=${vbps}"
 
  else
    export VIDOPTS="-ovc lavc -vf ${crop}${SCALE},${EXPAND},harddup -lavcopts 
vcodec=mpeg2video:keyint=18:vrc_buf_size=1835:vrc_maxrate=${mbps}:vbitrate=${abps}"
 
  fi
elif [ "$atype" != "(mp3lib" ] && [ "$atype" != "mp3lib" ] ; then
  #
  # there is probably an audio bps limit - I have not yet seen a failure around 
it so won't
  # worry about the audio bps at this time
  #
  echo "${0}: This file does not use mp3lib audio and will not play correctly 
on audio on MVPMC (ac3 will play but be out of sync)"
  exit 0
elif ( [ $hsize == 352 ] && [ $vsize == 240 ] ) ||
     ( [ $hsize == 480 ] && [ $vsize == 480 ] ) ||
     ( [ $hsize == 528 ] && [ $vsize == 480 ] ) || 
     ( [ $hsize == 704 ] && [ $vsize == 480 ] ) || 
     ( [ $hsize == 720 ] && [ $vsize == 480 ] ) ; then
  echo "${0}: This video file is believed to work on MVPMC correctly - no 
changes needed"
  exit 0
else

  echo "${0}: Unknown MPEG1/MPEG2 with mp3 audio $hsize x $vsize it may or may 
not play correctly"
  exit 0
fi



echo ${0}: $CONVERSION
echo "${0}: Command line: "
echo "${0}: ${MENCODEROPTS} ${VIDOPTS} ${AUDIOOPTS} ${AUDIOEXTRA} ${filename} 
-o ${filename}.mpg"
/usr/bin/time --verbose -o ${TMPFILE}.time ${MENCODEROPTS} ${SWS} ${VIDOPTS} 
${AUDIOOPTS} ${AUDIOEXTRA} "${filename}" -o "${filename}.mpg" 2>&1 | tee 
${TMPFILE}.transcode
if [ $? == 0 ] && [ -s "${filename}.mpg" ] ; then
  # only rename to original if original extension is .mpg or .mpeg
  if [ "${ext}" = "mpg" ] || [ "${ext}" = "mpeg" ] || [ "${ext}" = "MPG" ] || [ 
"${ext}" = "MPEG" ] ; then
    echo "${0}: Extension is a mpeg type extension - renaming "
    if [ -f "${filename}.orig" ] ; then
      echo "${0}: File ${filename}.orig already exists renaming original 
${filename}.orig to .2"
      if [ -f "${filename}.orig.2" ] ; then
        mv "${filename}.orig.2" "${filename}.orig.3"
      fi
      mv "${filename}.orig" "${filename}.orig.2" 
    fi
    mv "${filename}" "${filename}.orig"
    mv "${filename}.mpg" "${filename}"
    if [ ${mythjob} -eq 1 ] ; then
      echo "${0}: Running mythcommflag"
      nice -n 10 mythcommflag -f "${filename}"
    fi
  else
    echo "${0}: Original extension was not a mpeg extension"
    if [ -f "${obase}.mpg" ] ; then
      echo "${0}: File ${obase}.mpg already exists - not using"
    else
      echo "${0}: Renaming ${filename}.mpg to ${obase}.mpg"
      mv "${filename}.mpg" "${obase}.mpg"
    fi
  fi
fi
ls -l ${TMPFILE}.time ${TMPFILE}.transcode "${obase}"*
CPUpercent=`grep "Percent of CPU" ${TMPFILE}.time | awk '{print $7}'` 
ElapsedTime=`grep "Elapsed " ${TMPFILE}.time | awk '{print $8}'` 
Vbps=`grep "Video stream" ${TMPFILE}.transcode | awk '{print $3}'`
Abps=`grep "Audio stream" ${TMPFILE}.transcode | awk '{print $3}'`
Vsize=`grep "Video stream" ${TMPFILE}.transcode | awk '{print $8}'`
Vtime=`grep "Video stream" ${TMPFILE}.transcode | awk '{print $10}'`

logger -p info -t transcode  "Transcoded ${filename} 
(${hsize}x${vsize}-${Vtime} sec) in ${ElapsedTime} with ${CPUpercent} CPU to 
mvpmc with vbps=${Vbps}Kbps and abps=${Abps}Kbps"
echo "${0}: Transcoded ${filename} (${hsize}x${vsize}-${Vtime} sec) in 
${ElapsedTime} with ${CPUpercent} CPU to mvpmc with vbps=${Vbps}Kbps and 
abps=${Abps}Kbps"
date >> /tmp/makempeg2.log
echo "${0}: Transcoded ${filename} (${hsize}x${vsize}-${Vtime} sec) in 
${ElapsedTime} with ${CPUpercent} CPU to mvpmc with vbps=${Vbps}Kbps and 
abps=${Abps}Kbps" >> /tmp/makempeg2.log
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Mvpmc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mvpmc-users
mvpmc wiki: http://mvpmc.wikispaces.com/

Reply via email to