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
# 1  
Old 08-29-2011
ffmpeg script to convert all movies in a folder for PSP

Hi all,

I use ffmpeg to convert my movies to play them with my PSP.
I use the terminal version of ffmpeg so i put in the code:
Code:
]ffmpeg -i FILENAAM.avi -f psp -r 29.97 -b 512k -ar 24000 -ab 64k -s 320x240 M4V00001.MP4

FILENAAM is the part i replace with the title of the movie i want to see converted.

Now i was wondering if there is a possibility to make it so that i give a command so ffmpeg will start another conversion when the first one is done.
So it can convert one move after the other.
I would like this so i can put on the command and go to bed, or do some shopping and so the movies i want to convert are all converted after i get home again or wake up.

i found a script on the internet that needed a little adjustment but somewhere its wrong, but i cant find where.

Original script:
Code:
#!/bin/bash
echo "fakap mp3-to-flv converter http://staff.fakap.net/mp3toflv/"
echo "Copyright (c) mypapit 2007"
echo ""
if [ $# -eq 0 ]
then
    echo "Usage: flvto3gp [flv files] ..."
    exit
fi

while [ $# -ne 0 ]
do
        ffmpeg -i $1 -s 176x144 -vcodec h263 -r 28 -b 96k -ab 64 -acodec libfaac -ac 1 -ar 44100 "$1".3gp
    shift
done
echo "Finished fakaping with flv-to-3gp converter"
echo "\"fakap all those nonsense!\""
echo ""

Adjusted script:
Code:
#!/bin/bash
echo "avi-to-MP4 converter"
echo "Original: fakap mp3-to-flv converter http://staff.fakap.net/mp3toflv/"
echo "Copyright (c) mypapit 2007"
echo ""
if [ $# -eq 0 ]
then
    echo "Usage: avitomp4 [mp4 files] ..."
    exit
fi

while [ $# -ne 0 ]
do
        ffmpeg -i $1 -f psp -r 29.97 -b 512k -ar 24000 -ab 64k -s 320x240 "$1".MP4
    shift
done
echo "Finished fakaping with flv-to-3gp converter"
echo "\"fakap all those nonsense!\""
echo ""

who can tell me where i am wrong?

thx
# 2  
Old 08-29-2011
Do you get an error when you run your modified script? If so, please post the error.
# 3  
Old 08-29-2011
i do not get any errors, just terminal that opens and then it closes again before something happens.
so actually what happens is that i run the script, it opens a terminal for a fraction of a second and closes again, without giving any sort of output like error messages, converted files,...)
# 4  
Old 08-29-2011
Are you running it by double clicking the script from your desktop or context-menu->run in terminal from the desktop? That is the only way it will open the terminal and then exit. If that is not the case, post an example on how are you running it.

To run this script. Open a terminal and then run it from the terminal by doing

Code:
./yourscript <list of files to convert>

off course that will work if you made it executable by doing

chmod +x <yourscript>
# 5  
Old 08-29-2011
Thanks

with running it as you say, it seems to work.
only small problem i now have is that the output files have double extention (like moviename.avi.mp4)
how can i make it that the .avi part s left out in the filenames of the outputfiles and only have like moviename.mp4?
# 6  
Old 08-29-2011
Add the below line after "do" in your script:

Code:
newext=$(echo "$1"|sed  's/\.avi//g')

and change your ffmpeg command to:

Code:
ffmpeg -i $1 -f psp -r 29.97 -b 512k -ar 24000 -ab 64k -s 320x240 "$newext".MP4

# 7  
Old 08-30-2011
it works perfect, thx for the help.

Do you know a way that i do not have to type all the names of the movies i want to convert ( <list of files to convert> )
So when i run the script in a certain folder it takes all .avi files that are in that folder to convert them (would save me some work, total is about 200 movies to convert Smilie )
Now i placed 10 movies in a folder and typed their names in the <list of files to convert> so it starts with those 10, but it would be nice not to have to type all the movie titles before converting.




Is there a way that when you execute the script that before it starts converting you first get the question to restart (r), shutdown (s), leave computer on (l)
so after you press r, s or l the conversion starts and then after all is converted the system shuts down or restart or does nothing?
For this i thing about:
[code]echo "When converting is done would you like to Restart (r), Shot down (s) or leave the computer on (l)"
if [r] restart,
if [s] shutdown
if [l] do nothing

but im not a good scripter, so i know the way i put it here will not work (but i dont know the good way)

Last edited by Ditzyken; 08-30-2011 at 08:11 PM.. Reason: added second question
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