tag:blogger.com,1999:blog-6748147.post3946219315127294845..comments2023-06-21T01:59:56.563-07:00Comments on John Harding - Insert Catchy Title Here: Encoding video for iPhone with mencoderJohn "Blogger" Hardinghttp://www.blogger.com/profile/10524442451207178306noreply@blogger.comBlogger26125tag:blogger.com,1999:blog-6748147.post-62934664213398741372012-02-26T23:43:55.034-08:002012-02-26T23:43:55.034-08:00For those like kannie using PSNR to measure qualit...For those like kannie using PSNR to measure quality: be aware that PSNR is purely technical, bit-to-bit, not perceptual. Any kind of processing, like sharpening, will obviously worsen PSNR while could improve subjective quality. Extreme example: adding a bit of grain/noise is usually recommended to improve visual quality.Horacio Mijailhttps://www.blogger.com/profile/10941261506308268725noreply@blogger.comtag:blogger.com,1999:blog-6748147.post-61205905656186880002011-09-01T07:02:43.397-07:002011-09-01T07:02:43.397-07:00I had big trouble making my video work on a 3G : m...<b>I had big trouble making my video work on a 3G : mencoder was overidding the profile to high, I don't know the reason.<br /><br />I had to force the profile using <br /><br />-x264encopts profile=baseline<br /><br />Hope this will help</b>Arnonoreply@blogger.comtag:blogger.com,1999:blog-6748147.post-70934542291416768342010-11-18T08:05:09.887-08:002010-11-18T08:05:09.887-08:00Previous comment is spam (see poster's URL).Previous comment is spam (see poster's URL).Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6748147.post-50574662333131584112010-09-13T21:59:06.069-07:002010-09-13T21:59:06.069-07:00Answering a bunch of recent comments:
@khannie: I&...Answering a bunch of recent comments:<br />@khannie: I'm not too familar with the various scalers - there's a lot of interaction between the material, scaler, bitrate, etc. http://www.wieser-web.de/MPlayer/sws1/ is an interesting overview.<br /><br />@mlw: That's odd - I don't have any problems loading these videos. Worked via <object> and <a> tag on original iPhone (iOS 3.0), and via <video> and <a> tag on iPad (iOS 3.2.2) and it worked fine. <br /><br />@adam: Yeah, Handbrake is probably a better solution for this all around. I keep telling myself I'm going to add things like interlace handling (which I believe Handbrake already deals with) and audio normalization (which I bet Handbrake does as well). Part of the motivation here was just digging deeper into mencoder, but I also hold out hope for building out my own automated workflow.<br />And doesn "Insert Catchy Title Here" qualify as a catchy title?<br /><br />re: weightp - LAME. In support of Adam's comment, Handbrake seems to handle this for you. :)<br /><br />@Mobil: Yes. <br /><br />Random side note - I'm actually encoding at up to 640x480 for my Nexus One and should probably bump that up to the full 800x480 bounding box. If you're lucky enough to have an iPhone 4, you can do even higher res and bump up to Main Profile. You should actually be able to use almost the same settings as for AppleTV, though I'm not sure if I ever committed that to svn.John "Blogger" Hardinghttps://www.blogger.com/profile/10524442451207178306noreply@blogger.comtag:blogger.com,1999:blog-6748147.post-66147466565480130122010-08-19T17:44:03.071-07:002010-08-19T17:44:03.071-07:00Will this work for a 3Gs?Will this work for a 3Gs?Mobil | Mobiltelefonhttp://www.mobilhuset.orgnoreply@blogger.comtag:blogger.com,1999:blog-6748147.post-82866476124669210002010-07-10T13:47:56.437-07:002010-07-10T13:47:56.437-07:00Newest version of x264 requires adding weightp=0 t...Newest version of x264 requires adding weightp=0 to the x264encopt argumentsAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6748147.post-80241512702589423812010-05-29T22:18:49.130-07:002010-05-29T22:18:49.130-07:00A few things:
1. folks, check out HandBrake. Tran...A few things:<br /><br />1. folks, check out HandBrake. Transcoding made easy.<br />2. the longevity of this blog post is staggering.<br />3. JH - do you have a catchy title for this blog yet?Adam Monsenhttps://www.blogger.com/profile/18129153812733370245noreply@blogger.comtag:blogger.com,1999:blog-6748147.post-76952391439661072002010-05-28T09:50:08.792-07:002010-05-28T09:50:08.792-07:00John's mencoder settings work fine if you want...John's mencoder settings work fine if you want to prepare a video to transfer to your iPhone via iTunes. But the resulting MP4s won't play over HTTP in Safari on the iPhone.<br /><br />To make a Safari streamable MP4 (H264, AAC) using Quicktime Pro to do the encoding you have to set "Restrict Profile(s) to Baseline".<br /><br />But what are the correct x264 options to achieve the same result with mencoder?Unknownhttps://www.blogger.com/profile/08615104882260355955noreply@blogger.comtag:blogger.com,1999:blog-6748147.post-34262736888366330292010-01-07T03:23:18.213-08:002010-01-07T03:23:18.213-08:00Very useful post. Thanks. :)
Some minor feedback....Very useful post. Thanks. :)<br /><br />Some minor feedback.....<br /><br />-sws 9 seems to result in slightly lower picture quality than the default (-sws 2). I've checked the PSNR output from x264encopts on a few videos now and -sws 9 always seems to result in a lower PSNR (i.e. slightly worse picture quality).<br /><br />If all that is "blah blah blah" to you, the short version is that you're better off leaving out the -sws 9 switch.<br /><br />Also, a bitrate of 500 is quite low. Unless space is a concern for you, you're better off going with a higher bitrate (I'll be using around 800-1000 depending on the aspect ratio of the original).asdfhttps://www.blogger.com/profile/10979543352602947312noreply@blogger.comtag:blogger.com,1999:blog-6748147.post-86128752196555176502009-12-09T10:01:31.328-08:002009-12-09T10:01:31.328-08:00FFMPEG command line i used for iPod touch and iPho...FFMPEG command line i used for iPod touch and iPhone 3Gs:<br /><br />"\ffmpeg.exe" -i "Path\My.avi" -author "2Avi" -f mov -b 720k -r 23.976 -aspect 16:9 -s 480x320 -acodec libfaac -ab 256k -ar 44100 -ac 2 -y "Path\My_2avi.mp4"<br /><br />i wrote an extra Userinterface for Windows with it so i can just click & go. I m sure ill try the mencoder soon.<br /><br />tyAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6748147.post-36556589246350395642009-11-19T18:43:39.140-08:002009-11-19T18:43:39.140-08:00Why people? Why use all these scripts? (PHP?!) I...Why people? Why use all these scripts? (PHP?!) If you want to reuse the format, then use the built in mencoder config file. Then you can encode using<br /><br />mencoder infile.avi -o outfile.mp4 -profile iphone<br />And it's sooooo much easier to edit/add to later on.<br />Default location is ~/.mplayer/mencoder.conf<br />add this to the file<br />[iphone]<br />profile-desc="Default profile for iphone"<br />vf=scale=480:-10,harddup<br />lavfopts=format=mp4<br />faacopts=mpeg=4:object=2:br=128<br />oac=faac=yes<br />ovc=x264=yes<br />sws=9<br />x264encopts=nocabac:level_idc=30:bframes=0:global_header:threads=auto:subq=5:frameref=6:partitions=all:trellis=1:chroma_me:me=umh:bitrate=500<br />of=lavf=yesGordonhttps://www.blogger.com/profile/18292151533066879924noreply@blogger.comtag:blogger.com,1999:blog-6748147.post-60868369027241462482009-07-20T12:34:21.555-07:002009-07-20T12:34:21.555-07:00My PHP contrib:
function convert_video($nom){
...My PHP contrib:<br /><br /> function convert_video($nom){<br /> $input = "$nom.flv";<br /> $output = "mp4/$nom.mp4";<br /> <br /> $linia = "mencoder.exe $input -o $output ";<br /> <br /> //$linia .= "-vf scale=480:-10,harddup";<br /> $linia .= "-vf scale=480:320:2,scale=-8:-8,harddup ";<br /><br /> $linia .= "-lavfopts format=mp4 ";<br /> $linia .= "-faacopts mpeg=4:object=2:raw:br=128 ";<br /> $linia .= "-oac faac ";<br /> $linia .= "-ovc x264 ";<br /> $linia .= "-sws 9 ";<br /> $linia .= "-x264encopts nocabac:level_idc=30:bframes=0:global_header:threads=auto:subq=5:frameref=6:partitions=all:trellis=1:chroma_me:me=umh:bitrate=500 ";<br /> $linia .= "-of lavf";<br /><br /> exec($linia);<br /> echo $nom."<br>";<br /> //echo $linia."<br>";<br /> }<br /> <br /> $dix = "./folder/with/files/";<br /> $d = dir($dix);<br /> while(false !== ($arxiu = $d->read())) {<br /> if($arxiu!=".."&&$arxiu!="."){<br /> $arxiu = str_replace('.flv','',$arxiu);<br /> convert_video($arxiu);<br /> }<br /> }<br /> $d->close();Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6748147.post-26368803972613133182009-06-28T13:08:32.841-07:002009-06-28T13:08:32.841-07:00nice post. but it is possible with mencoder to cre...nice post. but it is possible with mencoder to create iphone reference movies?<br /><br />so instead of serving up one, i've got a .mov that references a movie file (m4v or 3gp or whatever) depending on network connection.<br /><br />you can do it with quicktime pro and something called makerefmovie but it's Mac/Windows only and I could do with a linux solution!<br /><br />thanks!Rich Ghttps://www.blogger.com/profile/02881029525826997066noreply@blogger.comtag:blogger.com,1999:blog-6748147.post-50472555156261570282009-06-06T16:05:02.035-07:002009-06-06T16:05:02.035-07:00Thanks for the mencoder info.
Here's a Window...Thanks for the mencoder info.<br /><br />Here's a Windows .bat file that will allow drag-and-drop encoding of multiple files: (assumes mencoder.exe in c:\program files\mencoder) It will also use .srt subtitles, if present. I haven't actually tested the output of this on an iPhone yet.<br /><br />:cont<br /><br />if '%1' == '' goto end<br /><br />for %%F in (%1) do start "MEncoder" /low /min /wait "c:\program files\mencoder\mencoder.exe" %%F -priority belownormal -oac lavc -lavcopts acodec=libfaac:abitrate=128:aglobal=1 -a52drc 0 -ovc x264 -x264encopts nocabac:level_idc=30:bframes=0:global_header:crf=20 -of lavf -lavfopts format=mp4 -vf dsize=480:320:0,scale=-8:-8,harddup -o "%%~dpnF_iPhone.mp4" -slang en -sub "%%~dpnF.srt"<br /><br />shift<br />goto cont<br /><br />:end<br /><br />pausebalazerhttps://www.blogger.com/profile/07679939273821807432noreply@blogger.comtag:blogger.com,1999:blog-6748147.post-38337320873949965922009-03-26T16:12:00.000-07:002009-03-26T16:12:00.000-07:00That was a really good script to encode video file...That was a really good script to encode video files.<BR/><BR/>Based on your script, I made a little batch program to do the job easier.<BR/><BR/>http://www.myubuntu.ca/?p=193Jasonhttps://www.blogger.com/profile/09673312326663943525noreply@blogger.comtag:blogger.com,1999:blog-6748147.post-89269894941534934912009-03-26T16:10:00.000-07:002009-03-26T16:10:00.000-07:00This comment has been removed by the author.Jasonhttps://www.blogger.com/profile/09673312326663943525noreply@blogger.comtag:blogger.com,1999:blog-6748147.post-42612618248938762182008-12-03T13:23:00.000-08:002008-12-03T13:23:00.000-08:00"-sws 9 - I think I just grabbed this from somewhe..."-sws 9 - I think I just grabbed this from somewhere - wtf?"<BR/><BR/>that is the type of resize to use. <BR/>The most common are 1,2, or 9.<BR/>Bilinear (-sws 1) is fast but smooths the image. Bicubic (-sws 2) is the default. Lanczos (-sws 9) actually sharpens the image during resize.<BR/><BR/>0 fast bilinear<BR/>1 bilinear<BR/>2 bicubic (good quality) (default)<BR/>3 experimental<BR/>4 nearest neighbor (bad quality)<BR/>5 area<BR/>6 luma bicubic / chroma bilinear<BR/>7 gauss<BR/>8 sincR<BR/>9 lanczos<BR/>10 natural bicubic splineAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6748147.post-2391886713366817682008-11-10T04:51:00.000-08:002008-11-10T04:51:00.000-08:00Finally got everything installed and working on my...Finally got everything installed and working on my Debian box. Getting the x264 codec installed and working took the longest, but I now have a perl script for converting everything thanks to your page and comments, so thanks everyone.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6748147.post-19537493818596007982008-09-01T11:09:00.000-07:002008-09-01T11:09:00.000-07:00Now, what are the chances that the one place on th...Now, what are the chances that the one place on the Interweb with information on encoding video for the iPhone that actually works is someone I know? :)<BR/><BR/>Thanks, John, this is useful stuff. I'd been trying to <A HREF="http://timfick.com/iphone/" REL="nofollow">futz around with VLC</A> for a while and found that it worked perfectly on some videos and horribly on others.<BR/><BR/>I'm trying out your to_ipod.py script now. I had to hack it a bit to make it work on Ubuntu, so let me know if you'd like a patch.<BR/><BR/>Happy Labor day!Adam Monsenhttps://www.blogger.com/profile/18129153812733370245noreply@blogger.comtag:blogger.com,1999:blog-6748147.post-38270179209188688862008-08-06T09:33:00.000-07:002008-08-06T09:33:00.000-07:00thank for the wonderful post. i use this command ...thank for the wonderful post. i use this command to convert a flv to iphone mp4 format:<BR/><BR/> mencoder 47762donbgcums.flv -o test.mp4 -vf scale=480:-10,harddup -oac faac -faacopts mpeg=4:object=2:raw:br=128 -of lavf -lavfopts format=mp4 -ovc x264 -x264encopts qp=26:pass=1<BR/><BR/>but i phone safari cannot download the test.mp4 and I cannot even import the test.mp4 to iphone using itune. Am i missing somthingAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6748147.post-14181052822348132912008-07-18T14:17:00.000-07:002008-07-18T14:17:00.000-07:00Never mind my question, I figured it out, it was a...Never mind my question, I figured it out, it was a DO'H moment. For those of you that are unaware, here are the steps<BR/>1) drag the mp4 file to iTunes Movies (top left under Library)<BR/>2) connect iPhone <BR/>3) Click on iPhone device<BR/>4) Click on Video tab<BR/>5) SCROLL DOWN - this is the DO'H moment for me LOL, check sync movies, check the movie<BR/>6) Sync iPhone<BR/>7) On iPhone, launch iPod app, click on Videos tab and there's the movie. <BR/><BR/>Enjoy!Bobhttps://www.blogger.com/profile/12461114419335666897noreply@blogger.comtag:blogger.com,1999:blog-6748147.post-65063410031631644272008-07-18T12:59:00.000-07:002008-07-18T12:59:00.000-07:00Thanks for this awesome post, it really helps me a...Thanks for this awesome post, it really helps me as I am a total video encoding newbie. And a basic question, I have iPhone 3G with iTunes 7.7 and can't seem to get the mp4 file (it plays fine in Quicktime) to sync with iTunes/iPhone, any suggestions?Bobhttps://www.blogger.com/profile/12461114419335666897noreply@blogger.comtag:blogger.com,1999:blog-6748147.post-64688956147576630652008-06-22T18:37:00.000-07:002008-06-22T18:37:00.000-07:00naviogg, you're totally right, that was a typo. G...naviogg, you're totally right, that was a typo. Good catch - I've corrected the post.<BR/>Glad to hear the post was useful for you - I had the same frustration with poor documentation of options and the various configs people had posted in the past.John "Blogger" Hardinghttps://www.blogger.com/profile/10524442451207178306noreply@blogger.comtag:blogger.com,1999:blog-6748147.post-42088354529932566312008-06-22T17:20:00.000-07:002008-06-22T17:20:00.000-07:00It is amazing how hard it is to get good informati...It is amazing how hard it is to get good information on mencoder settings, giving all the cool things it does<BR/><BR/>And you've been kind enough to say what the commands *mean* instead of simply an inscrutible cookbook - yay!<BR/><BR/>However, I think your command is wrong - you have two -oac options, and I think the second should be -oav<BR/><BR/>Am I right?naviogghttps://www.blogger.com/profile/11839460145411672008noreply@blogger.comtag:blogger.com,1999:blog-6748147.post-59244705206268961652008-05-26T10:38:00.000-07:002008-05-26T10:38:00.000-07:00If you want to constrain the final size to be with...If you want to constrain the final size to be within 480x320, then I think you actually want -vf dsize=480:320:<B>0</B>, which tells it to keep <B>display</B> size within those bounds, rather than <B>video</B> size. 4:3 DVDs are authored at 720x480 and scaled at display time, so using dsize=480:320:<B>2</B> will result in either a distored image (if display aspect ratio is not applied) or runtime rescaling (if it is).<BR/><BR/>In my testing w/ a 720x480 DVD source, 480:320:2 ended up with a 480x320 video, and it appears the display aspect ratio got lost in the process, such that mplayer and quicktime at least displayed it horizontally stretched.John "Blogger" Hardinghttps://www.blogger.com/profile/10524442451207178306noreply@blogger.com