ffmpeg script to convert all movies in a folder for PSP


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ffmpeg script to convert all movies in a folder for PSP
# 8  
Old 08-30-2011
Thank you dude2cool,

works as it should.
Converting my movies now

Only question left:
is there a way to make the script so that you dont have to type the names of the moviefiles (let the script take all .avi files automaticly in the folder where the .sh file is in.)
# 9  
Old 08-30-2011
./yourscript *.avi

Or if you really, really want to do that inside the script for some reason, add this as the first line:

Code:
set -- /path/to/dir/*.avi

# 10  
Old 08-30-2011
Quote:
Originally Posted by Corona688
./yourscript *.avi
]
of course, why couldn't i think of that SmilieSmilie

thx

now only one question remains, the restart, shutdown, do nothing question.
# 11  
Old 08-31-2011
Code:
#!/bin/sh

RESTART=""

while true
do
        case "$RESTART" in
        [RrSslL])
                break;
                ;;
        *)      echo "(R)estart, (S)hut down, (L)eave computer on?"
                read RESTART
                ;;
        esac
done

echo "do stuff"
sleep 10

case "$RESTART" in
        [rR])   echo "Finished.  Rebooting."
                echo sudo /sbin/reboot
                ;;

        [sS])   echo "Finished.  Shutting down."
                echo sudo /sbin/poweroff
                ;;

        [lL])   echo "Finished.  Quitting."
                exit 0
                ;;

        *)      echo "How'd this get here?"
                ;;
esac

# 12  
Old 08-31-2011
thank you for this.
I placed this in the existing script.
When i start the script indeed it asks me to restart, shutdown or Leave computer on.µ
When i give in R S or L the script starts converting the movies as it needs to do
after all the converting is done i get following output:
Code:
Finished.  Shutting down.
sudo /sbin/poweroff
koen@Koen-PC ~/Downloads/test $

so it says its going to shutdown (or restart or just quit)
it echo's the command to shutdown or restart or exit
but it does not do the work, it comes back to commandprompt

---------- Post updated at 05:35 PM ---------- Previous update was at 05:01 PM ----------

To clarify previous post, this is the used script:
Code:
#!/bin/sh
RESTART=""

while true
do
        case "$RESTART" in
        [RrSslL])
                break;
                ;;
        *)      echo "(R)estart, (S)hut down, (L)eave computer on?"
                read RESTART
                ;;
        esac
done

echo "do stuff"
sleep 2


echo "CPSP 1.3"
echo "Converting movies (.avi) to .MP4 for PlayStation Portable."
echo ""
echo "Files must be named as M4V00001.avi (adjust 00001 to 00002, 00003, ... for multiple files."
echo ""
echo "Original: fakap mp3-to-flv converter http://staff.fakap.net/mp3toflv/"
echo "Special thanks to dude2cool and Corona688 @ https://www.unix.com/ for helping to put the script together"
if [ $# -eq 0 ]
then
    echo "Input files: *.avi"
    echo "Output files: *.MP4"
    
fi

while [ $# -ne 0 ]
do
newext=$(echo "$1"|sed  's/\.avi//g')
        ffmpeg -i $1 -f psp -r 29.97 -b 512k -ar 24000 -ab 64k -s 320x240 "$newext".MP4
    shift
done
echo ""
echo "CPSP has finished converting the files."
echo "Thank you for using CPSP 1.3"
echo "bye bye"
echo ""
case "$RESTART" in
        [rR])   echo "Finished.  Rebooting."
                echo sudo /sbin/reboot
                ;;

        [sS])   echo "Finished.  Shutting down."
                echo sudo /sbin/poweroff
                ;;

        [lL])   echo "Finished.  Quitting."
                exit 0
                ;;

        *)      echo "How'd this get here?"
                ;;
esac

This is the output i get:
Code:
koen@Koen-PC ~/Downloads/test $ ./CPSP.sh *.avi
(R)estart, (S)hut down, (L)eave computer on?
r
do stuff
CPSP 1.3
Converting movies (.avi) to .MP4 for PlayStation Portable.

Files must be named as M4V00001.avi (adjust 00001 to 00002, 00003, ... for multiple files.

Original: fakap mp3-to-flv converter http://staff.fakap.net/mp3toflv/
Special thanks to dude2cool and Corona688 @ https://www.unix.com/ for helping to put the script together

FFmpeg version 0.6.2-4:0.6.2-1ubuntu1, Copyright (c) 2000-2010 the Libav developers
  built on Mar 22 2011 15:35:22 with gcc 4.5.2
  ...
  ...
  Some info about ffmpeg (cutted to save some space)
  ...
  ...
  libavutil     50.15. 1 / 50.15. 1
  libavcodec    52.72. 2 / 52.72. 2
  libavformat   52.64. 2 / 52.64. 2
  libavdevice   52. 2. 0 / 52. 2. 0
  libavfilter    1.19. 0 /  1.19. 0
  libswscale     0.11. 0 /  0.11. 0
  libpostproc   51. 2. 0 / 51. 2. 0

Input #0, avi, from 'dmd-nda-sample.avi':
  Duration: 00:01:29.71, start: 0.000000, bitrate: 2630 kb/s
    Stream #0.0: Video: mpeg4, yuv420p, 624x352 [PAR 1:1 DAR 39:22], 23.98 tbr, 23.98 tbn, 23.98 tbc
    Stream #0.1: Audio: mp3, 48000 Hz, 2 channels, s16, 128 kb/s
Output #0, psp, to 'dmd-nda-sample.MP4':
  Metadata:
    encoder         : Lavf52.64.2
    Stream #0.0: Video: mpeg4, yuv420p, 320x240 [PAR 117:88 DAR 39:22], q=2-31, 512 kb/s, 2997 tbn, 29.97 tbc
    Stream #0.1: Audio: aac, 24000 Hz, 2 channels, s16, 64 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
Press [q] to stop encoding
[mpeg4 @ 0x9ff9680]Invalid and inefficient vfw-avi packed B frames detected  
frame=    7 fps=  4 q=2.0 size=      18kB time=0.23 bitrate= 630.2kbits/s dup=1 frame=   17 fps=  8 q=2.0 size=      50kB time=0.57 bitrate= 721.1kbits/s dup=3 frame=   27 fps= 10 q=2.0 size=      72kB time=0.90 bitrate= 653.2kbits/s dup=5 frame=   41 fps= 13 q=2.0 size=      96kB time=1.37 bitrate= 574.1kbits/s dup=8 frame=   54 fps= 14 q=2.0 size=     139kB time=1.80 bitrate= 632.1kbits/s dup=11frame=   76 fps= 18 q=2.0 size=     208kB time=2.54 bitrate= 670.5kbits/s dup=15frame=   86 fps= 18 q=2.0 size=     247kB time=2.87 bitrate= 703.8kbits/s dup=17frame=   96 fps= 18 q=2.5 size=     277kB 
...
...
...
A bunch of converting steps
...
...
...
74 fps= 14 q=14.0 size=    6398kB time=89.22 bitrate= 587.5kbits/s dup=frame= 2689 fps= 14 q=14.9 Lsize=    6478kB time=89.72 bitrate= 591.4kbits/s dup=538 drop=0    
video:5778kB audio:660kB global headers:0kB muxing overhead 0.617032%

CPSP has finished converting the files.
Thank you for using CPSP 1.3
bye bye

Finished.  Rebooting.
sudo /sbin/reboot
koen@Koen-PC ~/Downloads/test $

# 13  
Old 08-31-2011
You need to read the code given to you, not just copy it. Look at this line, and see what it dies:
Code:
echo sudo /sbin/reboot

...well, I didn't want to reboot my computer after all.
# 14  
Old 08-31-2011
stupid me...
remove the echo's before you try it (me and scripting,...)


Now it gives the command as it should be.

problem is that it asks for the sudo password after the converting (when i supposed to be AFK)
Is there a way to let the script ask the sudo password after the selection to shutdown or restart so you get output like
Code:
koen@Koen-PC ~ $ cd Downloads/test
koen@Koen-PC ~/Downloads/test $ ./CPSP.sh *.avi
(R)estart, (S)hut down, (L)eave computer on?
r
Enter sudo password to shutdown or restart after the conversion completes      <== when i choose R or S
password:
do stuff

(fat text is new part, non fat is what i am trying to explain)

i am 100% sure it would be:
Code:
echo"Enter sudo password to shutdown or restart after the conversion completes"

but then it must ask for the password and execute the restart/shutdown after the converting is finished

i know i ask alot, but like i said, me and scripting...


i found a way with editing sudoers file with visudo, so it don't need to give the password, but i hope there is a way to have it like described above (asking password after selecting reboot/shutdown and then first run the conversion and after converting doing the shutdown or reboot)

Last edited by Ditzyken; 08-31-2011 at 10:47 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies

2. Shell Programming and Scripting

Script to move one folder to multiple folder...

Hi All, I have to requirement to write a shell script to move file from one folder (A) to another five folder (B,C,D,E,F) and destination folder should be blank. In not blank just skip. This script will run as a scheduler every 2 minutes. It will check number of files in folder A and move 1 to... (9 Replies)
Discussion started by: peekuabc
9 Replies

3. Red Hat

Problem installing PSP on rhel 5.2 64

hi, i have a problem when i try to install Proliant support pack into a server with rhel 5.2 sv556:#/tmp/psp# ./hpsum -silent ./hpsum: error while loading shared libraries: libfreetype.so.6: cannot open shared object file: No such file or directory i have already installed library... (3 Replies)
Discussion started by: pabloli150
3 Replies

4. Shell Programming and Scripting

Convert all files in current folder from UTF8 to ANSI, name unchanged.

Asking for a Linux command line to convert all files in current folder from UTF8 to ANSI, name unchanged. Best Regards Pei (3 Replies)
Discussion started by: jiapei100
3 Replies

5. Shell Programming and Scripting

Automated FFmpeg Convert Bash Script

I need a bash script that will. So here is what I made so far. 1. Convert video files to iPhone format 2. MV converted video to new directory (with domain.com attached to it) 4. Copy a NFO file (from another directory) and add some conversion information 5. Delete old directory torrent... (6 Replies)
Discussion started by: domz
6 Replies

6. Linux

convert avi to cellphone friendly 320x176 mp4 file...ffmpeg to the rescue :)

found a few ffmpeg posts and after a few unsuccessful attempts, I have found a solution :) to encode an avi to to an nokia e71 recognized mp4 format: ffmpeg -y -i inputFILE.avi -acodec aac -ab 72k -s 320x176 -aspect 16:9 -vcodec h264 -b 300k -qcomp 0.6 -qmin 16 -qmax 51 -qdiff 4 -flags +loop... (2 Replies)
Discussion started by: mr_manny
2 Replies

7. Shell Programming and Scripting

script for Finding files in a folder and copying to another folder

Hi all, I have a folder '/samplefolder' in which i have some files like data0.txt, data1.txt and data2.txt. I have to search the folder for existence of the file data0.txt first and if found have to copy it to some other file; next i have to search the folder for existence of file... (5 Replies)
Discussion started by: satish2712
5 Replies

8. Shell Programming and Scripting

here-doc convert 2 script convert to single script?

I have my main script calling another script to retrive a "ls -alt" of a directory that's located in a remote location I'm sftping into. main.sh #!/bin/ksh getLS.sh > output.txt getLS.sh #!/bin/sh /home<..>/sftp <host@ip> <<! cd /some/dir/Log ls -alt quit ! Basically I'd like to be... (2 Replies)
Discussion started by: yongho
2 Replies
Login or Register to Ask a Question