LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-17-2009, 03:24 PM   #1
rootoutcast
LQ Newbie
 
Registered: Dec 2008
Posts: 7

Rep: Reputation: 0
trouble with my first bash script


Hi I am righting a script to use mencoder to convert videos the menu is giving my trouble it runs throw the menu options and closes the script



#!/bin/bash
VAR="files.txt"
DIR="srcdir"


clear
echo "Make The TV"
echo "********************************"
echo "MENU "
echo "*******************************"
echo "1. Video to xvid (1 pass )"
echo "2. wmv two xvid (2 pass encoding)"
echo "3. Video to flv (for the web)"
echo "4. Video to NTSC_DVD "
read yourch
echo "$yourch"
echo "Enter Video Directory"
read $srcdir
cd "$srcdir"
touch $VAR
find $srcdir > $VAR



case $yourch in

"$yourch != 1" )
xvid
;;

"$yourch != 2" )
wmv
;;
"$yourch != 3" )
flv
;;

"$yourch != 4" )
dvd
;;

esac


xvid () {
# Collect the files in the current directory
cat $VAR | while read line; do
# Loop read the filenames from the file
INPUT=$(echo ${line})
# Grab the nxt new filename
OUTPUT=${INPUT%.*i}
# Append new extension
OUTPUT+=".avi1"
# Convert files
mencoder "$INPUT" -ovc xvid -oac mp3lame -xvidencopts fixed_quant=4 -o "$OUTPUT"
done

}


wmv () {
# Collect the files in the current directory
cat $VAR | while read line; do
# Loop read the filenames from the file
INPUT=$(echo ${line})
# Grab the nxt new filename
OUTPUT=${INPUT%.*i}
# Append new extension
OUTPUT+=".avi1"
# Convert files
mencoder "$INPUT" \
-ofps 23.976 \
-oac mp3lame \
-ovc xvid \
-xvidencopts pass=1 -o /dev/null

mencoder "$INPUT" \
-ofps 23.976 \
-oac mp3lame \
-ovc xvid \
-xvidencopts pass=2:bitrate=250 \
-o "$OUTPUT"

done

}


flv () {
# Collect the files in the current directory
cat $VAR | while read line; do
# Loop read the filenames from the file
INPUT=$(echo ${line})
# Grab the nxt new filename
OUTPUT=${INPUT%.*v}
# Append new extension
OUTPUT+=".flv"
# Convert files
ffmpeg -i "$INPUT" -ab 256 "$OUTPUT"
done

}


dvd () {
# Collect the files in the current directory
cat $VAR | while read line; do
# Loop read the filenames from the file
INPUT=$(echo ${line})
# Grab the nxt new filename
OUTPUT=${INPUT%.*g}
# Append new extension
OUTPUT+=".mpg"
# Convert files
ffmpeg -i "$INPUT" -target ntsc-dvd "$OUTPUT"
done

}

#clean up after the script has run
rm $VAR # Remove the text file with the file names
 
Old 11-17-2009, 03:52 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
The first thing I notice is "$" where it does not belong....

For variables:

read name
echo $name

For files:
touch filename
echo "stuff" > filename

Please put code into [code] tags for better readability
 
Old 11-17-2009, 04:13 PM   #3
rootoutcast
LQ Newbie
 
Registered: Dec 2008
Posts: 7

Original Poster
Rep: Reputation: 0
ok thanks
 
Old 11-17-2009, 11:17 PM   #4
rootoutcast
LQ Newbie
 
Registered: Dec 2008
Posts: 7

Original Poster
Rep: Reputation: 0
Hi I finished the script for the most part when I convert wmv files to xvid I get audio skipping and sync problems any ideas?

Code:
 

#!/bin/bash
VAR="files.txt"
DIR="srcdir"


xvid () {
touch $VAR
ls *.avi | sort > $VAR
# Collect the files in the current directory
cat $VAR | while read line; do  
# Loop read the filenames from the file
  INPUT=$(echo ${line}) 
# Grab the nxt new filename
  OUTPUT=${INPUT%.*i} 
# Append new extension
  OUTPUT+=".avi1" 
# Convert files 
mencoder "$INPUT" -ovc xvid -oac mp3lame -xvidencopts fixed_quant=4 -o "$OUTPUT"
done

}


wmv () {
touch $VAR
ls *.wmv | sort > $VAR
# Collect the files in the current directory
cat $VAR | while read line; do
# Loop read the filenames from the file
  INPUT=$(echo ${line})
# Grab the nxt new filename
  OUTPUT=${INPUT%.*i}
# Append new extension
  OUTPUT+=".avi1"
  # Convert files 

mencoder "$INPUT" -ovc xvid -oac mp3lame -xvidencopts fixed_quant=4 -o "$OUTPUT"

done

}


flv () {
touch $VAR
ls *.avi | sort > $VAR
# Collect the files in the current directory
cat $VAR | while read line; do
# Loop read the filenames from the file
  INPUT=$(echo ${line})
# Grab the nxt new filename
  OUTPUT=${INPUT%.*v}
# Append new extension
  OUTPUT+=".flv"
  # Convert files 
ffmpeg -i "$INPUT" -ab 256 "$OUTPUT"
done

}


dvd () {
touch $VAR
ls *.avi | sort > $VAR
# Collect the files in the current directory
cat $VAR | while read line; do
# Loop read the filenames from the file
  INPUT=$(echo ${line})
# Grab the nxt new filename
  OUTPUT=${INPUT%.*g}
# Append new extension
  OUTPUT+=".mpg"
  # Convert files 
ffmpeg -i "$INPUT" -target ntsc-dvd "$OUTPUT"
done

}



clear
echo "************************"
echo "* Mike The TV *"
echo "************************"
echo "* [a] Video to xvid (1 pass ) *"
echo "* [b] wmv to xvid (2 pass ) *"
echo "* [c] Video to flv (for the web) *"
echo "* [d] Video to NTSC_DVD  *"
echo "************************"
echo -n "Enter your menu choice [a-d]: "
read yourch
case $yourch in
a) xvid ;;
b) wmv  ;;
c) flv  ;;
d) dvd  ;;

esac


#clean up after the script has run
rm $VAR # Remove the text file with the file names

Last edited by rootoutcast; 11-17-2009 at 11:22 PM.
 
Old 11-17-2009, 11:25 PM   #5
xaler
LQ Newbie
 
Registered: May 2009
Location: the zero world
Distribution: F11, U9.04, Gentoo
Posts: 20

Rep: Reputation: 1
No...no....

Add it this way...

"[-code-]"
some shell script code in between...
"[-/-CODE-]"
(Remove the 4 quotes and the 5 hyphens above)

when you click on "reply with quote", click on the icon with the hash symbol...hope u get it...

Last edited by xaler; 11-17-2009 at 11:39 PM.
 
  


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
Trouble with making a bash script to read in different files and rename output files. rystke Linux - Software 1 05-07-2009 08:00 AM
Trouble With FOR Loop In Simple Bash Script sudleyplace Linux - Newbie 7 03-12-2008 04:55 AM
[bash] having trouble debugging this bash script. jons Programming 4 02-08-2007 06:51 AM
bash script causes trouble with cron Suinatsa Programming 10 06-14-2006 03:20 AM
Trouble with a basic bash script Tengil Linux - Newbie 5 03-04-2004 12:59 PM


All times are GMT -5. The time now is 04:32 PM.

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