FFMPEG Mass Conversion Question
Hello, i'm a new member here, I hate to start out on a forum by asking a question however I came across this forum and hopefully I can maybe find some help from some Linux experts!
If anyone can help me, it'll be greatly appreciated. I'm currently using the following command to convert my avi's to flv's through my server: Code:
ffmpeg -i "INPUT.avi" -y -f flv -ar 44100 -ab 64 -ac 1 -acodec mp3 "OUTPUT.flv" So basically my question is, does anyone know a command to mass convert all files in a certain directory to FLV? Instead of doing them one at a time? Thanks for any help, and thanks for your time. James. |
Quote:
#### beginning of script, cut and paste below this line #### #!/bin/sh cd the_directory_where_are_stored your_avi_files find *.avi | while read f do input="$f" output="${f%.*}.flv" ffmpeg -i "$input" -y -f flv -ar 44100 -ab 64 -ac 1 -acodec mp3 "$output" done #### end of cut and paste ###### your output files will have the same name as the input file but a different extension (flv instead of avi) |
Edit: Thanks the script worked, but it only converted one file.
|
If the only thing in the directory is the .avi files you want to convert:
Code:
#/usr/bin/env bash Of course, all the usual disclaimers about bashscripts apply, but this is basically a very slight modification to the script I use to convert mp3s to ogg files and move them to my personal music player, so there's no reason it shouldn't work as expected. |
Thanks very much, will try this now.
|
Be sure to tell me if it works; I certainly hope so (!) because I know what it's like to require mass conversion of media files.
|
Hmm it doesn't seem to be working. I added your code to convert.sh and removed the mkdir line as I already have the directory, however when i'm running the command it's not doing anything:
[root@bonkbox test]# ./convert.sh [root@bonkbox test]# |
Could you post the entire contents of convert.sh for me? If I look through it as it appears in your script, I might see what the problem is (and I probably know how to fix it, this is the kind of stuff I do all the time, though it's with audio and not video).
|
Yep, also thanks for your time, I have limited knowledge at this.
Code:
#/usr/bin/env bash |
Oh no. There was a typo (I wrote "#/usr[...]" instead of "#!/usr[...]"). This should, now (I've fixed the error).
Tell me if you encounter success (!); again, I try to helpful when I'm actually knowledgable about the topic at hand. ######## BEGIN PASTING (below this line) #!/usr/bin/env bash for i in *; do TEMPNAME=$(echo $i | sed 's/.avi//gI')done ############ END OF PASTE |
Ok it's running, once again thank you VERY much, will update this topic after the test has been complete.
|
Seems to be working fine. Thanks so much for your time.
|
Quote:
current directory, the other ones are in subfolders. In that case you must recurse thru all the directories ###modified script #!/bin/sh TOP=full_path_to_the_directory_just_above_the_AVI_directory #replace avi by the actual name of your avi directory AVI=$TOP/avi FLV=$TOP/flv find $AVI/* | while read f do if [ -d $f ]; then continue fi cmd="echo $f | sed 's?^$AVI?$FLV?' | sed 's?\.avi?.flv?'" g="$(eval $cmd)" d=${g%/*} ext=${g##*.} if [ "$ext" == "avi" ]; then input="$f" output="$g" echo "mkdir -p $d" # mkdir -p $d echo "ffmpeg -i "$input" -y -f flv -ar 44100 -ab 64 -ac 1 -acodec mp3 \"$output\"" # ffmpeg -i "$input" -y -f flv -ar 44100 -ab 64 -ac 1 -acodec mp3 "$output" fi done ##########end of script ################ 1. remove the echo lines after you tested it (and then remove the '#' comment below those lines) 2. I'll comment some lines find $AVI/* | while read f this will look for every file/folder in the $AVI path, and store it in the variable f g="$(eval $cmd)" this will form the output full path name d=${g%/*} this will form the full path to the directory where the output file must reside mkdir -p $d create the target directory if it doesn't already exist now the conversion command is called if $f is a file and its extension is avi the output is written in a similar folder/subfolder and same name but different extension (flv instead of avi) |
This seems to be working fine, i've thanked both of you through the forum +1 system or what not, cheers guys.
|
All times are GMT -5. The time now is 05:29 PM. |