Hi,
I have a CENTOS server with FFMPEG installed. I have around 40 directories with MP4 files in them. I'm currently re-encoding the files into an android optimized MP4 using the following command
It's taking quite some time, but that's okay. I'm wondering if there is a way to convert all the MP4 files in a particular directory and place the encoded output into the same directory. I've seen a couple of threads about this. But in those threads the input format is different from the output, so I'm not sure if it'll work for me.Code:$ ffmpeg -i infile.mp4 -s 432x320 -threads 4 -vcodec libx264 -flags +loop+mv4 -cmp 256 -partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 5 -bf 0 -flags2 +mixed_refs -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qmin 27 -qmax 32 -qdiff 4 -b 384k -r 600 -acodec libfaac -ar 48000 -ab 48000 -pass 1 outfile.mp4]
Thanks
+ Reply to Thread
Results 1 to 7 of 7
-
Last edited by darklift; 3rd Feb 2012 at 05:41.
-
Code:
for I in *.mp4; do ffmpeg -i "$I" -s 432x320 -threads 4 -vcodec libx264 -flags +loop+mv4 -cmp 256 -partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 5 -bf 0 -flags2 +mixed_refs -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qmin 27 -qmax 32 -qdiff 4 -b 384k -r 600 -acodec libfaac -ar 48000 -ab 48000 -pass 1 "${I%.mp4}new.mp4";done
Last edited by Baldrick; 3rd Feb 2012 at 07:12. Reason: Add done
-
Sorry, I'm kind of a linux newbie. How do I execute that? When I type all that and press enter, it takes me to the next line and stays blank. However when I press the up arrow to check the previous commands, I can see a large command that I never entered.
I'm testing it inside a folder with 2 MP4 files.
Thanks
____________________________________
Edit: I did some searching. So, I should put the code in a .sh file in a directory and then execute it by bash name.sh, right? When doing that I get a syntax error at line 2
Edit 2: It worked. All I had to do was add 'done' at the end of the code and then execute it.
Thanks a lotLast edited by darklift; 3rd Feb 2012 at 06:50.
-
I forgot the done after the last;
Code:for I in *.mp4; do ffmpeg -i "$I" -s 432x320 -threads 4 -vcodec libx264 -flags +loop+mv4 -cmp 256 -partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 5 -bf 0 -flags2 +mixed_refs -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qmin 27 -qmax 32 -qdiff 4 -b 384k -r 600 -acodec libfaac -ar 48000 -ab 48000 -pass 1 "${I%.mp4}new.mp4";done
I'm running a test on centos right now,
Code:for I in *.mp4; do ffmpeg -i "$I" -sameq "${I%.mp4}new.mp4"; done
edit: I see that you have already found the solution.Last edited by Baldrick; 3rd Feb 2012 at 07:12.
-
Yeah, found it just before you made that post. Thanks.
I need a little more help.
for I in *.mp4; do ffmpeg -i "$I" -s 432x320 -threads 4 -vcodec libx264 -flags +loop+mv4 -cmp 256 -partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 5 -bf 0 -flags2 +mixed_refs -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qmin 27 -qmax 32 -qdiff 4 -b 384k -r 600 -acodec libfaac -ar 48000 -ab 48000 -pass 1 "${I%.mp4}new.mp4";done
How can I make the same script do the QT-faststart and an MP4Box -isma on the output file.
Since there are around 50-100 files in one directory, it's a little time consuming to perform a QT-faststart and an MP4box isma on it one by one.
FFMPEG converts my 01.mp4,02.mp4 into 01new.mp4,02new.mp4 etc. I take the obtained 01new.mp4 file and run this
qt-faststart 01new.mp4 01.mp4
MP4Box -isma 01.mp4
Can you update the script to perform these two functions as well? Thank you -
Try
Code:for I in *new.mp4; do qt-faststart "${I%.mp4}.mp4" "${I%.mp4}qt.mp4";done
Code:for I in *newqt.mp4; do MP4Box -isma "${I%.mp4}.mp4"; done
Similar Threads
-
Cannot encode .mov file to dvd using ffmpeg
By RL in forum ffmpegX general discussionReplies: 3Last Post: 25th Oct 2011, 14:43 -
Encode with FFMPEG with multiple input files...
By RogerTango in forum Video ConversionReplies: 3Last Post: 20th Jun 2011, 01:12 -
Need CBR MP3 in FFMPEG encode, can you help?
By RogerTango in forum Video ConversionReplies: 7Last Post: 17th May 2010, 20:09 -
Cannot encode VOB to ffmpeg format ***UPDATED***
By pjfl29 in forum ffmpegX general discussionReplies: 4Last Post: 31st Jan 2009, 22:50 -
Ffmpeg command to encode ENTIRE DIRECTORY?
By sumpm1 in forum LinuxReplies: 2Last Post: 27th Sep 2008, 08:40