Results 1 to 4 of 4

Thread: Batch conversion WMV to MP4 with Avidemux

  1. #1
    Join Date
    Aug 2006
    Location
    Canberra, Australia
    Beans
    89
    Distro
    Ubuntu 11.04 Natty Narwhal

    Smile Batch conversion WMV to MP4 with Avidemux

    I needed to convert a bunch of Windows movie files (.wmv) to MP4 format so my Motorola Xoom would play them reliably.

    Installed Avidemux on my Ubuntu 11.04 (32 bit) PC. Its easy to use the GUI but I needed an unattended job to process multiple files, so I saved this script and set the executable bit, double-clicked and let it run through the night.

    Hope it is useful to someone else.


    Code:
    #!/bin/bash
    # Usage: convert all WMV files to MP4
    shopt -s nullglob
    for f in *.wmv
    do avidemux --force-alt-h264 --load "$f" --audio-bitrate 224 --audio-codec aac --video-codec x264 --save "${f%.wmv}.mp4" --output-format MP4 --quit
    done
    Tony
    --
    Linux Mint 14, Linux user 456436

  2. #2
    Join Date
    Dec 2006
    Beans
    7,317

    Re: Batch conversion WMV to MP4 with Avidemux

    Nice, I did not know that avidemux could be used this way .
    You think that's air you're breathing now?

  3. #3
    Join Date
    Aug 2006
    Location
    Wiesbaden, Germany
    Beans
    40

    Re: Batch conversion WMV to MP4 with Avidemux

    Just created the following script, which uses a avidemux-gui for creating a project file used for avidemux-cli batch conversion. I am currently under ubuntu 11.10.

    1. Open a file with avidemux-gui (!!!).
    2. Configure like you want it to be.
    3. Save the project.


    Needs avidemux2-cli package!!!

    Code:
    #!/bin/bash
    
    FOLDER="Converted"   # Subfolder to put the converted files in
    IN_TYPE="mp4"        # File ending of input files
    OUT_TYPE="avi"       # Should match the type in avidemux
    PROJECT="convert_to_mjpeg.proj"  # the avidemux project file
    
    ##########################################
    
    mkdir -p $FOLDER
    
    cat "${PROJECT}" | \
    fgrep -v app.load  | \
    fgrep -v app.clearSegments  | \
    fgrep -v app.addSegment  | \
    fgrep -v app.markerA  | \
    fgrep -v app.markerB  \
    > "${PROJECT}.cli"
    
    BASE=""
    for InputItem in *.${IN_TYPE}
    do 
    	BASE="$(basename $InputItem .${IN_TYPE})"
    	avidemux2_cli \
                --load  "$InputItem" \
                --run "$PROJECT.cli" \
                --save "${FOLDER}/${BASE}.${OUT_TYPE}" 
    done
    Works like a charm. I am very happy.
    Feel free to adjust.

    Greets Axel
    Last edited by apos; December 28th, 2011 at 02:44 AM. Reason: Little Error in basename ...

  4. #4
    Join Date
    Aug 2006
    Location
    Wiesbaden, Germany
    Beans
    40

    Re: Batch conversion WMV to MP4 with Avidemux

    And the version to put into /usr/local/bin:

    Code:
    #!/bin/bash
    
    which avidemux2_cli > /dev/null || echo "Please install: sudo apt-get install avidemux-cli"
    which avidemux2_cli > /dev/null || exit 1
    
    [ "$4" ] || cat <<EOF
    
     USAGE: $(basename $0) 
    		<OUTPUT_FOLDER_NAME> 
    		<IN_TYPE OUT_TYPE> 
    		<OUTPUT_FILETYPE> 
    		<AVIDEMUX_PROJECT_FILE_NAME>
    
     e.g.
    
     $> $(basename $0) ConvertedFiles mp4 avi myavidemux.proj
    
    EOF
    
    [ "$1" ] || exit 1
    [ "$2" ] || exit 1
    [ "$3" ] || exit 1
    [ "$4" ] || exit 1
    
    FOLDER="$1"
    IN_TYPE="$2"
    OUT_TYPE="$3"
    PROJECT="$4"
    LOGFILE="conversion.log"
    
    ##########################################
    
    mkdir -p $FOLDER
    
    cat "${PROJECT}" | \
    fgrep -v app.load  | \
    fgrep -v app.clearSegments  | \
    fgrep -v app.addSegment  | \
    fgrep -v app.markerA  | \
    fgrep -v app.markerB \
    > "${PROJECT}.cli"
    
    cat "${PROJECT}.cli"
    
    BASE=""
    ERROR="0"
    for InputItem in *.${IN_TYPE}
    do 
    BASE="$(basename $InputItem .$IN_TYPE)"
    
    cat <<EOF
    #######################################################################
    #######################################################################
    ## avidemux2_cli 
    ## --load  "$InputItem"
    ## --run "$PROJECT.cli" 
    ## --save "${FOLDER}/${BASE}.${OUT_TYPE}
    ##
    EOF
    
    avidemux2_cli --load  "$InputItem" --run "$PROJECT.cli" --save "${FOLDER}/${BASE}.${OUT_TYPE}" || ERROR="1"
    
    cat <<EOF
    #######################################################################
    
    EOF
    
    done
    
    [ "$ERROR" = "1" ] && zenity --info --title "Conversion ended" --text "There have been ERRORS" 
    [ "$ERROR" = "0" ] && zenity --info --title "Conversion ended" --text "OK"
    Last edited by apos; December 28th, 2011 at 03:06 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •