For most people, the way they watch their snapped HD video is with either these ways:
– Copy files to the computer, edit as a single video, export to a DVD or MOV/MP4. This is the most popular method, and the one I’d recommend to most people.
– Buy a mini-HDMI adapter, connect the camera to the TV directly.
– Wirelessly transmit the video via DLNA/UPnP/Airplay to a playback device.
Each of these ways has its advantages and disadvantages. In the first case, exporting to a delivery codec for general viewing, is “lossy”, for example. Using the camera via an HDMI adapter doesn’t scale financially, since these files are huge and new SD cards would need to be purchased regularly once they’re filled up. As for the third option, it’s technically complex and few can figure it out, or have a solid-enough WiFi network to send up to 50 mbps of data over the air (few people have their living room wired), or often the formats don’t work on the targeted device.
So here’s a fourth, alternative way, for those who want lossless HD video, from their camera to TV, using a playback device, like the Sony PS3, XBOX360, Roku, GoogleTV. Some cameras that already record in MP4 (h.264/AAC), or playback devices that support many formats, do not require any additional processing on the video files, but often, this combo is not possible (e.g. files from a Canon HD digicam and Roku XD|S’ “USB Channel” playback app don’t work together). This article is trying to tackle such cases. The video will remain untouched, only the audio would be re-encoded in high bitrate, and only if that’s needed.
So, for this tutorial, you will need an h.264 (not MJPEG) HD digital camera or digirecorder, and some rudimentary knowledge of how to use the command line. If you have a Canon camera, you should use its built-in editing function to cut out the parts of videos that are not worth keeping (e.g. shaky scenes etc). Don’t keep footage that is not presentable. Other cameras might have the same in-camera ability, check with your camera’s manual.
Install this ffmpeg build from here, and the faac encoder archive from here. Create a folder called “ffmpeg” in your user’s folder, it would look something like this: C:\Users\YOUR-USERNAME\ffmpeg\ (the exact path depends on the version of the Windows OS you’re using). From inside these two compressed archives you downloaded, drag in the ffmpeg folder the ffmpeg.exe file, and the libfaac-0.dll file (note: you will need the 7-Zip utility to uncompress these archives). Then rename libfaac-0.dll to libfaac.dll (if you don’t see file suffixes, e.g. .dll, .7z, etc, you can enable that feature on your Windows Explorer’s “Options” dialog). Finally, inside that ffmpeg folder create two new folders, named “original”, and “rewrapped”. Using an SD reader (it’s faster than connecting your camera via USB), copy your camera files inside the “original” folder.
If your files’ suffix is .mov or .mp4, open Quicktime, load any one of your camera files, and click “Window”, and then “Show Movie Inspector”. Check the format, and depending what kind of audio it says it’s got, you’d need to follow a different ffmpeg script, as shown below. If your files are .mts use case #4 (change .mts to .m2ts or .avi if your h.264 camera shoots as such, e.g. older AVCHD cams, older Flip cams). So, open the “Command Prompt” Windows application, navigate to the ffmpeg folder (that’s where the rudimentary command-line knowledge I mentioned above is required), then copy/paste the right script that matches your case, and run it.
1. MOV (h.264/PCM) to MP4 (h.264/AAC) // Canon, new Nikon cams
ffmpeg -i original\movie.mov -f mp4 -vcodec copy -acodec libfaac -ab 256000 -ac 2 rewrapped\movie.mp4
2. MOV (h.264/AAC) to MP4 (h.264/AAC) // Flip, Kodak, iPhone/iPod/iPad
ffmpeg -i original\movie.mov -f mp4 -vcodec copy -acodec copy rewrapped\movie.mp4
3. MP4 (h.264/PCM/AC3/mono AAC) to MP4 (h.264/AAC) // Optional for Samsung cams with AAC mono audio
ffmpeg -i original\movie.mp4 -f mp4 -vcodec copy -acodec libfaac -ab 256000 -ac 2 rewrapped\movie.mp4
4. MTS (h.264/AC3) to MP4 (h.264/AAC) // AVCHD-Lite Sony & Panasonic digicams
ffmpeg -i original\movie.mts -f mp4 -vcodec copy -acodec libfaac -ab 256000 -ac 2 rewrapped\movie.mp4
Obviously, manually change the two filenames “movie.xxx” each time you move to a different file (e.g. an original file 2011-03-14-343.mov would become 2011-03-14-343.mp4). If you have lots of camera files, and changing the filename manually is way too much work, you can create a “batch” script. Open notepad or another text editor, and depending which of the cases above you need, copy/paste the appropriate script (not the “Case ##:” line).
for %%a in ("original\*.mov") do ffmpeg -i %%a -f mp4 -vcodec copy -acodec libfaac -ab 256000 -ac 2 rewrapped\%%~na.mp4
for %%a in ("original\*.mov") do ffmpeg -i %%a -f mp4 -vcodec copy -acodec copy "rewrapped\%%~na.mp4"
for %%a in ("original\*.mp4") do ffmpeg -i %%a -f mp4 -vcodec copy -acodec libfaac -ab 256000 -ac 2 rewrapped\%%~na.mp4
Case #4 (change .mts to .m2ts or .avi if your h.264 camera shoots as such, e.g. older AVCHD cams, older Flip cams):
for %%a in ("original\*.mts") do ffmpeg -i %%a -f mp4 -vcodec copy -acodec libfaac -ab 256000 -ac 2 rewrapped\%%~na.mp4
Save the script for your case as rewrap.bat on the same folder as your ffmpeg.exe file, and run it. It will only take a few moments to losslessly rewrap your video to the more standard MP4 format that can be played with most TV devices. The only device that needs its video re-encoded is the original AppleTV, which has a limitation of 720/24p at 5 mbps (Simple Profile). Every other modern TV device should be able to playback these rewrapped files without a problem. Once you have confirmed that your device can play these files, you can delete the original camera files to make space in your PC (these new MP4 files are as good for future editing, since the video was not re-encoded, and the audio was not always re-encoded — and if it was, it was with high-enough bitrate).
If you would like to join all these created MP4 files under a single MP4 file for easier viewing, you can use MP4box. Unzip mp4box.exe and any DLL file it comes with on your \ffmpeg\rewrapped\ folder. Navigate there with a Command Prompt window and run:
MP4Box -cat 1.mp4 -cat 2.mp4 -cat 3.mp4 output.mp4
Add as many mp4 files you want (preferably in the order they were shot as), and of course use the right mp4 filenames. If it complains about it, you also need to hunt for the MSVCR100.dll file at Microsoft’s site, and when you find it, you can copy it on the same folder as mp4box.exe. At the end, to fix some mp4box container bugs, run:
..\ffmpeg -i output.mp4 -vcodec copy -acodec copy -y final.mp4
This final.mp4 file is the one you can use to watch all your clips as one. If you’re copying it into a FAT32 system to view, then make sure the file is not bigger than 4 GB, or it will fail (FAT32 limitation).
If you’re porting these scripts to a Linux/Unix OS, you must either compile your own ffmpeg with libfaac support, or download a binary package compiled as such, or you will need a pre-built libfaac library for an existing ffmpeg version (that must itself be built with dynamic loading). Finally, make sure the script’s backward slashes are changed to forward.