# .m2ts to .mp4; H.264, 1440:1080i; Tivo and Streambaby



## OmegaTCB (May 17, 2011)

(FYI, I have also posted this at videohelp.com.)

Hoping that one of the experts can point me in the right direction. I have been searching this and other forums, but still haven't been able to come up with the solution. Might have learned a little about codecs and containers along the way, but I am definitely a newbie.

My situation and end goals would seem pretty simple:

I have a bunch of home videos shot on m Sony HDR-SR7 Camcorder that I have transfered to my computer. I also have a couple of Tivo Premeirs in the house and would like to transfer and/or stream those videos to my Tivos. The Sony packages the files in a file with a .m2ts extension. tsMuxer 1.10.6 reports the following about the files inside the container:

H.264, Profile: [email protected] Resolution 1440:1080i Frame Rate: 29.97
AC3, Bitrate 448 kbps, Sample Rate 48 Khz Channels 6

While I have used Pinacle Studio (v 12 first, now v15) on ocassion to manipulate the files such that I could use Tivo's standard app for viewing playing the videos, it is a bit tedious and it is never clear to me if I am doing some re-encoding that would result in a loss of quality. I would like to quickly and without loss of quality, remux(?) (new word to me) the files to be able to see them through my Tivos. While I might go back later and use Pinacle to combine files and pretty things up (hopefully also without any loss of quality), right now I'd settle for getting my unedited files from my camcorder accessible.

Have recently discovered Streambaby (streaming application for Tivo), and I definitely prefer the streaming approach over the pull approach in the standard Tivo App. Have also been playing around with tsMuxeR and Yamb/Mp4box based on a little information that I found on other sites. (Mostly here: new user - can't post link). Using TsMuxer/Yamb without changing any defaults, the resulting file has the video playing at half-speed (I think do to some mishandling of the interlacing?). Doubling the frame rate in Yamb for the video file results in very jerky video in the final file.

Any help would be much appreciated. Thanks.


----------



## wmcbrine (Aug 2, 2003)

I'd do it with ffmpeg:

ffmpeg -i file.m2ts -vcodec copy -acodec copy file.mp4

or just let pyTivo do that automatically (in the most recent versions only).


----------



## OmegaTCB (May 17, 2011)

wmcbrine said:


> I'd do it with ffmpeg:
> 
> ffmpeg -i file.m2ts -vcodec copy -acodec copy file.mp4
> 
> or just let pyTivo do that automatically (in the most recent versions only).


Thanks! Nice and fast. However, the resulting file seems to have something wrong with the audio track. When quicktime tries to play it, I get a pop-up that says:

Error -2041: an invalid sample description was found in the movie (out.mp4)​
When I open in Pinacle Studio, the clip will play, but without any sound.

Streambaby, however, plays it just fine.

Will do a little searching on that error message, but any tips still appreciated.


----------



## moyekj (Jan 24, 2006)

OmegaTCB said:


> Thanks! Nice and fast. However, the resulting file seems to have something wrong with the audio track. When quicktime tries to play it, I get a pop-up that says:
> 
> Error -2041: an invalid sample description was found in the movie (out.mp4)​
> When I open in Pinacle Studio, the clip will play, but without any sound.
> ...


 Only a few media players support AC3 audio in mp4 container. Videolan VLC is one of them and of course TiVo decoder supports it.


----------



## OmegaTCB (May 17, 2011)

Thanks. So may different compatibilities and caveats to figure out -- hard to keep track.

Let me back up and see if anyone wants to answer a more general question. Given my capture device and the general desire to play it on my Tivo without too much trouble, what is the right format and container. Would be best if it was in a format that I could easily put on disk (DVD) that would play on Bluray player too. Just don't want to spend to much time screwing around re-encoding stuff....


----------



## OmegaTCB (May 17, 2011)

STill surfing and trying to figure stuff out. Am I right in understanding that H264 + AAC in an MP$ container will be the most versatile without downdraging quality (especially video). Again, I'd like to be abvle to play on Tivo, Play with "standard" video players on the PC, probably drop into a BluRay image to share with Grandma.

If this is true, then it seems that I need to take my AC3 stream and get it encoded in AAC. Surfing on the right solution for that, but any tips would be appreciated.


----------



## ajayabb (Jan 12, 2007)

I ran into this same dilemma. I have a Panasonic HD camcorder which produces h.264 video in an .mts container. I looked all over, but never found a way to demux the h.264 into an .mp4 container (without transcoding) and stream to my tivo. Pytivo should be able to play your .mt2s files but it will be transcoded to .mpg and there will be some notable loss in video quality. For me, watching the transcoded material defeated the purpose of having an HD camcorder. Instead, I just directly view the videos from the camera to the TV via HDMI. I wish there was a better way as well. Also, when I did try transcoding the file to .mp4 with Handbrake and streaming, the bit rate had to be dialed down in order to stream the file with Streambaby.


----------



## wmcbrine (Aug 2, 2003)

OmegaTCB:

ffmpeg -i file.m2ts -vcodec copy -acodec libfaac -ab 256K file.mp4

or something like that... Really, though, it seems to me that your main problem is wanting a single file for all purposes. I'd just have the MP4 (with AC3 audio, so neither video nor audio has to be reencoded) for the TiVo, and keep the original M2TS for other things.

If nothing else, M2TS is what you want to make a Blu-Ray from.

ajayabb:

Recent versions of pyTivo will remux your M2TS to a TiVo-compatible MP4 without reencoding it, if you use the "Push" feature (i.e., initiate the transfer from the web interface).


----------



## Okeemike (Apr 24, 2002)

Let me save you a LOT of time. Pick up either a WD TV Live, or a WD TV Live+. They're running around $80 now on Amazon, and you may be able to find a deal elsewhere.

Plug this sucker in via HDMI and then either browse to a shared folder on your PC, connect to your NAS (via DLNA) or just stick a thumbdrive in the back, and play your video.

(Generally) no conversion needed. It will play MP4, AVI, MPG, VOB, ISO, etc... 

I tried to do exactly what you're trying to do now, and had a heck of a time finding the secret combination that give me a balance of picture quality, audio, and didn't take forever to convert. I got tired of all the work involved just to watch home videos, and got one of these things. I liked it so much, I now own three (two for home, and one I use for the hotel when I travel).


----------



## orangeboy (Apr 19, 2004)

OmegaTCB said:


> STill surfing and trying to figure stuff out. Am I right in understanding that H264 + AAC in an MP$ container will be the most versatile without downdraging quality (especially video). Again, I'd like to be abvle to play on Tivo, Play with "standard" video players on the PC, probably drop into a BluRay image to share with Grandma.
> 
> If this is true, then it seems that I need to take my AC3 stream and get it encoded in AAC. Surfing on the right solution for that, but any tips would be appreciated.


Be aware of Note 3 from the Streambaby Video Compatibility wiki:



> TiVo decoder can only properly output stereo or 5.1 AC3 audio, so while > 2 channel AAC audio tracks are supported, they will not sound right as output by TiVo.


I stick with AC3.

Edit - I found this at doom9 forum:


> AAC is mapped as C-L-R-Ls-Rs-LFE, while AC3 is mapped as L-C-R-LFE-Ls-Rs


I don't know if remapping would fix the TiVo "not sounding right" with AAC surround.


----------



## jcthorne (Jan 28, 2002)

I will add that Tivo, the WDTV mentioned above and mediaplayer HC or VLC player all work with mp4 files with ac3 audio. Its been a part of the standard for some time now. With the right codecs installed, even WMP can play them. Its the one file format that I use for everything so that compatibility is maintained. Its also easily extracted if I ever do need to remux for some other container.


----------



## OmegaTCB (May 17, 2011)

Thanks everyone.

While the WDTV does look cool, I am doing to try to avoid adding yet another device to the mix. With H264+AC3 in MP4 now being part of the standard, I guess that I can hope that some of the issues with various players/devices get ironed out over time. Right now it looks like Pinnacle Studio 15 doesn't handle it quite right. Also discovered the Picasa garbles the audio when it uploads. Not a big deal, but I was using that as my easy, low tech way of sharing with Grandma.

I think I have settled on keeping both .m2ts and .mp4 versions around. Happy that I don't have to do any transcoding, and maybe in the future I'll be able to do without one of the versions.

Last issue I am struggling with is using Pinnacle Studio to combine multiple videos (just concatenating, no real editing), and saving in a format that doesn't do transcoding. Trying to work that question on the Pinnacle forums....


----------



## orangeboy (Apr 19, 2004)

OmegaTCB said:


> Thanks everyone.
> 
> While the WDTV does look cool, I am doing to try to avoid adding yet another device to the mix. With H264+AC3 in MP4 now being part of the standard, I guess that I can hope that some of the issues with various players/devices get ironed out over time. Right now it looks like Pinnacle Studio 15 doesn't handle it quite right. Also discovered the Picasa garbles the audio when it uploads. Not a big deal, but I was using that as my easy, low tech way of sharing with Grandma.
> 
> ...


I have a Windows batch file I use to concatenate various file types, using mencoder, mp4box or just the COPY command:


```
@ECHO off
SetLocal EnableDelayedExpansion

IF NOT "%~d1"=="\\" (
	CD /D "%~dp1"
) ELSE (
	PUSHD "%~dp1"
)
CD
SET fileext=%~x1
SET filename=%~n1
SET filelist="%~nx1"
SET outfile="combined%~x1"

SHIFT

:Loop
::-----------------------------------------::
:: Process all files until arguments empty ::
::-----------------------------------------::
IF "%~nx1"=="" GOTO Done

SET filelist=%filelist% "%~nx1"

:End
::-----------------------------------------::
:: File is done, go get next one           ::
::-----------------------------------------::
SHIFT
GOTO Loop

:Done
IF "%fileext%" EQU ".avi" (
	mencoder.exe -oac copy -ovc copy -idx -noodml -of avi -o %outfile% %filelist%
)
IF "%fileext%" EQU ".mp4" (
	FOR %%A IN (%filelist%) DO (
		SET input=!input! -cat %%A
	)
	mp4box -add !input:~5! -new %outfile%
)

IF "%fileext%" EQU ".mpg" (
	mencoder.exe -oac copy -ovc copy -of mpeg -o %outfile% %filelist%
)
IF "%fileext%" EQU ".VOB" (
	SET voblist=%filelist: =+%
	COPY /B !voblist! /B %outfile%
)
IF "%fileext%" EQU ".001" (
	SET splitlist=%filelist:" "="+"%
	CD
	COPY /B !splitlist! /B %outfile%
)
::DEL %filelist%
ECHO.
ECHO %filename%
ECHO.
ECHO %outfile%
SET /P newname=New name? 
IF "%newname%" NEQ "" (
	REN %outfile% "%newname%%fileext%"
)

POPD
::------------------------------------------::
:: Files done. Go back from whence you came ::
::------------------------------------------::
EXIT /B
```
I drag a set of files onto the batch file (actually, the batch file resides in my Send To folder). Something to note about Windows selecting multiple files: the file arguments _start_ with the file that the cursor is on. So if you have:

File1.ext
File2.ext
File3.ext

and start selecting with File1, and end with the cursor on File3, the arguments passed will be File3, File1, File2. So I always select "backwards", starting with File3, and ending with the cursor on File1.


----------



## jcthorne (Jan 28, 2002)

OmegaTCB said:


> Thanks everyone.
> 
> Also discovered the Picasa garbles the audio when it uploads. Not a big deal, but I was using that as my easy, low tech way of sharing with Grandma.
> 
> ...


That one is a bit surprising for Google. I can tell you that they work fine with flickr. Perhaps you should ask Google for help with it in one of thier help blogs. They might not even know its a problem. Since it is part of the standard, they might be interested. YouTube handles it too. Google has been quite helpful to me on a few android and google voice issues when they integrated with Sprint.


----------

