Converting 1080i to 720p for XBMC
If you are using XBMC as your video player, you might have encountered a problem playing 1080i AVCHD (*.ts or *.m2ts) videos. When playing such files, you may see just a gray screen with some digital artifacts. One possible solution is to convert such files to 720p H.264/MPEG-4 AVC format using ffmpeg utility and x264 encoder. The ffmpeg utility is available for Windows, Mac, Linux and other operating environments.
Download ffmpeg for your operating system. You can find download locations for ffmpeg for Windows here. For Unix-based operating systems, you can download source code and compile it yourself. Or you can download a pre-compiled version for your specific OS and processor architecture. Software repositories for most Linux distributions will include a pre-compiled version of ffmpeg.
The ffmpeg package for Windows will include a folder called “ffpresets”. This folder will contain text files with pre-configured options for ffmpeg to achieve desired video quality. Linux ffmpeg packages may not come with the presets, but you can easily find them online.
Here is a quick example of converting a 1080i video file to 720p on Windows. The ffmpeg package has been downloaded in extracted to “C:\Users\Bob\Desktop\ffmpeg\” directory. The ffmpeg presets directory is “C:\Users\Bob\Desktop\ffmpeg\ffpresets”. The file we are going to convert is “C:\Users\Bob\Documents\Videos\Video File.1080i.ts”
|
1 |
C:\Users\Bob\Desktop\ffmpeg\ffmpeg -deinterlace -i "C:\Users\Bob\Documents\Videos\Video File.1080i.ts" -acodec copy -vcodec libx264 -vpre "C:\Users\Bob\Desktop\ffmpeg\ffpresets\libx264-normal.ffpreset" -crf 25 -sws_flags lanczos -s hd720 -r 25 "C:\Users\Bob\Documents\Videos\Video File.720p.avi" |
The conversion process may take some time, depending on the duration of the video and processing power of your computer. Ffmpeg does not show estimated time or percentage of completion. You will see something like this in your command window:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
frame=19166 fps= 5 q=26.0 size= 244286kB time=1173.88 bitrate=1704.8kbits/s frame=19170 fps= 5 q=26.0 size= 244306kB time=1174.14 bitrate=1704.5kbits/s frame=19174 fps= 5 q=26.0 size= 244337kB time=1174.36 bitrate=1704.4kbits/s frame=19178 fps= 5 q=26.0 size= 244364kB time=1174.76 bitrate=1704.0kbits/s frame=19182 fps= 5 q=26.0 size= 244391kB time=1174.96 bitrate=1703.9kbits/s frame=19186 fps= 5 q=26.0 size= 244411kB time=1175.16 bitrate=1703.8kbits/s frame=19190 fps= 5 q=27.0 size= 244436kB time=1175.44 bitrate=1703.6kbits/s frame=19194 fps= 5 q=27.0 size= 244459kB time=1175.68 bitrate=1703.4kbits/s frame=19198 fps= 5 q=27.0 size= 244513kB time=1175.88 bitrate=1703.4kbits/s frame=19202 fps= 5 q=25.0 size= 244538kB time=1176.12 bitrate=1703.3kbits/s frame=19206 fps= 5 q=25.0 size= 244580kB time=1176.44 bitrate=1703.1kbits/s frame=19211 fps= 5 q=25.0 size= 244615kB time=1176.90 bitrate=1702.7kbits/s frame=19216 fps= 5 q=25.0 size= 244669kB time=1177.16 bitrate=1702.7kbits/s |
If you know the runtime of the original video, you can use this information to estimate how long it will take to finish re-encoding the file. Just look at the “time=” field. It shows the number of seconds of the original video that have been converted to the new format. In our example above, the conversion utility has been running for about 30 minutes and converted about 20 minutes of the video.
Below is an example of converting an entire directory full of 1080i *.ts and *.m2ts video files to 720p *.avi format on Linux one at a time using a script. This may be convenient if you have many files to convert, but you don’t wont to babysit the process. In this example the ffmpeg is located in /usr/bin/ and the ffpresets are located in /etc/ffmpeg/ffpresets. The video files are located in /home/bob/videos and a few subfolders.
|
1 2 3 4 5 6 7 |
#!/bin/bash # find /home/bob/videos -type f -iname "*.ts" -o -iname "*.m2ts" | while read i do OUTFILE=$(echo "$i" | sed 's/\(.ts\|.m2ts\)/-720p.avi/g') /usr/bin/ffmpeg -deinterlace -i "$i" -acodec copy -vcodec libx264 -vpre /etc/ffmpeg/ffpresets/libx264-normal.ffpreset -crf 25 -sws_flags lanczos -s hd720 -r 25 "$OUTFILE" done |
-
LN13
-
Echo

