VideoHelp.com Forum
+ Reply to Thread
Results 1 to 3 of 3
Thread
  1. Member
    Join Date: Jan 2011
    Location: az (timezone not listed)
    #!/bin/sh
    ##
    ## ts2avi version 1.03 (01/11/2012) freeware by robert_maul@hotmail.com
    ## translate *.ts to *.avi (XviD) (works well with avidemux editor)

    ## ALERT: Version 1.02 broken by WinFF Version 1.4.0 (see notes below)
    ## this script will break again with the next version of WinFF

    ## This script runs on Windows using MinGW Shell aka Msys (Minimal Gnu on Windows)
    ## which is downloaded from sourceforge.net (cygwin has no uninstall! too messy!)
    ## since i started using MinGW i don't bother with Ubuntu any more.
    ## I added this script to my c:\users\robert\bin directory and
    ## that directory to the end of the system PATH variable

    JAVA_HOME="/c/Program Files/Java/jre7/bin" # 64 bit java install
    java="$JAVA_HOME/java"
    projectx="/c/Project-X_0.91.0/ProjectX.jar"
    FFMPEG_HOME="/c/Program Files (x86)/WinFF" # 32 bit (WinFF)
    #FFMPEG_HOME="/c/AutoFF0998_Full_win" # 32 bit (AutoFF)
    ffmpeg="$FFMPEG_HOME/ffmpeg"
    AVIDEMUX_HOME="/c/Program Files/Avidemux 2.5"
    avidemux="$AVIDEMUX_HOME/avidemux2_cli" # 64 bit command line version

    ## download locations: (i use 64 bit when available on my 64 bit machines)
    ##
    ## java: http://download.oracle.com/otn-pub/j...indows-x64.exe
    ## project-x: http://sourceforge.net/projects/proj...urce=directory
    ## avidemux: http://avidemux.sourceforge.net/ (choose command line when installing)
    ## ffmpeg: http://www.videohelp.com/tools/ffmpeg (then choose AutoFF link)
    ## or
    ## ffmpeg: http://www.winff.org/html_new/downloads.html
    ##
    ## email me suggestions for stable 64 bit version of ffmpeg that is easy to install.
    ## of course it would be nice if you tested it with this script before emailing me.

    ## Changes for 1.01: adjusted numbers for -wide2full option
    ## ffmpeg docs for -cropleft and -cropright very confusing.
    ## only took me about 1 year of tying different things to figure this out!

    ## Changes for 1.02: added -full2wide option for non HD station airing widescreen
    ## video (tiny widescreen rectangle in the middle of widescreen monitor)
    ## adjusted numbers for -full option so no resizing happens, (faster translation)

    ## Changes for 1.03: This script was broken with WinFF version 1.4.0 (works with WinFF 1.3.1)
    ## I don't know why the ffmpeg command line option changed but I have attempted temp fix

    ## Old Linux based notes:
    ##
    ## Ubuntu Linux version depends on project-x, winff and
    ## libavcodec-unstripped-52 # the name of this lib may vary but it contains XviD
    ## all found in ubuntu 10.10 synaptic repositories
    ## also depends on avidemux2_cli listed as avidemux-cli in rep

    ## i have a haupaugge capture card that creates the *.ts files
    ## i am currently looking for a better card since the WinTV
    ## software that comes with it crashes all time with the 2250
    ## so i had to yank it run with my old 1600 card only.
    ## UPDATE: WinTV 2.4 has not crashed on me yet.

    ## I imagine that this script could be adapted to convert the
    ## video files created with other brands of cards. suggestions
    ## for new cards greatly appreciated

    ## windows users can install ubuntu on there windows box quite
    ## easily using virtualbox 4.x and ubuntu.10.10 ... i found it
    ## easier than trying to rewrite this script in a windows script
    ## virtualbox lets you run windows and ubuntu linux at the same time

    ## my next project is to write a cron script that will run this
    ## this script automattically and delete the large ts and m2v
    ## files and leave just the *.avi and *.ac3 files that need to
    ## be merged before editing. so as the large ts files are
    ## created they can be tranlated to xvid unattended

    ## as of version 4.0 of virtualbox it is easy to share folders
    ## between the host (windows) and guest (ubuntu) machine provided
    ## that the share is not on the C: drive (permissions problems)

    ## note: the final *.editing.avi files created by this script will
    ## be larger when run through project-x, you can get away without
    ## running project-x if the input files have no bad data.
    ## bad data is usually weather or signal strength dependent.

    ## step 1 (automated)
    ## use Project-X to throw out any bad data and sync video and audi0
    ## with ProjectX (free download at sourcforge.net)
    ## for each ts file create a directory and move the file there.
    ## then demux the file creating the m2v (video) and ac3 (sound)
    ## The Project-X command line method was found in the ProjectX
    ## source ReadMe.txt file

    ## step 2 (automated)
    ## create avi file using ffmpeg (download winff and ffmpeg included)
    ## translate the m2v (video only) file to an avi (XviD) file
    ## the ffmpeg options used here were found by running winff and
    ## choosing: "Display CMD Line" under the options menu

    ## step 3 (automated) avidemux command line is run to put the *.avi
    ## and *.ac3 (audio) files together to create the *.editing.avi

    ## step 4 (manual)
    ## edit out commercials with avidemux and save that file as:
    ## *.done.avi

    arg=$1
    crop=""
    if [ $arg = "-wide" ]; then
    dim=704x384 # Winff default value used in case user wants to run 2-pass on
    asp=16:9 # final edited *.done.avi file using WinFF (might make it smaller)
    echo running with widescreen $asp aspect ratio $dim resolution
    else
    if [ $arg = "-wide720p" ]; then # disk space is getting cheaper so save quality
    dim=1320x720 # 16/9=x/720 solve for x=1320
    asp=16:9 # 720p just means vertical resolution is 720
    echo running with wide screen 16:9 aspect ratio 720p resolution
    else
    if [ $arg = "-wide2full" ]; then # for HD station with full screen video
    echo running with wide to full screen cropping to 4:3 aspect ratio
    asp=4:3 # assuming the mpeg-2 file is 1980x1080 1980/16=x/4 solve for x=495
    crop=" -cropleft 246 -cropright 246 " # 495/2~=246 (must crop in even numbers)
    # 246 + 246 + 640 = 1132 (add back what was cropped off to arrive at 640x480)
    dim=1132x480 # cropping happens before resizing but it also affects the
    # resolution after resizing so it must be added back (very weird)
    else
    if [ $arg = "-full2wide" ]; then # for non HD station with wide screen video
    echo running with full to wide screen cropping to 16:9 aspect ratio
    asp=16:9 # assuming the mpeg-2 file is 704x480 704/16=x/9 solve for x=396
    crop=" -croptop 42 -cropbottom 42 " # 480-396=84 84/2=42
    dim=704x396 # no resizing, just cropping
    else
    if [ $arg = "-full" ]; then
    dim=704x480 # no resizing = faster translation
    asp=4:3
    echo running with fullcreen 4:3 aspect ratio $dim resolution
    else
    echo args must be: "-wide", "-wide720p", "-wide2full", "-full2wide" or "-full"
    exit 1
    fi
    fi
    fi
    fi
    fi
    ## do steps 1, 2 and 3 for all files in list
    list=`ls *.ts`
    for fn in $list ; do
    dir=`basename $fn .ts`
    if [ ! -d $dir ]; then
    mkdir $dir
    fi
    mv $fn $dir
    cd $dir
    dirpath=`pwd`
    avi="$dirpath/$dir.avi"
    m2v="$dirpath/$dir.m2v"
    if [ ! -f $m2v ]; then
    "$java" -Djava.awt.headless=true -jar "$projectx" -demux $fn
    fi
    if [ ! -f "$avi" ]; then
    if [ -f "$m2v" ]; then
    "$ffmpeg" -version >& tmp # WinFF 1.4.0 changed cmd line options for ffmpeg
    ffmpeg_version=`head -1 tmp | awk '{print $2}'`
    echo $ffmpeg_version
    if [ $ffmpeg_version = "N-34294-g0bc5677" ]; then # it's Winff 1.4.0
    "$ffmpeg" -y -i $m2v -f avi -r 29.97 -vcodec libxvid -vtag XVID -s $dim \
    -aspect $asp -maxrate 1800k -b 1500k -qmin 3 -qmax 5 -bufsize 4096 \
    -mbd 2 -bf 2 -acodec libmp3lame -ar 48000 -ab 128k -ac 2 $crop "$avi"
    else # WinFF version 1.3.1 and previous
    "$ffmpeg" -i $m2v -f avi -r 29.97 -vcodec libxvid -vtag XVID -s $dim \
    -aspect $asp -maxrate 1800k -b 1500k -qmin 3 -qmax 5 -bufsize 4096 \
    -mbd 2 -bf 2 -flags +4mv -trellis -aic -cmp 2 -subcmp 2 -g 300 \
    -acodec libmp3lame -ar 48000 -ab 128k -ac 2 $crop "$avi"
    fi
    fi
    fi
    if [ -f "$avi" ]; then # find the largest ac3 file and join it to the avi file
    maxsize=0 # the smaller file is in mono and has snaps, crackles and pops
    ac3list=`ls *.ac3`
    for f in $ac3list ; do
    size=`ls -la $f | awk '{ print $5 }' `
    if [ $size -gt $maxsize ]; then
    ac3=$f
    maxsize=$size
    fi
    done
    "$avidemux" --load "$avi" --external-ac3 "$ac3" --save "$dir.editing.avi" <<EOF
    y
    EOF
    fi
    cd ..
    done
    Last edited by robertmaul; 15th Jan 2012 at 09:09.
    Quote Quote  

  2. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date: Aug 2000
    Location: Sweden
    robertmaul: Please stop dig up old threads. And I moved your post to a new thread.
    Quote Quote  

  3. Member
    Join Date: Jan 2011
    Location: az (timezone not listed)
    this script works on both windows and ubuntu linux

    there is an indented version here: http://www.avidemux.org/smf/index.php?topic=10028.0
    Last edited by robertmaul; 2nd Dec 2011 at 00:15.
    Quote Quote  




Similar Threads

  1. hauppauge 1212 and wintv extend
    By tkolt in forum Media Center PC / MediaCenters
    Replies: 0
    Last Post: 18th Nov 2011, 18:56
  2. Replies: 14
    Last Post: 6th Nov 2011, 21:52
  3. Hauppauge WinTV-PVR 250
    By thatsgame1 in forum Newbie / General discussions
    Replies: 5
    Last Post: 22nd Jun 2011, 06:54
  4. Hauppauge WinTV-HVR-950Q
    By mauiwowi in forum Capturing
    Replies: 1
    Last Post: 28th Aug 2009, 21:43
  5. Hauppauge WinTV PVR 250
    By kenmo in forum Computer
    Replies: 10
    Last Post: 28th Apr 2009, 13:21
Search   Contact us   About   Advertise   Forum   RSS Feeds   Statistics   Tools