# Best way to convert to MP4/H264?



## AbMagFab (Feb 5, 2001)

I've now burned through multiple tools looking for one that will:
1) Convert HD MPEGs from Tivo to MP4, with no apparently loss in audio or video quality
2) Reduce the space needed, ideally at least 50%
3) Ideally be in a format that can be natively streamed to the iPad

The main issues I've had so far include:
- Most only support 2 channel audio
- All result in horribly choppy video, even at the highest video setting)
- Many times the size is the same as the original

I've tried Xillisoft HD, Xillisoft iPad, AVS Video converter, Nero 10 Recode, and a couple others, and none come even close (at least the way I was using them).

Surely someone else must be doing this - any advice out there?

Thanks in advance!


----------



## fyodor (Sep 19, 2006)

Have you tried Moyekj's KMTTG tool? It has various handbrake and FFMPEG profiles and automates pulling from the tivo and stream-reindexing. I've generally had pretty good results with it.

To be honest though, even with good tools, transcoding is such a giant, time-consuming PITA that I rarely bother with it. Hard drive space is so freakin cheap now that it's not worth my time. TigerDirect is selling 2TB hard drives for 99 bucks each. For $200 you can store about 800 hours of HD MPEG-2 video.



AbMagFab said:


> I've now burned through multiple tools looking for one that will:
> 1) Convert HD MPEGs from Tivo to MP4, with no apparently loss in audio or video quality
> 2) Reduce the space needed, ideally at least 50%
> 3) Ideally be in a format that can be natively streamed to the iPad
> ...


----------



## dlfl (Jul 6, 2006)

fyodor said:


> ........ Hard drive space is so freakin cheap now that it's not worth my time. TigerDirect is selling 2TB hard drives for 99 bucks each. For $200 you can store about 800 hours of HD MPEG-2 video.


Your point is valid but not as strong as you make it. You're assuming 2.5 GB per hour of HD MPEG-2, or a total bit rate of 5.56 Mbps including audio. This would be well below average MPEG-2 HD quality. Using 10 Mbps, which still isn't really good HD quality, the number comes out at 444 hrs for a 2T drive.

TiVo estimates 144 or 157 hrs of HD for a 1T drive.


----------



## dlfl (Jul 6, 2006)

AbMagFab said:


> I've now burned through multiple tools looking for one that will:
> 1) Convert HD MPEGs from Tivo to MP4, with no apparently loss in audio or video quality
> 2) Reduce the space needed, ideally at least 50%
> 3) Ideally be in a format that can be natively streamed to the iPad
> ...


I know from your posts on other threads that you have some version of VideoReDo. Assuming you have the minimum version ("Plus"), I believe you can upgrade to the H.264 (i.e., MPEG-4) version TVSuite 4, for around $50. 
You can also free-trial it uncrippled for 15 days. It will pass through 5 channel AC3 into a .mp4 container while transcoding to H.264.

fyodor's point about whether it's worth the time and trouble to transcode is a valid one.


----------



## fyodor (Sep 19, 2006)

dlfl said:


> Your point is valid but not as strong as you make it. You're assuming 2.5 GB per hour of HD MPEG-2, or a total bit rate of 5.56 Mbps including audio. This would be well below average MPEG-2 HD quality. Using 10 Mbps, which still isn't really good HD quality, the number comes out at 444 hrs for a 2T drive.
> 
> TiVo estimates 144 or 157 hrs of HD for a 1T drive.


Yeah, I somehow mixed up the numbers. I was thinking 800 hours for 4 terabytes or 5 gigs an hour, which would be about 11-12 megabits/s.

Also, WRT to the original post, I don't think that you're going to get any sort of 50 percent reduction without a noticeable drop in quality. It'll still look decent, but not as good as the HD MPEG-2.

While it's certainly possible to have a 7-8 megabits/s MP4 transcode that looks very good, this is usually involves starting with much higher quality source material and transcoding from that. A 6-7 megabit/s MP4 transcoding from your cable company's already degraded MPEG-2 stream just isn't going to look that great.


----------



## fyodor (Sep 19, 2006)

While we're on the topic - 2TB hard drive for $72 after rebates.

http://www.dealigg.com/story-Wester...-FXR100-DATA-Transfer-Cable-1-Donation-Cure-2


----------



## MichaelK (Jan 10, 2002)

my 2 cent's- for me the only reason to convert from mpeg2 to mpeg4 is to make a format your ipod, cell phone, or other portable device can handle. Since the screens are so small the quality doesn't need to be all that great. So anything works for that. Other wise the days and days of effort to convert everything isn't worth the time compared to the cost of drives.

I guess the ipad makes a problem though- if it can't deal with mpeg2? The screen is much bigger so quality could matter. So would be interesting to see what others think is the best way to convert in the most lossless manner- ignoring file size. 

At the moment I use Winff (a gui front end for ffmpeg) as suggested in a thread here. I only need it to convert for my kids to watch on their nano's and to use the nano's composite out to feed the dvd screen in my wifes car. WinFF built in profiles for 'ipod tv out' work fine for my needs.


----------



## Dan203 (Apr 17, 2000)

MichaelK said:


> Other wise the days and days of effort to convert everything


This isn't really the case any more. If you have a dual core PC made in the last 2 years or so* then you should be able to convert to H.264 in less then real time. Meaning a 1 hour video should take less then an hour to convert. And if you have something really fast, like a quad core i7, then it should only take about 15-20 minutes to convert that 1 hour program.

Dan

* Laptop processors are still a little slow at video encoding, but they're still significantly faster then a few years ago.


----------



## MichaelK (Jan 10, 2002)

Dan203 said:


> This isn't really the case any more. If you have a dual core PC made in the last 2 years or so* then you should be able to convert to H.264 in less then real time. Meaning a 1 hour video should take less then an hour to convert. And if you have something really fast, like a quad core i7, then it should only take about 15-20 minutes to convert that 1 hour program.
> 
> Dan
> 
> * Laptop processors are still a little slow at video encoding, but they're still significantly faster then a few years ago.


I dont even own a desktop, never mind a quad core. At work I have another laptop and access to servers- there is one desktop that literally has a pentium in it. So basically my options at home are a 2+ year old laptop- so not the fastest, A year old netbook- so just an atom, ot a couple year old windows home server- without so much as a vga out and just a bottom end low power amd chip. So it's still days- laughing.

I've got family that works at Intel so they'd shudder to hear me say it- but aside from fiddling with video I dont find I need to spend 2 grand every year on the latest and greatest pc just to keep up like i did in years past.

But that aside- it's not really the time of the actual encode- it's the extra steps, clicking, different programs, and general fiddling that annoy me. For situations where you can automate it I really wouldn't care one bit. But when you are trying to convert DVD's to tivo ready mpeg2 and than to ipod format it gets annoying all the various clicks and user intervention involved.

I should have clarified that for tivotogo life seems to be good (I think it's just a maatter kmttg all set automated- right?)- But it's just such a hassle (although much better than the past) with the various tools for DVD's. And even if one finds something that works for them, you typically had to fight through testing 12 different methods with 50 different settings like AbMagFab has started.

And once we fight our way though our DVD collections then we have to figure out what to do with all the new bluray discs we are collecting...


----------



## AbMagFab (Feb 5, 2001)

Right - I'm trying to get things into a format that can be easily streamed to an iPad. I'm finding that the PCH for TV is preferable to a Tivo for watching server-side media, and an iPad is far preferable for remote streaming. The PCH can play anything, but the iPad can only play H264.

I have TVSuite, but apparently they only have v3 from the site. Edit - found v4 buried only in the forums? Weird... Downloaded, bought, trying now on a Tivo file, will try on an M2TS shortly...

Definitely a CPU hog! I have a CoreQuad Q6600, and all 4 cores are pegged. Will an i7 be that much better?


----------



## txporter (Sep 18, 2006)

fyodor said:


> Also, WRT to the original post, I don't think that you're going to get any sort of 50 percent reduction without a noticeable drop in quality. It'll still look decent, but not as good as the HD MPEG-2.
> 
> While it's certainly possible to have a 7-8 megabits/s MP4 transcode that looks very good, this is usually involves starting with much higher quality source material and transcoding from that. A 6-7 megabit/s MP4 transcoding from your cable company's already degraded MPEG-2 stream just isn't going to look that great.


I don't think that I agree with this statement. I suppose it is how you attempt to convert the video. For 1080i material, everything that I transcode originated as FILM source (23.976fps). If I IVTC the material and encode at CRF 20 in x264, I can take a 14mbps source down to 7mbps (I use avisynth and x264). Personally, I think CRF 22 encodes look fine for HD material so you can save even more bitrate. And for 720p material, you are in an even better spot. Even though it is broadcast at 59.94fps, most all material is again sourced from 23.976fps material. Cutting out all of the dups and then transcoding to h.264 can save a lot of space. Even with MPEG2 re-encodes, I will take 720p material broadcast at 14 mbps and drop it down to 6 mbps without a noticeable drop in quality. With x264, I can transcode to around 3 mbps.


----------



## txporter (Sep 18, 2006)

AbMagFab said:


> Right - I'm trying to get things into a format that can be easily streamed to an iPad. I'm finding that the PCH for TV is preferable to a Tivo for watching server-side media, and an iPad is far preferable for remote streaming. The PCH can play anything, but the iPad can only play H264.
> 
> I have TVSuite, but apparently they only have v3 from the site. Edit - found v4 buried only in the forums? Weird... Downloaded, bought, trying now on a Tivo file, will try on an M2TS shortly...
> 
> Definitely a CPU hog! I have a CoreQuad Q6600, and all 4 cores are pegged. Will an i7 be that much better?


Transcoding/re-encoding is CPU intensive. It SHOULD use all 4 of your cores to be most efficient. An i7 will also attempt to use as much CPU process time as possible. It will just get through the encode faster because of the higher frequencies and pipelining/threading.

I don't have a PCH or iPad, so I don't have any personal experience with them. My understanding is that iPad will only accept h.264 video with up to level 3.1 (through itunes at any rate). That restricts the video to [email protected] (wiki). I don't know what the restrictions are on PCH, but I think it accepts a much wider array of formats and specifications. My experience with TivoHD is that any H.264 video over ~25fps up to level 4.1 will play back fine. Displaying at 23.976fps highllights at least one issue on TivoHD (and I think H.264 needs to be 29.97fps to work on Series3). My understanding is that Tivo Premiere has fixed the <25fps framerate playback issue. I think you are more likely to find 1 format that works with both PCH and Tivo Premiere than you are with PCH and iPad. Unless, of course, you don't mind dropping resolution.


----------



## fyodor (Sep 19, 2006)

Dan,

I'm curious what settings you're using since your results are very different from what I've seen in reviews and in my own experiences.

Looking at the test results here (the second pass, which is the actual encoding step), it shows a reasonably fast dual core processor (E5300) getting about 8.7 frames per second for a 720p encode. Only the i7 processors encode at something resembling realtime.

http://anandtech.com/show/2839/4

And that result is, if anything, faster than the actual performance that I've seen. Encoding a 2.5 hour movie on a dual core system, that's about 8 hours that the computer is churning away on an encode and isn't available for other CPU intensive tasks.



Dan203 said:


> This isn't really the case any more. If you have a dual core PC made in the last 2 years or so* then you should be able to convert to H.264 in less then real time. Meaning a 1 hour video should take less then an hour to convert. And if you have something really fast, like a quad core i7, then it should only take about 15-20 minutes to convert that 1 hour program.
> 
> Dan
> 
> * Laptop processors are still a little slow at video encoding, but they're still significantly faster then a few years ago.


----------



## fyodor (Sep 19, 2006)

I can only talk from my own experience - I've used the various premade handbrake and KMTTG profiles on KMTTG and (back in my SageTV days) the various sagetv plugins that had profiles for mencoder and handbrake. At best I'd get something that looked pretty good, but not as good as the original. It's possible that others have had more success with different tools.



txporter said:


> I don't think that I agree with this statement. I suppose it is how you attempt to convert the video. For 1080i material, everything that I transcode originated as FILM source (23.976fps). If I IVTC the material and encode at CRF 20 in x264, I can take a 14mbps source down to 7mbps (I use avisynth and x264). Personally, I think CRF 22 encodes look fine for HD material so you can save even more bitrate. And for 720p material, you are in an even better spot. Even though it is broadcast at 59.94fps, most all material is again sourced from 23.976fps material. Cutting out all of the dups and then transcoding to h.264 can save a lot of space. Even with MPEG2 re-encodes, I will take 720p material broadcast at 14 mbps and drop it down to 6 mbps without a noticeable drop in quality. With x264, I can transcode to around 3 mbps.


----------



## dlfl (Jul 6, 2006)

If you need to resize 1080 to 720 (or less) you will not output an hour of H.264 video in 15 or 20 minutes using TVS4 on an i7. (Mine is an i7 860 at 2.8 GHz.) I went through this with phd and DanR in **this thread on the VRD forums**  starting at post #15. I just rechecked this with Build 600 to verify it hasn't changed since then. I get 35% or so overall CPU usage for my test encode and it runs at 24.6 fps.

I sent my file to support (DLFLANNERY_topic16356) and DanR verified what I was seeing on a Quad 6600. We had some private email exchanges that weren't reflected in the referenced thread. The conclusion, as I understand it, is that some processing tasks, including resizing, some types of deinterlaceing, and MPEG-2 decoding currently are single threaded. I ran other tests that didn't involve resizing and they ran at 80% overall CPU usage. DanR stated that improving this was on the to do list (and apparently it still is).

The test file in question was 1920x1080 at 14.89 Mbps estimated bit rate, and I was encoding to 1280x720 at 3 Mbps average bit rate, using Smart Interlace and Auto Framerate.

Getting my test encode to run at the 1-hour-in-20-mins rate mentioned by Dan203 earlier in this thread (i.e., 90 fps) would require an average CPU usage of 128% (i.e., it aint gonna happen). However something in the 30 mins range seems possible with multi-threaded enhancements to get the average CPU usage up to 80 or 90%.


----------



## fyodor (Sep 19, 2006)

3 Mbps is also a pretty low bitrate for 720p. It's been my experience that the encode bitrate is one of the primary factors in encode time (much more so than source bitrate since encoding is much harder than decoding).

The OP is looking for something that is very close to the source material, which probably means more like a 6-7 Mbps encode. I can't say with complete precision exactly how encode time scales with bitrates, but I'd be surprised if a 6Mbps encode didn't take at least 50 percent longer.



dlfl said:


> If you need to resize 1080 to 720 (or less) you will not output an hour of H.264 video in 15 or 20 minutes using TVS4 on an i7. (Mine is an i7 860 at 2.8 GHz.) I went through this with phd and DanR in **this thread on the VRD forums**  starting at post #15. I just rechecked this with Build 600 to verify it hasn't changed since then. I get 35% or so overall CPU usage for my test encode and it runs at 24.6 fps.
> 
> I sent my file to support (DLFLANNERY_topic16356) and DanR verified what I was seeing on a Quad 6600. We had some private email exchanges that weren't reflected in the referenced thread. The conclusion, as I understand it, is that some processing tasks, including resizing, some types of deinterlaceing, and MPEG-2 decoding currently are single threaded. I ran other tests that didn't involve resizing and they ran at 80% overall CPU usage. DanR stated that improving this was on the to do list (and apparently it still is).
> 
> ...


----------



## jcthorne (Jan 28, 2002)

I use MeGUI which is a front end for avisynth, x264 and mp4creator and a number of other tools. 720p encodes for tivo with ac3 5.1 audio run at about 5.5fps on my dual core laptop in the background. Use a CRF of 22 in x264 and am pretty happy with the results. Tivo likes the mp4s.


----------



## AbMagFab (Feb 5, 2001)

jcthorne said:


> I use MeGUI which is a front end for avisynth, x264 and mp4creator and a number of other tools. 720p encodes for tivo with ac3 5.1 audio run at about 5.5fps on my dual core laptop in the background. Use a CRF of 22 in x264 and am pretty happy with the results. Tivo likes the mp4s.


Do you have the specifics on things like bitrate that you're using?


----------



## AbMagFab (Feb 5, 2001)

dlfl said:


> I know from your posts on other threads that you have some version of VideoReDo. Assuming you have the minimum version ("Plus"), I believe you can upgrade to the H.264 (i.e., MPEG-4) version TVSuite 4, for around $50.
> You can also free-trial it uncrippled for 15 days. It will pass through 5 channel AC3 into a .mp4 container while transcoding to H.264.
> 
> fyodor's point about whether it's worth the time and trouble to transcode is a valid one.


Okay, I upgraded, and it seems to sort of work, but:
1) It converts to 2-channel, not 5.1
2) The resulting file periodically crashes the iPad

So I guess a follow-on question is, how to convert M2TS BluRay files to something that is easily playable on the iPad?


----------



## txporter (Sep 18, 2006)

fyodor said:


> 3 Mbps is also a pretty low bitrate for 720p. It's been my experience that the encode bitrate is one of the primary factors in encode time (much more so than source bitrate since encoding is much harder than decoding).
> 
> The OP is looking for something that is very close to the source material, which probably means more like a 6-7 Mbps encode. I can't say with complete precision exactly how encode time scales with bitrates, but I'd be surprised if a 6Mbps encode didn't take at least 50 percent longer.


I think if you use the setting that dlfl is using in VRD (Auto Framerate), then VRD will drop every other frame (720p broadcast of FILM material has a 3:2:3... pattern of duplicate frames). That leaves you with basically a telecined video stream (4th and 5th frames are duplicates rather than telecined). Now you have half as many frames every second to encode. From what encodes I have done, 3 mbps is fine for 720p material that was originally FILM. If you have true 720p (unique frames at 59.94fps), then you will need more than 3 mbps.

@AbFabMag- jcthorne is using the constant quality encoding profile with x264. The final bitrate will vary depending on the source. With crf 22 and 720p material (assuming that he removes dups back to 23.976fps), I would guess he is normally in the 2.5mbps to 4mbps range with his encodes.

@fyoder- I haven't really seen a correlation between encode time and target bitrate on x264. I would be surprised to see that this were true on MainConcepts H.264 encoder (VRD).


----------



## dlfl (Jul 6, 2006)

AbMagFab said:


> Okay, I upgraded, and it seems to sort of work, but:
> 1) It converts to 2-channel, not 5.1
> 2) The resulting file periodically crashes the iPad
> 
> So I guess a follow-on question is, how to convert M2TS BluRay files to something that is easily playable on the iPad?


OK, I said it would pass AC3 through -- I didn't say it was seamless! 
Downconverting to 2 channel is currently the default, apparently in all the distributed profiles. However look at the changelog post for TVS4, search for "AC3" yielding:



> [Change] H.264 AC3 with MP4: Added new attribute to profile: "allowAC3" to allow AC3 in MP4 saves. Requires special profile (see below).


And "below" is this link to a profile that passes AC3 through:
http://www.videoredo.net/msgBoard/attachment.php?attachmentid=645&d=1269346761

profiles are XML files and I believe the only thing different about this profile to do the AC3 pass-thru is the red part of this:

```
<AudioAttributes>
[COLOR="Red"]      <Encoder allowAC3="y">Auto</Encoder> [/COLOR]         
      <Bitrate>128</Bitrate> 
      <SampleRate>No Change</SampleRate> 
  </AudioAttributes>
```
I don't think the VRD profile editing gui supports changing this so, if not, you need to edit the profile XML file. The profiles are in OutputProfiles.xml located in My Documents\Videoredo.

I have no ideas about what may be causing the iPad crashes. Probably an issue of parameters to be compatible with the iPad (?).
If not done already, an iPad user should post a request on the VRD forums to come up with an iPad profile. They are usually pretty responsive.


----------



## fyodor (Sep 19, 2006)

AbMagFab said:


> Okay, I upgraded, and it seems to sort of work, but:
> 1) It converts to 2-channel, not 5.1
> 2) The resulting file periodically crashes the iPad
> 
> So I guess a follow-on question is, how to convert M2TS BluRay files to something that is easily playable on the iPad?


While there are a lot of knowledgeable people on this forum you might find it helpful to also repost this inquiry on the AVSForum HTPC section. There are a lot of people on that forum that reencode blu-ray files and they might even have some premade profiles/configurations for the iPad.


----------



## lrhorer (Aug 31, 2003)

dlfl said:


> Your point is valid but not as strong as you make it. You're assuming 2.5 GB per hour of HD MPEG-2, or a total bit rate of 5.56 Mbps including audio. This would be well below average MPEG-2 HD quality. Using 10 Mbps, which still isn't really good HD quality, the number comes out at 444 hrs for a 2T drive.
> 
> TiVo estimates 144 or 157 hrs of HD for a 1T drive.


Not only that, but while drives have become unbelievably inexpensive, storage costs still add up. My video server is essentially full, with a 12 drive RAID6 array providing about 9.8T of storage. Doubling that would require a minimum of seven 2T drives costing about $850 plus $1400 for an additional RAID chassis and $150 for an additional eSATA controller. That's only half of it, though, because I would also have to augment my backup server at a similar cost, so we're looking at between $3400 and $4000 to double the capacity of my video library. An elegant means of more or less painlessly re-coding the video files that impacts neither the PQ nor network transfer performance would be most welcome.

Actually, I am hoping the 3T drives are announced very soon and that by the end of 2010 or early 2011 the price per byte of the 3T drives will be comparable to the current price for 1.5T drives. That way I could triple the size of both arrays without having to purchase an additional RAID chassis.

Some of the videos I have average out to more than 18 Mbps, BTW.


----------



## dlfl (Jul 6, 2006)

txporter said:


> I think if you use the setting that dlfl is using in VRD (Auto Framerate), then VRD will drop every other frame (720p broadcast of FILM material has a 3:2:3... pattern of duplicate frames). That leaves you with basically a telecined video stream (4th and 5th frames are duplicates rather than telecined). Now you have half as many frames every second to encode. From what encodes I have done, 3 mbps is fine for 720p material that was originally FILM. If you have true 720p (unique frames at 59.94fps), then you will need more than 3 mbps.
> .................
> @fyoder- I haven't really seen a correlation between encode time and target bitrate on x264. I would be surprised to see that this were true on MainConcepts H.264 encoder (VRD).


My test clip is a live broadcast of a tennis match. Gspot says it is Interlaced at 29.97 frames/sec. The output mp4 is also at 29.97 fps.

I increased the target bit rate to 6 Mbps and the encode ran at 23.86 fps (down from 24.61 fps) with CPU usage about the same as before (~35%). Thus very little encode time increase with target bit rate.


----------



## fyodor (Sep 19, 2006)

dlfl said:


> My test clip is a live broadcast of a tennis match. Gspot says it is Interlaced at 29.97 frames/sec. The output mp4 is also at 29.97 fps.
> 
> I increased the target bit rate to 6 Mbps and the encode ran at 23.86 fps (down from 24.61 fps) with CPU usage about the same as before (~35%). Thus very little encode time increase with target bit rate.


Huh. Interesting.


----------



## Phantom Gremlin (Jun 20, 2002)

AbMagFab said:


> I've now burned through multiple tools looking for one that will:
> 1) Convert HD MPEGs from Tivo to MP4, with no apparently loss in audio or video quality
> 2) Reduce the space needed, ideally at least 50%
> 3) Ideally be in a format that can be natively streamed to the iPad


Lots of great suggestions already in this thread. Since you're specifically interested in the iPad I think you need to


target H.264, not MP4, since iPad has h/w support for former

target a width of 1024 to match iPad screen. That will probably mean less decoding work (therefore greater battery life) in iPad
That's just some theoretical ideas for now. I haven't been able to snag a 3G iPad locally so haven't done anything practical yet.


----------



## jcthorne (Jan 28, 2002)

AbMagFab said:


> Do you have the specifics on things like bitrate that you're using?


I leave it mostly to xvid defaults. Constant quality, single pass, CRF of 22, avc level 4.1. here is the xvid command line that meGUI uses:

--level 4.1 --preset slow --crf 22.0 --b-pyramid none

pretty simple stuff.


----------



## txporter (Sep 18, 2006)

jcthorne said:


> I leave it mostly to xvid defaults. Constant quality, single pass, CRF of 22, avc level 4.1. here is the xvid command line that meGUI uses:
> 
> --level 4.1 --preset slow --crf 22.0 --b-pyramid none
> 
> pretty simple stuff.


Just to be clear, those are x264 parameters, not xvid.


----------

