Register
It is currently Thu Jul 31, 2014 9:44 pm

mencoder, i know, again


All times are UTC - 6 hours


Post new topic Reply to topic  [ 7 posts ] 
Author Message
 PostPosted: Mon Jun 20, 2011 4:47 pm   

Joined: Thu May 26, 2011 7:46 pm
Posts: 7
I've been researching and i can not seem to be able to figure this out. i want to make a simple mencoder command into a function so i just put <function anme> <file name> and have it go from there. my ideal goal is to get it to accept wildcards so it can be let loose on an entire directory. here is the command

mencoder <inputfil.*> -ovc xvid -oac mp3lame -xvidencopts bitrate=1100 -lameopts abr:br=131 -o <outputfile.avi>


Top
 Profile  
 PostPosted: Mon Jun 20, 2011 7:04 pm   
User avatar

Joined: Wed Jun 08, 2011 8:27 am
Posts: 189
Location: outer Shpongolia
Code:
xvidenc() {
    if (($# != 1)); then
        printf 'usage: <(filename|'dirname/*')>\n' >&2
        return 1
    fi 
   
    for f in $1; do 
        mencoder "$f" \
                 -ovc xvid \
                 -oac mp3lame \
                 -xvidencopts bitrate=1100 \
                 -lameopts abr:br=131 \
                 -o "${f%.*}.avi"
    done
}


Don't forget to at least quote the glob that follows the directory name.


Top
 Profile  
 PostPosted: Mon Jun 20, 2011 8:15 pm   

Joined: Thu May 26, 2011 7:46 pm
Posts: 7
wow, thanks a ton:
EDIT:
this doesn't seem to be doing the trick, but it seems to be my command not your script


Top
 Profile  
 PostPosted: Tue Jun 21, 2011 6:56 am   
User avatar

Joined: Wed Jun 08, 2011 8:27 am
Posts: 189
Location: outer Shpongolia
v2 : you don't have to quote the glob that follows the directory name.

Code:
xvidenc() {
    if ((! $#)); then
        printf 'usage: <(filename|dirname/*)>\n' >&2
        return 1
    fi
   
    for f; do
        mencoder "$f" \
                 -ovc xvid \
                 -oac mp3lame \
                 -xvidencopts bitrate=1100 \
                 -lameopts abr:br=131 \
                 -o "${f%.*}.avi"
    done
}


It's not a script, but a function declaration.
Can you please post the command you used? What makes you think it isn't working?
Are you for sure using bash(1)?


Top
 Profile  
 PostPosted: Tue Jun 21, 2011 8:01 am   

Joined: Thu May 26, 2011 7:46 pm
Posts: 7
the command was in the first post, and yes, function, my bad. I found that when used on a file that was is already in the container format *.avi it causes the file to be re sized to 80K and made useless. I fixed that by adding .new.avi to the output file name. but that is a quirk of mencoder, happens even when running it manually.


Top
 Profile  
 PostPosted: Tue Jun 21, 2011 12:06 pm   
User avatar

Joined: Wed Jun 08, 2011 8:27 am
Posts: 189
Location: outer Shpongolia
If I understand correctly, you want the function not to process AVI files, right?
Then you can just add another statement that checks whether the files end by « .avi » before processing them.

v3 : checks whether the files are AVI before processing.

Code:
xvidenc() {
    if ((! $#)); then
        printf 'usage: <(filename|dirname/*)>\n' >&2
        return 1
    fi
   
    for f; do
        if [[ $f = *.avi ]]; then
            continue
        fi
       
        mencoder "$f" \
                 -ovc xvid \
                 -oac mp3lame \
                 -xvidencopts bitrate=1100 \
                 -lameopts abr:br=131 \
                 -o "${f%.*}.avi"
    done
}


Top
 Profile  
 PostPosted: Wed Jun 22, 2011 4:04 pm   

Joined: Thu May 26, 2011 7:46 pm
Posts: 7
no, it should be doing its work on avi files as well, but mencoder was not handling an output file with the same name as input, so i did this to compensate

Code:
xvidenc() {
    if ((! $#)); then
        printf 'usage: <(filename|dirname/*)>\n' >&2
        return 1
    fi
   
    for f; do
        mencoder "$f" \
                 -ovc xvid \
                 -oac mp3lame \
                 -xvidencopts bitrate=1100 \
                 -lameopts abr:br=131 \
                 -o "${f%.*}.xbox.avi"
    done
}


this makes it possible to stream files to either the xbox360 or PS3 using ushare


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP