# eac3to, mp4box or mp4creator?



## orangeboy (Apr 19, 2004)

I have come across an mkv file that is 1080p30. I see that eac3to has an option:

```
-changeTo24.000    change source fps to "23.976", "24.000", "25.000", ...
```
mp4box has:

```
-fps FPS               forces frame rate for video and SUB subtitles import
```
and mp4creator has:

```
-rate=<fps>             Video frame rate, e.g. 30 or 29.97
and
-timescale=<ticks>      Time scale (ticks per second)
```
I'd like to modify mkv2tivomp4.bat to account for 1080p content greater than 24fps by utilizing one of the options listed above. The question is, which would be the best one? I've got a version now that correctly parses out and identifies the resolution, scan mode (progressive or interlaced), and framerate, but I'm stuck now trying to figure out if the framerate should be altered at demux time with eac3to, or at remux time with either mp4creator or mp4box.

Any suggestions or experience in doing so?


----------



## jcthorne (Jan 28, 2002)

Those options are used for correcting frame rates and aligning audio/video/subtitles. They cannot be use to change the frame rate as that will require re-encoding the video stream. Do you want to get into command line x264 processing and the time it takes?


----------



## orangeboy (Apr 19, 2004)

jcthorne said:


> Those options are used for correcting frame rates and aligning audio/video/subtitles. They cannot be use to change the frame rate as that will require re-encoding the video stream.


Given the time it took for eac3to to demux, I _had_ hopes that wasn't the case:


```
------------------------------------------------------------------------------
MKV, 1 video track, 1 audio track, 1:55:22, 30p /1.001
1: h264/AVC, 1080p30 /1.001 (16:9)
2: DTS, 5.1 channels, 24 bits, 1509kbps, 48kHz
[a02] The ArcSoft and Sonic decoders don't seem to work, will use libav instead.
[a02] Extracting audio track number 2...
[v01] Extracting video track number 1...
[a02] Decoding with libav/ffmpeg...
[a02] Changing FPS from 29.970 to 23.976...
[a02] Encoding AC3 <448kbps> with libAften...
[v01] Creating file "Test.h264"...
[a02] Creating file "Test.ac3"...
[a02] Clipping detected, a 2nd pass will be necessary.  <WARNING>
[a02] Starting 2nd pass...
[a02] Extracting audio track number 2...
[a02] Decoding with libav/ffmpeg...
[a02] Changing FPS from 29.970 to 23.976...
[a02] Encoding AC3 <448kbps> with libAften...
[a02] Applying -0.2dB gain...
[a02] Creating file "Test.ac3"...
Video track 1 contains 207451 frames.
eac3to processing took 5 hours, 23 minutes.
Done.
```
That was on my PIII @850MHz machine. Running MediaInfo against "Test.h264" did indeed still reflect 29.970 fps. I'm in the process of remuxing at the moment, because I am curious as to what actual changes (if any) to the output will be seen. Perhaps I've just now introduced out of sync audio and video?



jcthorne said:


> Do you want to get into command line x264 processing and the time it takes?


While not terribly excited about introducing another step into process of (quickly) creating a TiVo compatible file, running it through x264 appears to be necessary for 1080p > ~24 fps. So sure! If you have some x264 command line recipes that would change fps without introducing too much* or no quality degradation, I'd be interested. :up:

*of course "too much" is subjective. If the process is merely discarding every ~5th frame, my eyes would probably not notice any change in quality. If the process involves an actual transcode, a quality change may become noticeable.


----------



## jcthorne (Jan 28, 2002)

I guess you are contemplating recoding files for the TivoHD as 1080p30 files play fine on a Premiere, they just get displayed as 1080i. Never tried 1080p30 on the TivoHD as I was only using 720p back then. For all operations of re-encoding I use MeGUI as a front end for x264 so have no command line help to offer you. But if your file took 5 hrs to demux, that machine could easily take DAYS to re-encode.


----------



## orangeboy (Apr 19, 2004)

jcthorne said:


> I guess you are contemplating recoding files for the TivoHD as 1080p30 files play fine on a Premiere, they just get displayed as 1080i. Never tried 1080p30 on the TivoHD as I was only using 720p back then. For all operations of re-encoding I use MeGUI as a front end for x264 so have no command line help to offer you. But if your file took 5 hrs to demux, that machine could easily take DAYS to re-encode.


Actually, this is for the Premiere. I guess it's not a fps issue then. When I try to playback this file after pushing with pyTivo, it just outright fails with no sound or picture. Streaming it with Streambaby does the same. I had only assumed it was an fps issue because it was the first thing that I noticed was different with files that did playback successfully.

But yeah, I don't usually expect too much "heavy lifting" processor-wise on that box. It's set up with a few harddrives for file serving. My other box that I normally do transcoding on is busy doing just that: transcoding a collection of old files to mp4.


----------



## orangeboy (Apr 19, 2004)

jcthorne said:


> ...But if your file took 5 hrs to demux, that machine could easily take DAYS to re-encode.


Time taken when NOT specifying either -slowdown or -changeTo##### eac3to options:


```
MKV, 1 video track, 1 audio track, 1:55:22, 30p /1.001
1: h264/AVC, 1080p30 /1.001 (16:9)
2: DTS, 5.1 channels, 24 bits, 1509kbps, 48kHz
a02 The ArcSoft and Sonic decoders don't seem to work, will use libav instead.
v01 Extracting video track number 1...
a02 Extracting audio track number 2...
a02 Decoding with libav/ffmpeg...
a02 Encoding AC3 <448kbps> with libAften...
v01 Creating file "test.h264"...
a02 Creating file "test.ac3"...
a02 Clipping detected, a 2nd pass will be necessary.
a02 Starting 2nd pass...
a02 Extracting audio track number 2...
a02 Decoding with libav/ffmpeg...
a02 Encoding AC3 <448kbps> with libAften...
a02 Applying -0.11dB gain...
a02 Creating file "test.ac3"...
Video track 1 contains 207451 frames.
eac3to processing took 1 hour, 45 minutes.
Done.
```
The difference in the resulting files was the ac3 files with either -slowdown or -changeTo were substantially larger, and had a longer duration, while the h264 files remained the same. I see now that it is a moot point, and absolutely did not have the desired effect that I was looking for.

For now, I'll just concede that those files that would seem to be compliant, but don't successfully playback, will have to be re-encoded with a known set of "good" parameters. So depending on how you look at it, re-encoding will be either more or less expensive* cpu-wise (not monetarily.)

*Coming from a mainframe background, it was desired to have the big iron running as close to 100% cpu utilization as possible, that way the full potential of it's capabilities was realized. With the "squatty boxes", it seemed the higher the cpu utilization, (perceived) performance would take a hit, so keeping cpu utilization lower would be attempted. If the desired goal is 20% utilization, that's 80% of the potential being wasted, which to me would be more expensive since I'm not realizing the full potential. But I ramble on...


----------



## txporter (Sep 18, 2006)

Can you post the mediainfo for the file that is causing trouble? I am wondering if it was maybe encoded with a level higher than 4.1.


----------



## orangeboy (Apr 19, 2004)

txporter said:


> Can you post the mediainfo for the file that is causing trouble? I am wondering if it was maybe encoded with a level higher than 4.1.


Aye. MediaInfo text attached.
Here's my tale at VideoHelp.com. Post #11 from PuzZLer has me a bit confused though:



PuzZLer said:


> Hi again.
> 
> Took another look at those settings. I'm actually surprised, and impressed if so, in the TiVo profile including normal b-pyramids - many devices/decoders, including blu-ray, could choke on those without at least a strict version of them.
> 
> Interesting.


I'm confused because I don't know what "normal b-pyramids" are, or what profile PuzZLer is referring to! 
I'm wondering if it's the sample that I uploaded that contains the normal b-pyramids, and that's why I can't get the file to play on the Premiere.


----------



## jcthorne (Jan 28, 2002)

Other than the audio needs to be converted to ac3 from dts, I really see nothing wrong with the video section. Donno. Perhaps someone else has ideas. I'd be where you are and just re-encode the file and move on. Perhaps the video stream is not exactly what mediainfo thinks it is and tivo chokes on it. Just a guess as I have had it happen before. If you did not encode the file, you really dont know what internal parameters it was encoded with, despite what mediainfo reports.


----------



## txporter (Sep 18, 2006)

Yeah, I saw your post over on Videohelp.com after posting on here. I don't really see anything wrong with it either. It looks to be the default x264 (medium preset) encoding settings using CRF=18 except reference frames were changed from 3 to 5 and deblock was changed from 0:0 to -2:-1. Perhaps the number of reference frames is a problem?? I think that has been shown to be a problem for blu-ray compliancy. Not sure, I don't mess with it.

Puzzler is referring to this setting (highlighted in red):

```
cabac=1 / ref=5 / deblock=1:-2:-1 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=6 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / constrained_intra=0 / bframes=3 / [COLOR="Red"][B]b_pyramid=0[/B][/COLOR] / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=18.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
```
You can see some comments about it here on the MeGUI wiki for x264. He is really just saying that he is surprised that Tivo's decoder don't require the same compliance that blu-ray players do. Not sure why he is surprised though. It seems that blu-ray players are always more strict than other media players. At any rate, I have seen no real problems decoding h.264 that weren't related to framerate, frame size or audio.


----------



## orangeboy (Apr 19, 2004)

txporter said:


> Yeah, I saw your post over on Videohelp.com after posting on here. I don't really see anything wrong with it either. It looks to be the default x264 (medium preset) encoding settings using CRF=18 except reference frames were changed from 3 to 5 and deblock was changed from 0:0 to -2:-1. Perhaps the number of reference frames is a problem?? I think that has been shown to be a problem for blu-ray compliancy. Not sure, I don't mess with it.
> 
> Puzzler is referring to this setting (highlighted in red):
> 
> ...


It makes my head hurt trying to think of all the things it could be. Probably because I'm ignorant to most if not all the x264 options represent, even with the x264 wiki to reference! The code snippet above is overwhelming to me.


----------



## muerte33 (Jul 4, 2008)

Are there any tweaks that we can use to help in the synching of audio to video?
My MKV file works great, but the MP4 file that is created is way out of synch.
Thanks!

Never mind, I found another app that seems to take longer to run, but it synchronizes audio/video properly on the MKV file I had.
http://www.videohelp.com/tools/MkvToMp4


----------



## jcthorne (Jan 28, 2002)

orangeboy said:


> It makes my head hurt trying to think of all the things it could be. Probably because I'm ignorant to most if not all the x264 options represent, even with the x264 wiki to reference! The code snippet above is overwhelming to me.


I looked again at your mediainfo and now see something I missed previously. 5 reference frames is beyond level 4.1 for 1080 resolution content. 4 ref frames is the max. Tivo will choke if this is exceeded. If the level is reported to tivo as 4.1 it will download but not play. If it is indicated as level 5 (which it is) tivo will not download the content.

I also have had poor luck with ANY 1080p30 content. Some plays as 1080i some chokes. I now re-encode any 1080p content >24fps to avoid problems. Its rare anyway and usually encoded wrong when I do see it.

Have you done any further development of the mkv2tivomp4.bat program? I still use it all the time.


----------

