Converting Video Files for iPod/iPhone/iPad
We usually have video files in .wmv .mpg .rmvb or .mkv formats. The iPod, iPhone or iPad only accept a limited number of video file types, such as .mov and .mp4. To play these video files in .wmv .mpg or .rmvb format, we should first convert them to .mov or .mp4 files that can played by iTune or other video players on these Apple devices that use the same codec engine. We may possibly convert video files for iPod or iPhone with mplayer/mencoder but it may have some problems, such as the audio and video do not synchronize very well for some videos.ffmpeg can convert video files from various formats to others and most of the time ffmpeg works very well. This post introduces how to convert the video files in common formats (.wmv, .mpg, .rmvb, .mkv, .etc.) to .mp4 format for iPod/iPhone/iPad.
Install ffmpegFirst, we should install the ffmpeg package. The Fedora Linux does not include ffmpeg in its repository for some reasons but the RPM Fusion repository provides it for us. To install the ffmpeg package, add RPM Fusion repository first.
The install the ffmpeg package:
# yum install ffmpegConvert video file format with ffmpeg
The basic command to convert video file input.wmv to onput.mp4 is as follows.
# ffmpeg -i input.wmv output.mp4Or other format (such as .mov) by:
# ffmpeg -i input.wmv output.movffmpeg determines the output video’s format by its file name extersion.
Convert video file format with ffmpeg for iPod/iPhone/iPadThe files in .mp4 format can be played on Apples devices. The iPod/iPhone/iPad have specific resolution, so we need to to convert the video files to a very high resolution since the devices can only display a limited one. We use the iPod generation 2 as the example, its screen resolution is 480×320. Hence, we can only convert the video to this resolution for smaller video file size. Similarly, the bitrate can also be set accordingly. The default one of ffmpeg (200 kb/s) is too low. To improve the quality of the converted video, we can set it to a larger one.
One good configuration for me is:
# ffmpeg -i input.wmv -s 480x320 -b 1000k output.mp4-s sets the frame size of the video. -b sets the bitrate of the video.
Convert video file format with ffmpeg for iPod/iPhone/iPad in one commandMore conveniently, we can form this command to a script convert2mp4.sh:
#!/bin/bash ffmpeg -i $1 -s 480x320 -b 1000k /tmp/$1.mp4Each time to convert a video file video.wmv, we can simply run:
$ convert2mp4.sh video.wmvand the converted file is /tmp/video.wmv.mp4 after the script finishes.