Results 1 to 4 of 4

Thread: Creat a batch script to reencode video for PSP and rename the files

  1. #1
    Join Date
    Aug 2006
    Location
    USA, MI
    Beans
    232
    Distro
    Ubuntu 13.04 Raring Ringtail

    Thumbs up Need help creating a script to reencode video files and name them in large batches.

    I have never done any scripting ever. But I want to reencode some old movies to play on my PSP and to name them accordingly.

    So I can rename all the files and have PSP in the name so I know it's for my PSP.

    I have been using Avidemux GUI to do it until now but I have to go one by one. I want to do all of them in one night while I sleep.

    Anyone have any idea on how this can be done? Links to howtos would be cool too.

    I want to learn this stuff.
    Thankyou for your time,
    Drezliok
    Last edited by Drezliok; December 1st, 2008 at 04:18 AM. Reason: Retitled

  2. #2
    Join Date
    Aug 2006
    Location
    USA, MI
    Beans
    232
    Distro
    Ubuntu 13.04 Raring Ringtail
    If this thread is in the wrong section could I get a mod to move it?

    Yes I am doing a small bump.

  3. #3
    Join Date
    Aug 2006
    Location
    USA, MI
    Beans
    232
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: Creat a batch script to reencode video for PSP and rename the files

    I have never needed to bump my threads up 2 times.

    Any and all help is appreciated.

  4. #4
    Join Date
    May 2008
    Location
    Canada
    Beans
    75
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: Creat a batch script to reencode video for PSP and rename the files

    I found this. sounds like what you want.

    However, in order to get this to work, I had to switch the acodec=aac option to acodec=libfaac, which if I'm not mistaken, requires "libfaac0" (sudo apt-get install mencoder libfaac0).

    In the end, the command looks like this:
    Code:
    mencoder -ofps 30000/1001 -af lavcresample=24000 -vf harddup -of lavf \
        -oac lavc -ovc lavc -lavcopts aglobal=1:vglobal=1:vcodec=mpeg4:acodec=libfaac \
        -lavfopts format=psp \
        input.video -o output.psp
    To make a script to automate this for multiple files:
    Code:
    #!/bin/bash
    
    # In case user forgets to input file names
    if [ $# -eq 0 ]
            echo "USAGE: avi2psp <FILE(S)>";
            exit 1;
    fi
    
    # For each input file
    for FILE in "$@"
    do
            mencoder -ofps 30000/1001 -af lavcresample=24000 -vf harddup -of lavf \
            -oac lavc -ovc lavc -lavcopts aglobal=1:vglobal=1:vcodec=mpeg4:acodec=libfaac \
            -lavfopts format=psp $FILE -o ${FILE%.[^.]*}.psp
    done
    If you're new to shell scripting, the backslashes ("\") allow a command to run over more than one line, "$@" creates a strings of all the input arguments, which in this case will be the input files that the for loop cycles through, and the whole "${FILE%.[^.]*}" expression removes the extension from the file currently being processed so it can be replaced with ".psp" (I can't guarantee it will work perfectly in every case).

    Also, don't forget to give the script executable permissions:
    Code:
    chmod +x avi2psp
    Then you can run it:
    Code:
    ./avi2psp video1 video2 etc
    Last edited by cyfur01; December 29th, 2008 at 10:03 AM.

Tags for this Thread

Bookmarks

Posting Permissions

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