|
|||||||||
| Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here. |
learn linux and unix commands - unix shell scripting |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
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 |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Do you get an error when you run your modified script? If so, please post the error.
|
| Sponsored Links | ||
|
|
|
#3
|
||||
|
||||
|
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
|
||||
|
||||
|
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> |
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
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? |
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
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 |
| Sponsored Links | |
|
|
#7
|
||||
|
||||
|
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 )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 07:11 PM.. Reason: added second question |
| Sponsored Links | ||
|
|
![]() |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Automated FFmpeg Convert Bash Script | domz | Shell Programming and Scripting | 6 | 05-20-2010 01:01 AM |
| convert avi to cellphone friendly 320x176 mp4 file...ffmpeg to the rescue :) | mr_manny | Linux | 2 | 12-23-2008 04:26 PM |
| script for Finding files in a folder and copying to another folder | satish2712 | Shell Programming and Scripting | 5 | 09-11-2008 05:07 PM |
|
|