# Has *ANYONE* been able to convert/play AVCHD-originated video????



## Doug G (Mar 3, 2005)

I'm at my wits end. I've got streambaby working fine with MPEG2. All I want to do is play my Canon HF100 originated AVCHD ([email protected], AC3 audio) content by converting it to MP4 and pushing it. The stream specs are within the Tivo H.264/MPEG-4 requirements. It should be trivial to de/mux them into a MP4 container but I've tried ffmpeg, VLC, and even some trial versions of commercial tools like MTSconverter. Nothing works. Whenever I try to push, all I get is 60s time bar and a blank screen.

If anyone out there knows how or has gotten this working, please share!


----------



## txporter (Sep 18, 2006)

Can you post a MediaInfo capture of the video information? What container is the video in? Are you pushing with pytivo?

I don't have a camera like that myself, but if you can provide a small clip I can see what can be done to extract the video and remux into something that Tivo will handle.

Most likely, I would use a program like eac3to to demux the video:

```
eac3to videofile -demux
```
And then remux with mp4box:

```
mp4box -add videofile.ac3 -add videofile.h264 -fps correctratehere outputfilename.mp4
```


----------



## jcthorne (Jan 28, 2002)

txporter is on the right track.

I would use MeGUI which works as a front end for those two and other tools.

As txporter says, post the mediainfo capture and I'm sure someone here will spot the trouble. Tivo is very particular but once you get the recipie nailed, it works every time.


----------



## Doug G (Mar 3, 2005)

I've tried all the freeware tools for the most part - SUPER, mp4box, eac3to, ffmpeg, avidemux, etc. The only one which seems to work decently is version 0.5 of ffmpeg. It extracts the AVC and AC3 streams ok, it extracts the AVC stream at 29.970fps. This is correct since although the video originates as 1080i60, its stored in the stream progressively and using the interlaced flag. But when I try to re-mux this into mp4 I get an error like "Seems stream 0 fps is different from container fps 29.970->59.940". I tried bypassing this, and the resulting file doesn't play. I also tried forcing the frame rate to 59.940 and that doesn't work either. I can't figure out how to change the container rate, the -r switch seems to have no effect. I'm using the -a/vcodec "copy" switches to ensure the video remains as-is (which should be perfectly fine for an mp4 container as its already encoded h.264 using high profile 4.0.) 

This seems like it should be trivial to do, yet I can find no on who's actually done it. Everyone seems to want to down-rez their video which causes a re-encode and I definitely don't want to do that. (Although I did do it on one clip for kicks that my wife wanted to post on her facebook page.) I just want to put the existing streams into the container format that Tivo can understand so I can push the file without transcoding.

I'll take a look at MeGUI but at this point I think I've probably exhausted all the possibilities. Am I really the only one who wants to be able to view their AVCHD home video on a HD Tivo this way? I find that hard to believe, but I also can't find anyone else who's done this!

EDIT: Here is the problem I seem to have with all other tools except ffmpeg. I used MeGUI (eac3to I think) to extract and then mp4muxer to remux, and I end up with a file which is indicated as twice as long as it really is, at half the bit rate. So the clip is actually 15Mbps for 1m54s, yet it shows up as 3m54s at 7.6Kbps:

Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 213 MiB
Duration : 3mn 49s
Overall bit rate : 7 812 Kbps
Encoded date : UTC 2010-03-10 13:24:46
Tagged date : UTC 2010-03-10 13:24:46

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : [email protected]
Format settings, CABAC : Yes
Format settings, ReFrames : 2 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 3mn 49s
Bit rate mode : Variable
Bit rate : 7 683 Kbps
Maximum bit rate : 9 010 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Resolution : 8 bits
Colorimetry : 4:2:0
Scan type : Interlaced
Scan order : Top Field First
Bits/(Pixel*Frame) : 0.124
Stream size : 210 MiB (98&#37
Title : Imported with GPAC 0.4.6-DEV (build 1)
Encoded date : UTC 2010-03-10 13:24:46
Tagged date : UTC 2010-03-10 13:24:49

Audio
ID : 2
Format : AC-3
Format/Info : Audio Coding 3
Codec ID : ac-3
Duration : 1mn 54s
Bit rate mode : Constant
Bit rate : 256 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Resolution : 16 bits
Stream size : 3.50 MiB (2%)
Title : Imported with GPAC 0.4.6-DEV (build 1)
Encoded date : UTC 2010-03-10 13:24:49
Tagged date : UTC 2010-03-10 13:24:49


----------



## txporter (Sep 18, 2006)

Can you upload that clip somewhere? I don't have any 1080i60 material to play around with, so I haven't messed with something like this. If you have a clip that is <100MB, I can send you a link to my plug server that you can use to upload.


----------



## Doug G (Mar 3, 2005)

Sure, PM me the link and I can dig up a small clip to send you later.


----------



## txporter (Sep 18, 2006)

Sent you a PM.


----------



## txporter (Sep 18, 2006)

I can't test this out on my laptop here at work since it is too slow to playback 1080i h.264 files. I did demux and remux the file as mp4. It seems like it should be fine. Download from the same link that I sent you to upload.

I used eac3to to demux and mp4box(beta version) to remux.

Here is a batch file to batch demux/remux all .m2ts files in a directory and direct mp4 files to /output directory.


```
setlocal
set mp4box="D:\mp4box\mp4box.exe"
set eac3to="D:\eac3to\eac3to.exe"

mkdir output

FOR &#37;%A IN (*.m2ts) DO (
%eac3to% %%A %%~nA.ac3 %%~nA.h264
%mp4box% -add %%~nA.ac3 -add %%~nA.h264 -fps 59.94 %%~dpAoutput\%%~nA.mp4
)
```
You need to point the set commands to wherever you placed eac3to and mp4box.

update: Looks like we might need to mux at 59.94fps


----------



## gbrown (Oct 31, 2006)

You might try this. I just found it this morning and haven't tried it yet.

http://www.winxdvd.com/giveaway/


----------



## txporter (Sep 18, 2006)

gbrown said:


> You might try this. I just found it this morning and haven't tried it yet.
> 
> http://www.winxdvd.com/giveaway/


He is trying to remux his video, not transcode them.


----------



## Doug G (Mar 3, 2005)

txporter - thanks for the try, but the 1080i60 clip you made does the same thing the one I made does - it plays for about 1/2 second, then its all garbled.

There must be some basic incompatibility with the way 1080i60 video is stored in a m2ts vs mp4 container. Think I'll post over on vhelp forum and see if anyone over there knows.

Will keep everyone updated on any progress.


----------



## Doug G (Mar 3, 2005)

OK - Good news, bad news.

Good news, I was able to use ripbot264 to successfully create an HD mp4 file that I was able to push to my HD Tivo using streambaby.

Bad news, not sure why but to re-encapsulate the High Profile 4.0 AVC video stream into an MP4 container, it had to transcode the video. I have no idea why this was necessary since its already in AVC/H.264 High Profile 4.0 format?! A 2min clip took took 20min to re-encode on my 2.2GHz Core2Duo so not really that practical for hours of video.

But at least I got something to work!

UPDATE: Using MediaInfo to look at both the source AVCHD (m2ts) and resulting mp4 files, as I feared it seems mp4 has no support for interlaced video. This explains why a "transcode" was necessary, to deinterlace the source. It also changed the ReFrames from 2 to 3. Guess maybe I need to investigate shooting in 30p mode and see if that stream can be directly re-muxed into an MP4 container.


----------



## txporter (Sep 18, 2006)

Doug G said:


> UPDATE: Using MediaInfo to look at both the source AVCHD (m2ts) and resulting mp4 files, as I feared it seems mp4 has no support for interlaced video. This explains why a "transcode" was necessary, to deinterlace the source. It also changed the ReFrames from 2 to 3. Guess maybe I need to investigate shooting in 30p mode and see if that stream can be directly re-muxed into an MP4 container.


I don't think this is true. The version of the clip that I transcoded to 720x400 is still interlaced. I still have it up on my server. You can try downloading that and pushing it up to your tivo to see if works for you. Hopefully, you will get a response from poisondeathray or manono or jagabo on videohelp if you post over there. They tend to be very helpful and can usually help figure things out. Poison especially seems to have a lot of knowledge about video cameras. Not sure why it is so difficult to remux those m2ts clips into something that works in a mp4 container.


----------



## wavelet (May 15, 2010)

I share Doug G's frustration. I have been surprised and very disappointed by how many video tools I have been using happily for many years have suddenly keeled over when presented with interlaced H.264! Here's a summary of what I found works (not much) and doesn't work (lots):

Codecs:
The only directshow codec I have gotten to work is the one from DivX. Forget about ffdshow. WMP12 under Windows 7 also plays interlaced MPEG4 correctly, but doesn't use directshow. Another solution which works is Donald Graft's DGAVCDec frame server with avisynth.​Containers
Matroska:
eac3to will write interlaced H.264 into a mkv container correctly when extracting it from another format, but cannot mux audio into the same file.

mkvmerge (part of mkvtoolnix) does not handle interlaced H.264 correctly. The Resulting file has a duration set to twice what it should be and the 'Interlaced' flag is incorrectly set to 0. This bug has been flagged to the author. mkvmerge used to have the same issue with interlaced MPEG2 and it was fixed, so perhaps this will be fixed one day.​MP4:
As noted by txporter, MP4Box seems to mux interlaced H.264 into an MP4 container successfully if you set the fps parameter to the field rate rather than the frame rate (i.e. twice the frame rate). By 'successfully' I mean the resulting .mp4 file is played back correctly by software players using the codecs I have listed above. Doug G notes, however, that the result does not stream successfully to a STB. Interestingly, his problem occurs after 0.5s of playback. This by coincidence is the default interleaving period used by MP4Box. Perhaps Doug G could try using a different interleaving period ('-inter' parameter) or disabling it (-flat). Other things to try are fragmenting (-frag) and hinting (-hint).

ffmpeg does not work. It has the same issue as mkvmerge and MP4Box with fps set to the frame rate, i.e. it produces a file with the duration twice what it should be.​MPEG transport stream:
I have successfully muxed interlaced H.264 to a .ts file with tsMuxeR. The result plays back well both on a PC and on my STB (a DreamBox D8000HD).​Others:
Other container formats to try would be AVI and QuickTime. I haven't tried these out yet.​


----------

