Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 19
I want to use the command Code: mencoder /home/bob/test.avi -of mpeg -vf scale=720:480,harddup -oac lavc -ovc lavc -lavcopts acodec=ac3:abitrate=192:vcodec=mpeg2video:keyint=25:vbitrate=5000:aspect=4/3 -mpegopts format=dvd -srate 48000 -ofps 30000/1001 -o /home/bob/tv1.mpg but instead of ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Engineer spencerf's Avatar
    Join Date
    Jan 2005
    Location
    Syracuse, NY
    Posts
    1,144

    automating command mencoder (SOLVED)


    I want to use the command
    Code:
    mencoder /home/bob/test.avi -of mpeg -vf scale=720:480,harddup -oac lavc -ovc lavc -lavcopts acodec=ac3:abitrate=192:vcodec=mpeg2video:keyint=25:vbitrate=5000:aspect=4/3 -mpegopts format=dvd -srate 48000 -ofps 30000/1001 -o /home/bob/tv1.mpg

    but instead of test.avi and tv1.mpg I want it to automatically find all avi's in a certain directory and then name them the same when it converts to mpg. So for example if I have file: 1.avi, 2.avi, 3.avi and so on I want it to convert these and then name them 1.mpg, 2.mpg, and 3.mpg.

    So I think I just want to set up a simple script to do this. But I don't know how exactly. I set up the script to let me just run this command listed above so I don't have to type it in everytime but I have change the names of the files everytime I want to use it. I want it to automatically find the avi and turn them into mpg with proper naming. Any help would be greatly appreciated. Thanks a lot.
    All right, brain. You don't like me and I don't like you, but let's just do this and I can get back to killing you with beer. All New Users Read This!!! If you have a grub problem please look at GRUB MANUAL

  2. #2
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035

    Re: automating command mencoder

    Code:
    #!/bin/bash
    if [ $# -eq 1 ]
    then
    dir="$1"
    else
    dir="$PWD"
    fi
    cd $dir
    for file in *.avi
    do
    mencoder $file -of mpeg -vf scale=720:480,harddup -oac lavc -ovc lavc -lavcopts acodec=ac3:abitrate=192:vcodec=mpeg2video:keyint=25:vbitrate=5000:aspect=4/3 -mpegopts format=dvd -srate 48000 -ofps 30000/1001 -o ${file%%avi}mpg

  3. #3
    Linux Engineer spencerf's Avatar
    Join Date
    Jan 2005
    Location
    Syracuse, NY
    Posts
    1,144
    I tried this and then did chmod +x and then ran script and it gives me this error:

    ./MENCODER SCRIPT: line 12: syntax error: unexpected end of file

    I of course names it MENCODER SCRIPT

    Might just be some stupid mistake I don't know though. The only change I made was make the whole mencoder portion one line because that is how I had it setup originally.
    All right, brain. You don't like me and I don't like you, but let's just do this and I can get back to killing you with beer. All New Users Read This!!! If you have a grub problem please look at GRUB MANUAL

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    Try:

    Code:
    #!/bin/bash
    if [ $# -eq 1 ]
    then
    dir="$1"
    else
    dir="$PWD"
    fi
    cd $dir
    for file in *.avi
    do
    mencoder $file -of mpeg -vf scale=720:480,harddup -oac lavc -ovc lavc -lavcopts acodec=ac3:abitrate=192:vcodec=mpeg2video:keyint=25:vbitrate=5000:aspect=4/3 -mpegopts format=dvd -srate 48000 -ofps 30000/1001 -o ${file%%avi}mpg
    done
    He forgot the "done" at the end, methinks.

  6. #5
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    Yeah I forgot the done. That and try naming the script without spaces

  7. #6
    Linux Engineer spencerf's Avatar
    Join Date
    Jan 2005
    Location
    Syracuse, NY
    Posts
    1,144
    thanks I'll try this when I get home tonight.
    All right, brain. You don't like me and I don't like you, but let's just do this and I can get back to killing you with beer. All New Users Read This!!! If you have a grub problem please look at GRUB MANUAL

  8. #7
    Linux Engineer spencerf's Avatar
    Join Date
    Jan 2005
    Location
    Syracuse, NY
    Posts
    1,144
    now I'm getting this error:

    Code:
    MEncoder 1.0pre7-3.3.5-20050130 (C) 2000-2005 MPlayer Team
    CPU: Advanced Micro Devices Athlon MP/XP Thoroughbred (Family: 6, Stepping: 1)
    Detected cache-line size is 64 bytes
    CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 0
    Compiled for x86 CPU with extensions: MMX MMX2 3DNow 3DNowEx SSE
    
    File not found: 'frameno.avi'
    Failed to open frameno.avi
    File not found: 'That'
    Failed to open That
    Cannot open file/device.
    I don't know why it's looking for frameno.avi?
    or what "That" is?

    [/quote]
    All right, brain. You don't like me and I don't like you, but let's just do this and I can get back to killing you with beer. All New Users Read This!!! If you have a grub problem please look at GRUB MANUAL

  9. #8
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    What did you type, exactly?

  10. #9
    Linux Engineer spencerf's Avatar
    Join Date
    Jan 2005
    Location
    Syracuse, NY
    Posts
    1,144
    I put this command in a file entitled CONVERT I used nano to make the file CONVERT

    Code:
    #!/bin/bash
    if [ $# -eq 1 ]
    then
    dir="$1"
    else
    dir="$PWD"
    fi
    cd $dir
    for file in *.avi
    do
    mencoder $file -of mpeg -vf scale=720:480,harddup -oac lavc -ovc lavc -lavcopts acodec=ac3:abitrate=192:vcodec=mpeg2video:keyint=25:vbitrate=5000:aspect=4/3 -mpegopts format=dvd -srate 48000 -ofps 30000/1001 -o ${file%%avi}mpg
    done
    except the line starting with "mencoder" and ending with ${file%%avi}mpg I put all on one line.

    I then did chmod +x CONVERT
    then
    ./CONVERT
    All right, brain. You don't like me and I don't like you, but let's just do this and I can get back to killing you with beer. All New Users Read This!!! If you have a grub problem please look at GRUB MANUAL

  11. #10
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    What are the contents of the directory?

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •