Convert Transport Stream files from a Canon HG21 into AVI
Inhaltsverzeichnis
1 Goal
These new HD cameras are fantastic products. Windows users need tu buy some tools to do the cutting and the editing, but Linux users have some fantastic tools for converting between formats.
Yet, it is sometimes important to know some things about the formats in use or how to convert them into more known video formats.
The following page will show what's necessary.
2 References
- http://www.avsforum.com/avs-vb/showthread.php?t=789775 Fantastic thread with all information whatsoever.
- http://www.catswhocode.com/blog/19-ffmpeg-commands-for-all-needs fantastic ffmpeg commands
- http://www.fsckin.com/2008/01/03/transcoding-mtsm2ts-avchd-video-files-with-free-software/ also very good information
- http://iphome.hhi.de/suehring/tml/download/ Where to get all these fantastic H264 tools
- http://www.ffmpeg.org/faq.html ffmpeg FAQ
3 Ubuntu Requirements
Install the following:
sudo apt-get install uild-essential libxvidcore4-dev libfaad-dev libfaac-dev libmp3lame-dev \ subversion ctags mplayer ffmpeg x264 faad2 faac a52dec mencoder faad libfaad2-0 libfaad2-dev csh
Then download the jm17.2.zip file from http://iphome.hhi.de/suehring/tml/download/ and extract the zip file. Then cd into that directory and execute the install with sudo.
It will generate and install the according tools.
Note: The script didn't work that fine for me, so I modified it a little. See below.
4 Code
Since there might have been some errors in the script, here is the script that works fine for me:
#!/bin/csh if ( $#argv == "0" ) then echo usage: $0 filename.m2ts ... exit else set files=($*) endif set path = ( . $path ) echo using: which xporthdmv || exit which ldecod || exit which ffmpeg || exit echo $0 Starting. echo " " foreach file ($files) if ( ! -f $file ) then echo file $file not found exit endif set filebase=`basename $file | sed s/\.m2ts// | sed s/\.MTS//` set audiofile=/tmp/$filebase".ac3" set videofifo=/tmp/$filebase".yuv" set outputfile=$filebase".avi" if ( ! -f $audiofile ) then echo xporthdmv -nh $file 1 1 1 xporthdmv -nh $file 1 1 1 else echo $audiofile already exists, not creating it. endif if ( ! -f $videofifo ) then echo ldecod -i bits0001.mpv -o $videofifo ldecod -i bits0001.mpv -o $videofifo else echo $videofifo already exists, not creating it. endif mv bits0001.mpa /tmp/samplevideo.ac3 echo " " echo --- INPUT FILE HAS THE FOLLOWING PROPERTIES --- echo " " ffmpeg -i $file echo --- END OF INPUT FILE PROPERTIES --- echo " " if ( ! -f $outputfile ) then ffmpeg -r 25 -s 1440x1080 -i $file \ -acodec ac3 -ab 256k -ac 2 \ -vcodec mpeg4 -sameq \ -aspect 16:9 -b 15000k -deinterlace -copyts $outputfile if ( -f $outputfile ) then echo " " echo --- OUTPUT FILE HAS FOLLOWING PROPERTIES --- ffmpeg -i $outputfile echo --- END OF OUTPUT FILE PROPERTIES --- echo " " else echo $outputfile exists, not creating it. endif #echo To remove temporary files: rm -f /tmp/*.ac3 /tmp/*.yuv rm -f ./dataDec.txt ./log.dec bits0001.mpv $videofifo $audiofile rm /tmp/samplevideo.ac3 end echo $0 complete.