LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 02-25-2011, 08:09 PM   #1
MystKid
Member
 
Registered: Dec 2010
Posts: 51

Rep: Reputation: 0
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"

Last edited by MystKid; 02-25-2011 at 08:10 PM.
 
Old 02-25-2011, 08:27 PM   #2
mirni
LQ Newbie
 
Registered: Nov 2008
Location: pacific
Distribution: CentOS, openSuse, Ubuntu
Posts: 12

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

Now what is your error exactly?
 
Old 02-25-2011, 08:42 PM   #3
MystKid
Member
 
Registered: Dec 2010
Posts: 51

Original Poster
Rep: Reputation: 0
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
 
Old 02-25-2011, 10:20 PM   #4
MystKid
Member
 
Registered: Dec 2010
Posts: 51

Original Poster
Rep: Reputation: 0
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'
 
Old 02-26-2011, 08:05 AM   #5
MystKid
Member
 
Registered: Dec 2010
Posts: 51

Original Poster
Rep: Reputation: 0
i am still getting an error when executing it. here is the pastebin if anyoen can check it out http://dpaste.com/451661/
 
Old 02-26-2011, 08:32 AM   #6
larryhaja
Member
 
Registered: Jul 2008
Distribution: Slackware 13.1
Posts: 292

Rep: Reputation: 75
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.
 
Old 02-27-2011, 04:13 AM   #7
MystKid
Member
 
Registered: Dec 2010
Posts: 51

Original Poster
Rep: Reputation: 0
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####################
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] ffmpeg psp encoding woes (with a solution!) allstarzero Linux - Software 6 08-10-2013 03:09 PM
[SOLVED] Using ffmpeg to convert to .mov with h264 encoding. crosstalk Linux - Desktop 3 02-18-2011 12:36 AM
ffmpeg encoding wmv3 audio+video to flv fylnq Linux - Software 15 02-24-2010 04:15 AM
ffmpeg encoding help SentralOrigin Linux - Software 5 04-23-2008 10:35 AM
ffmpeg - psp [] Need help encoding to mp4 nomb Linux - Software 7 01-08-2007 07:42 PM


All times are GMT -5. The time now is 08:45 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration