1. elmo sgot's Avatar
    Hey guys I just wanted to share a script that I made it works with mac os x and linux. For mac os x you need first to install macports and then install the packages ffmpeg and normalize.

    The script rips first the audio and converts it from 6 channels audio to 2 channel audio. Then the script normalize the audio volume. Then it merges the original video stream and the optimized audio stream together into a new .mp4, if source is mp4 as well it will add .1.mp4 or until it finds an non existing filename. Then for the mac users I have build in a check if the playbook has been mounted to /Volumes/media if so the script automatically copies the video to the playbook videos folder.

    I placed the script on my mac in the macports folder '/opt/local/bin' From then you can use it in any directory in your terminal.

    Code:
    sh convert.sh original.mkv
    /opt/local/bin/convert.sh
    Code:
    #!/bin/bash
    DIR="$( cd -P "$( dirname "$0" )" && pwd )"
    SRC=("$1")
    PLAYBOOK="/Volumes/media"
    NAME=${SRC%.*}
    TIME="date +"%H:%M.%S""
    echo "$( $TIME ): Downmixing audio to 2 channels"
    ffmpeg -i $DIR/$SRC -acodec pcm_s16le -ac 2 $DIR/audio.wav > /dev/null 2>&1
    echo "$( $TIME ): Normalizing audio"
    normalize -b $DIR/audio.wav > /dev/null 2>&1
    echo "$( $TIME ): Creating mp4 with original video and normalized audio in 2 channels"
    POST=""
    I=0
    for(( ; ; )) do
            if [ ! -f $DIR/$NAME$POST ]
            then
                    break
            fi
            I=$(( $I + 1 ))
            POST=".$I"
    done
    ffmpeg -i $DIR/$SRC -i $DIR/audio.wav -map 0:0 -map 1:0 -vcodec copy -acodec libmp3lame -ab 192k -ar 48000 -async 48000 $DIR/$NAME$POST.mp4 > /dev/null 2>&1
    rm $DIR/audio.wav
    if [ -d "$PLAYBOOK" ]; then
            echo "$( $TIME ): Found playbook copying $NAME$POST.mp4"
            cp $DIR/$NAME.mp4 $PLAYBOOK/videos/$NAME$POST.mp4
    fi
    01-20-12 09:16 AM
LINK TO POST COPIED TO CLIPBOARD