18
Nov
written by cail.cn • posted in How-To • 992 views 2 comments

The screen size for iPod/iPhone is 640×480.
I use ffmpeg tool to perform the transcoding.
The original 1080i video has a length of 1:13:31 – took over 12 hours to export from Vegas. The file size is 87.2GB. After the transcoding, the file size is 337MB!

ffmpeg

The ffmpeg command I used is from here, two-pass x264 encode

ffmpeg -i input.avi -pass 1 -an -vcodec libx264 -vpre fastfirstpass -vpre ipod640 -b 512k -bt 512k -s 640x480 -threads 0 -f rawvideo -y /dev/null && ffmpeg -i input.avi -pass 2 -acodec libfaac -ab 128k -ac 2 -vcodec libx264 -vpre hq -vpre ipod640 -b 512k -bt 512k -s 640x480 -threads 0 output.mp4

After another 12 hours transcoding, I realize that I made a mistake. The original movie has a aspect ratio of 16:9, but I transcoded the video into 640×480 (4:3)!!!! The correct ffmpeg command should be

ffmpeg -i input.avi -pass 1 -an -vcodec libx264 -vpre fastfirstpass -vpre ipod640 -b 512k -bt 512k -s 640x360 -threads 0 -f rawvideo -y /dev/null && ffmpeg -i input.avi -pass 2 -acodec libfaac -ab 128k -ac 2 -vcodec libx264 -vpre hq -vpre ipod640 -b 512k -bt 512k -s 640x360 -threads 0 output.mp4

I didn’t want to run the correct ffmpeg command for another 12-hour. After some googling, I found a solution – use mp4box to change the aspect ratio. The command I used is

mp4box -add inputfile.mp4#1:par=4:3 -add inputfile.mp4#2 output.mp4

Great!

Now, I need some optimized ffmpeg code to transcode the 1080i video into a 720p video. I really don’t want to save this >80G giant, because none of my home computer can smoothly play it. Also, I believe that video in 720p has a good balance between resolution and file size. The following code from
Eugenia

ffmpeg -y -i "export.avi" -threads 2 -f mp4 -vcodec h264 -level 41 -refs 2 -loop 1 -deblockalpha 0 -deblockbeta 0 -parti4x4 1 -partp8x8 1 -partb8x8 1 -me full -subq 6 -brdo 1 -me_range 21 -s 1280x720 -r 24000/1001 -b 4096k -bt 4096k -bufsize 15000k -maxrate 16000k -g 300 -coder vlc -acodec aac -ac 2 -ab 128k "720p-24.mp4"

… no longer works with the current version of ffmpeg (I am sure it worked 1.5 years ago) :-(

Leave a Reply

 

En.dogeno.us - CaiLog © cail.cn | Licensed under a Creative Commons License