I'm looking for a good (general) conversion command that will convert any input file to h.264 sized for the iPad.
Currently I have this command that works, that was adapted from robert.swain
With presets:
$ ffmpeg -i INPUT -acodec aac -ab 160000 -s 1024x768 -vcodec libx264 \
-vpre slow -vpre ipod640 -b 1200kb -threads 0 -f mp4 OUTPUT.mp4
Long form, no presets:
$ ffmpeg -i INPUT -acodec aac -ab 160000 -s 1024x768 -vcodec libx264 \
-coder 1 -flags +loop -cmp +chroma \
-partitions +parti8x8+parti4x4+partp8x8+partb8x8 -me_method umh \
-subq 8 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 \
-i_qfactor 0.71 -b_strategy 2 -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 \
-bf 3 -refs 5 -directpred 3 -trellis 1 \
-flags2 +bpyramid+mixed_refs+wpred+dct8x8+fastpskip -wpredp 2 \
-rc_lookahead 50 -coder 0 -bf 0 -refs 1 -flags2 -wpred-dct8x8 \
-level 30 -maxrate 10000000 -bufsize 10000000 -wpredp 0 -b 1200k \
-threads 0 -f mp4 OUTPUT.mp4
Note: I'm skipping the aspect ratio because we handle that in the program, and we only resize it if the input resolution is greater than the output resolution.
If there's any suggestions for improvement, we are looking to balance speed, quality and conversion time.
Check this link. All the conversion settings you can shake a phone at.
http://develop.participatoryculture.org/index.php/ConversionMatrix
Related
I'm encoding with ffmpeg and my audio bitrate varies somewhat, even tho I'm using -b:a 224K it differs with +-1 or 2 kb/s in the finished product. Is there a way to set a strict bitrate? My OCD made me write this post.
Here is my encoding parameters:
-c:v libx264 -preset fast -profile:v high -level 4.0 -crf 23 -x264opts cabac=1:ref=4:vbv_maxrate=15000:vbv_bufsize=31250 -coder 1 -pix_fmt yuv420p -r 24000/1001 -use_editlist 0 -movflags +faststart -g 30 -bf 2 -map 0:1 -map 0:2 -map 0:3 -c:a aac -b:a 224K -ar 48K -ac 2 -profile:a aac_low
I've been searching all day for a way to transcode files that are being uploaded to something that iPhone's can handle (in Safari) without any success. I've read that it's best to use Quicktime for iPhone with the h.264 codec but I am struggling to find either the correct dependencies or the correct syntax for this. I have already managed to convert to mp4 and webm .
Mp4:
'ffmpeg -i '.$input.' -strict experimental -s 1024x760 -ab 128k -vcodec libx264 -mbd 2 -flags +mv4+aic -trellis 2 -cmp 2 -subcmp -2 '.$filepath.'/'.$filename.'.mp4'
Webm
'ffmpeg -i '.$input.' -b 600 -s 1024x760 -ab 128k -vcodec libvpx -ab 128k -acodec libvorbis '.$filepath.'/'.$filenamewithoutext.'.webm'
Anyone know how to get these videos available for Safari (on iPhone/Pad)?
In fact, there are much more options which can be set for the input file as well for the output file.
However, I have found this german site : http://www.quadhead.de/videos-mit-ffmpeg-fur-das-iphone-konvertieren-und-streamen/ with this command :
ffmpeg.exe -i "%~1" -r 29.97 -vcodec libx264 -s 480x320 -flags +loop -cmp +chroma -deblockalpha 0 -deblockbeta 0 -b 400k -bufsize 4M -bt 256k -refs 1 -coder 0 -me_range 16 -subq 4 -partitions +parti4x4+parti8x8+partp8x8 -g 250 -keyint_min 25 -level 30 -qmin 10 -qmax 51 -qcomp 0.6 -trellis 2 -sc_threshold 40 -i_qfactor 0.71 -acodec aac -ab 80k -ar 48000 -ac 2 -strict experimental -y "%~1".mp4
Yes, I'm german ;) that's the reason for my bad english. So feel free to correct my posts. But hey... I like ffmpeg too.
Have a nice day ;)
According to the official ffmpeg documentation on http://trac.ffmpeg.org/wiki/x264EncodingGuide, this is my suggestion to encode a video file to at least Apple Quicktime compatibility :
ffmpeg -i INPUT -c:v libx264 -movflags +faststart -profile:v normal -pix_fmt yuv420p -c:a aac -cutoff 15000 -b:a 128k OUTPUT.mp4
Have a nice day ;)
I used below command to convert videos from FLV,M4V to MP4.
ffmpeg -y -i video_1336406262.flv -vcodec libx264 -vpre slow -vpre
ipod640 -b 250k -bt 50k -acodec libfaac -ac 2 -ar 48000 -ab 64k -s
480x320 video_1336406262.mp4
The videos converted from M4V to MP4 are playing very well in both iPhone and iPod but the videos converted from FLV to MP4 does not work in iPod but does in iPhone.
In the video area of HTML5 page iPod even does not show the play symbol.
Could someone help here?
I am using the same command to convert from both FLV and M4V to MP4.
Thanks
I would recommend using HandBrakeCLI in order to convert videos to MP4.
Handbrake has a few built-in presets that allow precise compatibility targetting, see https://trac.handbrake.fr/wiki/BuiltInPresets
The built-in ipod preset has a few differences with the format you require, so your invocation can be translated to a handrake call in the following way:
HandBrakeCLI -i video_1336406262.flv -e x264 -a 1 -E faac -6 dpl2 -R Auto -D 0.0 -f mp4 -I -m -x level=30:bframes=0:weightp=0:cabac=0:ref=1:vbv-maxrate=768:vbv-bufsize=2000:analyse=all:me=umh:no-fast-pskip=1:subme=6:8x8dct=0:trellis=0 -b 250 -B 64 -R 48 -X 480 -w 480 -l 320 -2 -o video_1336406262.mp4
I can't certify this is exactly what you need, but that should be close enough.
The conversion m4v -> mp4 makes no sense. m4v is just another extension for mp4.
Mp4 is not a video format but a wrapper for audio/videos/subtitles/metadatas.
In my opinion the problem comes from the profile. Depending on the iPhone generation, not all h264 profiles are supported.
Try adding -coder 0 to your command and it should work.
I think you get your command from here and I noticed there is another command that should do what you want :
iPod-iPhone 640 width, without presset :
ffmpeg -i INPUT -s 640x480 -r 30000/1001 -b 200k -bt 240k -vcodec libx264 coder 0 -bf 0 -refs 1 -flags2 -wpred-dct8x8 -level 30 -maxrate 10M -bufsize 10M-acodec libfaac -ac 2 -ar 48000 -ab 192k output.mp4
According to my experience, if you want a good quality/size ratio, you should prefer 2-pass encoding :
ffmpeg -y -i input -r 30000/1001 -s 480x272 -aspect 480:272 -vcodec libx264 -b 512k -bt 1024k -maxrate 4M -flags +loop -cmp +chroma -me_range 16 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq "blurCplx^(1-qComp)" -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -coder 0 -refs 1 -bufsize 4M -level 21 -partitions parti4x4+partp8x8+partb8x8 -subq 5 -f mp4 -pass 1 -an -title "Title" output.mp4
The encoding process is longer but worth the time!
One last thing, instead of using ffmpeg directly, I prefer to use Mencoder which is a wrapper for ffmpeg (more codecs support). A nice GUI for Mencoder should be MeGUI for windows, it really make the encoding process easier!
I'm using the following code to encode video files for mobile devices. The problem is that video (mp4) is playing on iPhone 4 and Android devices well, but not working on iPhone 3g. Any ideas?
/usr/bin/ffmpeg -i <source> -vcodec libx264 -b 160k -bf 3 -b_strategy 1 -coder 1 -qmin 7 -qmax 30 -s 640x360 -sc_threshold 40 -flags +loop -cmp +chroma -me_range 16 -me_method hex -subq 5 -i_qfactor 0.71 -qcomp 0.75 -qdiff 4 -directpred 1 -flags2 +fastpskip -dts_delta_threshold 1 -acodec libfaac -ab 128k <output> -y 2> video_up/log/".$name.".txt > /dev/null 2>&1
That’s too many flags. Try with -vcodec libx264, -vb 1000k, and -acodec libfaac and see if that plays (it should). Then you can try adding the rest to see which causes the problems.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Need a little help. I am trying to encode large videos using ffmpeg/x264. While x264 is totally unable to encode these videos to .mov, ffmpeg does a decent job.
But I need to use one of the flags which x264 provides to encode my video. So is there a good way to encode large videos using x264 given that i only want .mov as output.
While using x264 I am only mentioning input and output flags, I think that may be causing the problem.
Please guide
For one pass (newer commandline):
ffmpeg -i INPUT -acodec libfaac -ab 128k -ar 48000 -s WIDTHxHEIGHT -r FRAME_RATE -vcodec libx264 -b BIT_RATE -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -me umh -subq 5 -trellis 1 -refs 2 -bf 1 -coder 1 -me_range 16 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt BIT_RATE -maxrate 4M -bufsize 4M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 21 OUTPUT.mp4
For two pass (newer commandline):
ffmpeg -i INPUT -an -pass 1 -s WIDTHxHEIGHT -r FRAME_RATE -vcodec libx264 -b BIT_RATE -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -me dia -subq 1 -trellis 0 -refs 1 -bf 1 -b_strategy 1 -coder 1 -me_range 16 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt BIT_RATE -maxrate 4k -bufsize 4k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 OUTPUT.mp4
ffmpeg -i INPUT -acodec libfaac -ab 128k -ar 48000 -pass 2 -s WIDTHxHEIGHT -r FRAME_RATE -vcodec libx264 -b BIT_RATE -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs -me umh -subq 5 -trellis 1 -refs 2 -bf 1 -b_strategy 1 -coder 1 -me_range 16 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt BIT_RATE -maxrate 4k -bufsize 4k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 21 OUTPUT.mp4
1.5Mbit/s 640×480 H.264 videos (for improved quality using TV out)
For one pass:
ffmpeg -i INPUT -acodec libfaac -ab 128k -s WIDTHxHEIGHT -vcodec libx264 -b BIT_RATE -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -me umh -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt BIT_RATE -maxrate 10M -bufsize 10M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect WIDTH:HEIGHT OUTPUT.mp4
For two pass:
ffmpeg -i INPUT -an -pass 1 -s WIDTHxHEIGHT -vcodec libx264 -b BIT_RATE -flags +loop -cmp +chroma -partitions 0 -me epzs -subq 1 -trellis 0 -refs 1 -coder 0 -me_range 16 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt BIT_RATE -maxrate 10M -bufsize 10M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect WIDTH:HEIGHT OUTPUT.mp4
ffmpeg -i INPUT -acodec libfaac -ab 128k -pass 2 -s WIDTHxHEIGHT -vcodec libx264 -b BIT_RATE -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -me umh -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt BIT_RATE -maxrate 10M -bufsize 10M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect WIDTH:HEIGHT OUTPUT.mp4
768kbit/s 320×240 H.264 videos
For one pass:
ffmpeg -i INPUT -acodec libfaac -ab 128k -s WIDTHxHEIGHT -vcodec libx264 -b BIT_RATE -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs -me umh -subq 5 -trellis 1 -refs 5 -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt BIT_RATE -maxrate 768k -bufsize 2M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 13 -title SOME_TITLE OUTPUT.mp4
For two pass:
ffmpeg -i INPUT -an -pass 1 -s WIDTHxHEIGHT -vcodec libx264 -b BIT_RATE -flags +loop -cmp +chroma -partitions 0 -me epzs -subq 1 -trellis 0 -refs 1 -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt BIT_RATE -maxrate 768k -bufsize 2M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 13 -title SOME_TITLE OUTPUT.mp4
ffmpeg -i INPUT -acodec libfaac -ab 128k -pass 2 -s WIDTHxHEIGHT -vcodec libx264 -b BIT_RATE -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs -me umh -subq 5 -trellis 1 -refs 5 -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt BIT_RATE -maxrate 768k -bufsize 2M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 13 -title SOME_TITLE OUTPUT.mp4
2.5Mbit/s 640×480 MPEG-4 SP videos
For one pass:
ffmpeg -i INPUT -acodec libfaac -ab 128k -s WIDTHxHEIGHT -vcodec mpeg4 -b BIT_RATE -flags +aic+cbp+mv0+mv4+trell -mbd 2 -cmp 2 -subcmp 2 -g 250 -maxrate 2.5M -bufsize 2M -title SOME_TITLE OUTPUT.mp4
For two pass:
ffmpeg -i INPUT -an -pass 1 -s WIDTHxHEIGHT -vcodec mpeg4 -b BIT_RATE -flags +aic+cbp+mv0+mv4+trell -mbd 2 -cmp 2 -subcmp 2 -g 250 -maxrate 2.5M -bufsize 2M -title SOME_TITLE OUTPUT.mp4
ffmpeg -i INPUT -acodec libfaac -ab 128k -pass 2 -s WIDTHxHEIGHT -vcodec mpeg4 -b BIT_RATE -flags +aic+cbp+mv0+mv4+trell -mbd 2 -cmp 2 -subcmp 2 -g 250 -maxrate 2.5M -bufsize 2M -title SOME_TITLE OUTPUT.mp4
Cheers