LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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 06-18-2006, 08:59 PM   #1
lpn1160
Member
 
Registered: May 2004
Location: USA
Distribution: pclinuxos
Posts: 37

Rep: Reputation: 15
improving my script


I have a ton of .mkv files.The video is mostly xvid with ogg audio. I recently purchased a dvd player that plays mpeg4 files. I want to convert them all so I can burn onto a dvd and play them on T.V. I wrote a very simple shell script, however I can only process one file at a time & I must manually re-name the files afterwards. I would like to process a whole directory at one time but my scripting skills after only several months on Linux is lacking (to say the least).So any help, tips explanations, or whatever are greatly appreciated. I tried but still don't have the hang of it. Here's the script I did write which works just fine.

#!/bin/bash

mkvextract tracks *.mkv 1:video.avi 2:audio.ogg && oggdec *.ogg && lame --abr 128 audio.wav audio.mp3 && mencoder video.avi -ovc copy -oac copy -audiofile audio.mp3 -o ghrest.avi && exit
 
Old 06-19-2006, 10:34 AM   #2
angel115
Member
 
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 494

Rep: Reputation: 75
Hi lpn1160

I can help you but i need more information, like in your command line can you give me an exemple of where is you input file and where are the output file

IE: in Green all input files and in Red all output file
Code:
mkvextract tracks *.mkv 1:video.avi 2:audio.ogg && oggdec *.ogg && lame --abr 128 [COLOR="rgb(139, 0, 0)"]audio.wav audio.mp3[/COLOR] && mencoder video.avi -ovc copy -oac copy -audiofile audio.mp3 -o ghrest.avi && exi
PS: could you add a small description of what each command does.

Regards,
Angel.
 
Old 06-19-2006, 01:38 PM   #3
lpn1160
Member
 
Registered: May 2004
Location: USA
Distribution: pclinuxos
Posts: 37

Original Poster
Rep: Reputation: 15
First off Thank you very much for responding. Basically what I do is put the file i wish to convert in a separate temp directory. They are video files with xvid or divx video & ogg vorbis audio. I use the wild card *.mkv which is the extension on all the files I want to convert, i use the wild card so I don't have to change the shell script to use the actual file name all the time.
mkvextract rips out the video and audio files to separate files. oggdec converts the ogg audio file to a .wav file, lame converts the audio .wav file to an .mp3 file. Then mencoder takes the extracted video only and muxes it together with the new .mp3 file to give me the final output .avi file. I wanted to try and run on a directory with several files at once using the input file name and having the final output file with the same name example:
the_green_hornet.mkv -> the_green_hornet.avi all the other files are just temp files to get to the final output. Have tweaked my script to remove them using rm video.avi rm audio.ogg etc

Thank you very much for any and all assistance

Last edited by lpn1160; 06-19-2006 at 01:40 PM.
 
Old 06-19-2006, 02:28 PM   #4
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
I think you should use something like the following loop:
Code:
#! /bin/bash
for NAME in *.mkv
do
  BASE=$(basename $NAME .mkv)
  mkvextract tracks $NAME 1:$BASE.avi 2:$BASE.ogg
  [...]
done
You can probably figure out how to complete the loop yourself. During each cycle, the current file's name can be referred to as $NAME (which ends with ".mkv"), and $BASE is the filename with ".mkv" removed.
Here I assume that the .mkv files are located in your current directory and the filenames don't contain space characters.
 
Old 06-19-2006, 09:09 PM   #5
lpn1160
Member
 
Registered: May 2004
Location: USA
Distribution: pclinuxos
Posts: 37

Original Poster
Rep: Reputation: 15
Sorry to bump the topic, however I just wanted to publicly Thank those who responded and helped. It worked perfect !!!
final code I am using

#! /bin/bash

for NAME in *.mkv
do
BASE=$(basename $NAME .mkv)
mkvextract tracks $NAME 1:video.avi 2:$BASE.ogg && oggdec $BASE.ogg -o $BASE.wav && rm $BASE.ogg && lame --abr 128 $BASE.wav audio.mp3 && rm $BASE.wav && mencoder video.avi -ovc copy -oac copy -audiofile audio.mp3 -o $BASE.avi && rm video.avi && rm audio.mp3

done

thank you all again !!!!!!

Last edited by lpn1160; 06-19-2006 at 09:53 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
Improving the startx script Woodsman Slackware 14 11-05-2005 09:08 AM
Anyone up for Improving Lsongs? dissonanz Linux - Software 1 10-26-2004 07:24 PM
Help improving a textfile blubbfish Linux - Newbie 2 06-22-2004 09:02 AM
improving 3d performance ababkin Linux - Hardware 1 04-09-2004 12:33 AM
Improving hd performance psyklops Linux - General 2 08-21-2003 09:19 PM


All times are GMT -5. The time now is 02:15 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