You might want to convert you home-made video (no pirated video :-!) into a format that your Android phone can play. The video formats that Android support are listed in Android developers' site:
Among the listed formats, H.264 (as a realization of the MPEG-4 standard) has been well accepted by the industry. Companies including Apple has switched to it. In the following, I will show you that using open source software on a Linux box can convert your video into H.264 with AVC video and AAC audio. I took the following post as a reference, but with updates.
First of all, you need to install the following software packages:
- mplayer: a multimedia player
- mencoder: MPlayers's movie encoder
- faac: an AAC audio encoder
- gpac: a small and flexible implementaiton of the MPEG-4 system standard
- x264: video encoder for the H.264/MPEG-4 AVC standard
Then we do the following steps to convert the video.avi into a .mp4 file in H.264 format.
- Extract the audio information from video.avi using MPlayer:
mplayer -ao pcm -vc null -vo null video.avi
This will generate a audiodump.wav file. - Encode audiodump.wav into AAC format
faac --mpeg-vers 4 audiodump.wav
This generates a audiodump.aac file. - Use mencoder to convert the video content of video.avi into YUV 4:2:0 format, and use x264 to encode the output into AVC format
mkfifo tmp.fifo.yuv
We created a named pipe to buffer between mencoder and x264. These command lines generate both Quicktime-compatible and H.264-compatible content. This is because Apple Quicktime can now hold H.264 content. Be aware to specify the same video size to mencoder and x264. In above example, the size is 800x450.
mencoder -vf scale=800:450,format=i420 \
-nosound -ovc raw -of rawvideo \
-ofps 23.976 -o tmp.fifo.yuv video.mp4 2>&1 > /dev/null &
x264 -o max-video.mp4 --fps 23.976 --bframes 2 \
--progress --crf 26 --subme 6 \
--analyse p8x8,b8x8,i4x4,p4x4 \
--no-psnr tmp.fifo.yuv 800x450
rm tmp.fifo.yuv - Merge the AAC audio and AVC video into a .mp4 file using gpac
MP4Box -add max-video.mp4 -add audiodump.aac \
MP4Box is a tool in the gpac package.
-fps 23.976 max-x264.mp4
1 comment:
Hello
Reached here searching for a method to convert YUV files to WMV or AVI using Mencoder.
Can u plz suggest a way for it ?
Post a Comment