LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   ffmpeg encoding script. error (http://www.linuxquestions.org/questions/linux-newbie-8/ffmpeg-encoding-script-error-865074/)

MystKid 02-25-2011 09:09 PM

ffmpeg encoding script. error
 
hello guys i have been writing a script to encode dvd's to svcd mpg for streaming with an old mpeg2 card. i am getting a syntax error on the script i wrote and i cant find a solution. here is the script:
Code:

#!bin/bash
echo -e '\E[37;44m'"\033[1mDVD to MPG Script\033[0m"
dumpdirectoy="~/dvdrip/vob"
outputdirectory="~/dvdrip/out"

set -e

if [ ! -d "$dumpdirectory" ]; then
        echo "* Making dump directory"
        mkdir -p ~/dvdrip/vob
        mkdir -p ~/dvdrip/out
else
        echo "* "$dumpdirectory" exists. Exiting.
        exit
fi

echo "* Taking a VOB dump"
vobcopy -m -o "$dumpdirectory"

echo "* Re-encoding with FFmpeg"
for vobinput in "$dumpdirectoy"/*.VOB; do ffmpeg -i "$dumpdirectory"/"$vobinput" -target pal-svcd "$outputdirectory"/"${vobinput%.VOB}.mpg"; done
echo -e '\E[47;32m'"\033[1mDone!\033[0m"


mirni 02-25-2011 09:27 PM

Hey there.
To start with, you are missing a slash in shebang line:
#!/bin/bash

Now what is your error exactly?

MystKid 02-25-2011 09:42 PM

i got it sorted. i would like to add a text dialog where i can press 1 to encode each title in its own output and with option 2 to have one file output

MystKid 02-25-2011 11:20 PM

Code:

#!/bin/bash

set -e
echo -e '\E[37;44m\033[1mDVD to MPG Script\033[0m'
dumpdirectoy='~/dvdrip/vob'
outputdirectory='~/dvdrip/out'

read -p "Rip DVD in separate output files or one file (1,2)?" option

if [[ $option == "1" ]]; then
    echo "You chose option 1"
elif [[ $option == "2" ]]; then
    echo "You chose option 2"
else
    echo "You didn't choose a valid option. Exiting!"
    exit
fi

echo "Creating folders"
if [ ! -d "$dumpdirectory" ]; then
        echo '* Making dump directory'
        mkdir -p ~/dvdrip/vob
        mkdir -p ~/dvdrip/out
else
    echo "* $dumpdirectory exists. Exiting."
    exit
fi

echo '* Taking a VOB dump'

if [[ $option == 1 ]]; then   
    vobargs="-m -o"
elif [[ $option == 2 ]]; then
    vobargs="-l -m -o"
fi

vobcopy $vobargs "$dumpdirectory"

echo '* Re-encoding with FFmpeg'

for vobinput in "$dumpdirectoy"/*.{vob,VOB}; do
    ffmpeg -i "$dumpdirectory/$vobinput" -target pal-svcd "$outputdirectory/${vobinput%.VOB}.mpg";
done
echo -e '\E[47;32m\033[1mDone!\033[0m'


MystKid 02-26-2011 09:05 AM

i am still getting an error when executing it. here is the pastebin if anyoen can check it out http://dpaste.com/451661/

larryhaja 02-26-2011 09:32 AM

The problem that I see is that you are using $dumpdirectoy twice in the ffmpeg command line.
Code:

for vobinput in "$dumpdirectoy"/*.{vob,VOB}; do
    ffmpeg -i "$dumpdirectory/$vobinput" -target pal-svcd "$outputdirectory/${vobinput%.VOB}.mpg";
done

I haven't ran this script, but how I interpret the script is that when running the ffmpeg line you are essentially telling ffmpeg that the VOB file is in "~/dvdrip/vob/~/dvdrip/vob/<filename>.vob". You might be running into a similar problem with the output filename as well.

MystKid 02-27-2011 05:13 AM

script fixed and improved. now it has 2 options. rip all titles in one output file or rip all titles in separate output files:
Code:

#!/bin/bash

shopt -s nocaseglob
set -e
echo -e "\E[37;44m\033[1mDVD to MPG Script\033[0m"

ffmpegargs="-target pal-svcd"
format="mpg"
##########Option 3 has still to be finished####################################
dumpdirectory="$HOME/dvdrip/rip"
outputdirectory="$HOME/dvdrip/out"
REQUIREMENTS=${REQUIREMENTS:-"vobcopy ffmpeg"}

type -P $REQUIREMENTS &>/dev/null || { echo "Missing Something ?" >&2; exit 1; }

read -p "Rip DVD as one file or separate files (1,2)?" option

# Option must be a valid integer; numbers lower than 1 or greater than 3 are invalid ...
if [[ $option =~ ^[[:digit:]]+$ ]] && [[ $option -lt 1 ]] || [[ $option -gt 3 ]]; then
    echo -en "You didn't choose a valid option. Exiting! \E[37;31m\033[1mScript By MystKid.\033[0m"
    exit
fi

echo "Creating folders"
rm -rf -- "$dumpdirectory" 2>/dev/null # empty the dump directory beforehand
[[ -d "$dumpdirectory" ]] || mkdir -vp "$dumpdirectory"
[[ -d "$outputdirectory" ]] || mkdir -vp "$outputdirectory"

echo "* Taking a VOB dump"

if [[ $option == "1" ]]; then   
    vobargs="-l -o"
elif [[ $option == "2" ]]; then
    vobargs="-l -m -o"
elif [[ $option == "3" ]]; then
    vobargs="-l -M -o"
fi

vobcopy $vobargs "$dumpdirectory"

echo "* Re-encoding with FFmpeg"

dvdname="$(vobcopy -I 2>&1 | grep DVD-name | sed 's/^.*: //')"
part=1

for vobinput in $(find $dumpdirectory -type f -iname "*.vob")
do
        if [[ $option == "2" ]]; then
                mpgoutput="$outputdirectory/${dvdname}${part}.$format"
        else
                mpgoutput="$outputdirectory/${dvdname}.$format"
        fi

        ffmpeg -i "$vobinput" $ffmpegargs "$mpgoutput"
       
        let part="$part+1"
done

echo -e "\E[47;32m\033[1mDone!\033[0m"
echo -e "\E[37;31m\033[1mScript By MystKid.\033[0m"

#################################By MystKid####################



All times are GMT -5. The time now is 09:03 PM.