View Full Version : Is anyone pushing HD mp4 video with AC3 to TivoHD?
jcthorne
03-20-2009, 04:24 PM
If so, what work process and software are you using and how are your results?
I have found one process that works but its a long way round and take a good deal of time.
This is for HD video, not SD.
moyekj
03-20-2009, 04:39 PM
What's your current flow?
If you are on Mac then iTivo else if you are on Windows or Linux kmttg make it pretty easy/automated.
The longest, most painful part is the H.264 encoding which no matter what your flow will take a long time to encode from HD mpeg2 sources. If quality is top priority then multi-pass encoding would be needed which makes it even longer.
spocko
03-20-2009, 05:08 PM
if you are on Windows or Linux kmttg make it pretty easy/automated.
I thought kmttg could only pull recordings in one direction from tivo to pc? It sounds like the OP wants to push programs in the other direction, from pc to tivo.
I don't have any experience doing this yet, but I believe Tivo Desktop Plus, pyTivo, and Streambaby are the most common apps for sending programs back to the tivo. PyTivo and Streambaby have the ability to send mp4 files containing H.264+AC3 without having to transcode them. I don't know if there are any specific encoding requirements to enable that capability.
moyekj
03-20-2009, 05:15 PM
I think I read too much into the question. The hard part in my mind is creating the H.264 + AC3 files which I assumed the OP was talking about but now I realize that's not the case. The actual push back to Tivo portion is fairly easy with pyTivo or even easier use streambaby to stream them.
pyTivo pushes could be made a little friendlier by creating an auto watch folder push capability similar to Tivo Desktop instead of having to initiate push manually as is currently the case. Streaming with streambaby is the easiest way by far. (HME/VLC for streaming also works but I think currently doesn't have the moov atom handling portion built in yet which is why I usually recommend streambaby).
NOTE: Tivo Desktop Plus auto pushes transcode to mpeg2 when you have H.264 + AC3 - it will transcode those presumably because the codecs it's using don't recognize mp4 container with H.264 video + AC3 audio. You have to use AAC audio for it to not transcode with TD+. So pyTivo is the only choice for native pushes.
jcthorne
03-20-2009, 07:57 PM
Sorry, I did not mean to be cryptic. I am referring to pushing mp4 with AC3 video TO the tivo using pyTivo. For the transfer, pyTivo works just fine, no trouble there and its the only known solution at the moment.
My trouble is with the very exacting requirements for HD mp4 files that tivo will accept and play properly.
1280x720 exactly, ac3 audio at 448kbps or less, interleaved and streamable mp4 file using h264 level 4.1 video.
I have a work flow to create such files but its time consuming and uses 3 different pieces of software. Was just wondering if anyone else was using this feature and had a better way.
moyekj
03-20-2009, 08:10 PM
So the question is related to creating compatible mp4 files...
You still don't mention what your source video files are, but assuming mpeg2 then kmttg and ff_h264_med_rate or ff_h264_high_rate encoding profiles work.
(You can also create your own custom encoding profiles to tweak ffmpeg encoding parameters to suit your needs, but at least the above give known working starting points).
jcthorne
03-20-2009, 08:29 PM
My source files are mosty .mkv but kmttg looks interesting for mpg files. Very seldom see HD .mpg files though. Curious what settings you use in the tivo_hd profile though? I could not tell from the documentation and did not want to install since it really did not seem to suit what I am doing. I seldom download from tivo to the pc and seldom get video in mpeg2 format from anywhere else these days.
Any chance you intend to add other files types as inputs to kmttg? It looks very promising and MUCH easier to use if so.
moyekj
03-20-2009, 08:41 PM
It's using ffmpeg as follows:
ffmpeg -y -i INPUT -vcodec libx264 -coder 0 -level 41 -sameq -g 300 -bufsize 14745k -b 8000k -maxrate 16000k -bug "+autodetect+ms" -me epzs -trellis 2 -mbd 1 -acodec copy -f mp4 OUTPUT
(Audio codec is set to copy which coming from a Tivo mpeg2 file usually means AC3)
You say your sources are .mkv files, but that's just a video container that can contain a pretty wide variety of of video & audio types.
The above ffmpeg profile may also work starting with .mkv files but depending on what audio is contained you would have to modify to encode audio instead of copy.
(Also, if you install a fairly recent version of ffmpeg I think the -me option has changed to -me_method)
jcthorne
03-20-2009, 08:47 PM
how do you handle video files that are less than full frame hd? IE 1280x544 for example? Unless its padded to 1280x720 for the mp4, it will not play correctly on the tivo once pushed.
ffmpeg cannot recode the audio and place into an mp4 conainer in one pass. Its a bug in ffmpeg with its muxer. Yes, mkv can contain many things and the tivo is very particular on mp4 contents. So I need to rework whatever is in the mkv container into an mp4 container that works with tivo. Usually the video is h264 level 4.1 and below though so except for the aspect ratio issue, would not require re-encoding.
moyekj
03-20-2009, 08:54 PM
To date all my sources that I encode from originate from Tivos so non-standard resolutions have not been an issue and the above recipe has worked.
When you say "it will not play correctly on the tivo once pushed" what is the problem exactly? Is it just the aspect ratio that looks wrong? I have seen several cases of aspect ratios not being right when streaming other mp4 sources to my Tivos.
jcthorne
03-20-2009, 09:19 PM
Right, tivo does not correctly display the file. Usually errors to displaying it in a 4:3 pillarbox. If the file is padded to full frame 1280x720 it displays correctly.
It seems to do better with SD resolution files but still not always. I don't send much SD so really cannot comment on exactly when those work and dont.
Anyway, a widescreen HD movie scrunched up into a 4:3 pillarbox is not much worth watching, kind of useless.
adding -padbottom xx - padtop xx to the ffmpeg command line where xx = (720 - input file vert resolution)/2 fixes it during re-encode.
moyekj
03-20-2009, 10:07 PM
Perhaps if Tivo obtains aspect ratio information properly from the file it will show it correctly, so you may be able to use MP4Box to set proper aspect ratio to be used (-par trackID=PAR).
Example if video trackID is 1:
MP4Box -par 1=X:Y file.mp4
You can print out track info using MP4Box -info file.mp4.
NOTE: I just tried changing aspect ratio on a 4:3 mp4 clip I have using MP4Box and sure enough it affected the display ratio when streaming file to Tivo.
jcthorne
03-21-2009, 07:52 AM
But was it an HD clip?
I'll try your command line PAR commands on some sample files when tivo gets the stagingmind servers back up. For the moment I cannot push anything.
Thanks for the suggestion. Looks interesting and sure worth a try.
jcthorne
03-21-2009, 08:25 AM
I checked a few files and they all show a pixel aspect ratio of 1:1 which is correct but tivo does not display them this way. When tivo server comes back, I'll try lying to tivo and see what happens with other entries.
Again, this only seems to happen with HD resolution files in widescreen aspect ratios. If you wish I can send you an example file to tinker with.
moyekj
03-21-2009, 11:36 AM
Just experimented with a 1280x720 HD clip with a PAR of 1. By setting PAR = 3:4 (see below) I was able to squish it horizontally to display as if it were 4:3 aspect ratio when streaming to my S3.
PAR = DAR * Y / X
16/9:
(16/9) * 720/1280 = 1
4/3:
(4/3) * 720/1280 = 0.75 = 3:4
For your example with your 1280x544 clip displaying on a 16:9 display:
(16/9) * 544/1280 = 0.755555555 = 34:45
i.e. MP4Box -par 1=34:45 may achieve what you want
(I don't have such a clip to try it with so don't know if it works. Point me to an example if you wish)
jcthorne
03-21-2009, 04:23 PM
OK, thanks. I learned something. Will give it a try as soon as I can push to tivo again and let you know.
Rdian06
03-21-2009, 10:29 PM
Here's a star trek teaser trailer converted to mp4:
http://rapidshare.com/files/206525855/ST09_1_Vision.rar
Its resolution is 1920x800 and the Tivo stretches it to fill the full widescreen even when set to Panel aspect when transferred by push.
I then set the PAR on the file using MP4box and pushed it again after restarting pyTivo for good measure. Video was still stretched:
Here's the MP4Box info for the altered file:
* Movie Info *
Timescale 2997 - Duration 00:01:16.309
Fragmented File no - 2 track(s)
File Brand mp42 - version 1
Created: GMT Sun Mar 08 17:27:43 2009
File has no MPEG4 IOD/OD
Copyrights:
(eng) © 2008 Paramount Pictures. All Rights Reserved
Track # 1 Info - TrackID 1 - TimeScale 44100 - Duration 00:01:16.323
Media Info: Language "English" - Type "soun:mp4a" - 3287 samples
MPEG-4 Config: Audio Stream - ObjectTypeIndication 0x40
MPEG-4 Audio AAC LC - 2 Channel(s) - SampleRate 44100
Self-synchronized
Track # 2 Info - TrackID 2 - TimeScale 2997 - Duration 00:01:16.309
Media Info: Language "English" - Type "vide:avc1" - 2287 samples
MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21
AVC/H264 Video - Visual Size 1920 x 800 - Profile Main @ Level 4.1
NAL Unit length bits: 32
Pixel Aspect Ratio 20:27 - Indicated track size 1920 x 800
Synchronized on stream 1
jcthorne
03-21-2009, 11:02 PM
Looks like the mp4 player in tivo still has some bugs with regard to aspect ratio for HD files. Only way I know of to work around this for the moment is to re-encode the video to full frame before sending. IE 1920x1080 in this case. Although for me, I send every thing as 720p to save space since my video distribution, projector and bedroom tv all run at that resolution.
moyekj
03-21-2009, 11:52 PM
Here's a star trek teaser trailer converted to mp4:
http://rapidshare.com/files/206525855/ST09_1_Vision.rar
Its resolution is 1920x800 and the Tivo stretches it to fill the full widescreen even when set to Panel aspect when transferred by push.
I then set the PAR on the file using MP4box and pushed it again after restarting pyTivo for good measure. Video was still stretched
With this one setting PAR=1:1 displays perfectly on the Tivo (letterboxes top and bottom appropriately to display with proper aspect ratio) when streaming and/or pushing to Tivo.
So it looks to me with appropriate PAR settings you can get Tivo to display mp4 files properly.
Rdian06
03-22-2009, 01:04 AM
With this one setting PAR=1:1 displays perfectly on the Tivo (letterboxes top and bottom appropriately to display with proper aspect ratio) when streaming and/or pushing to Tivo.
So it looks to me with appropriate PAR settings you can get Tivo to display mp4 files properly.
Ah, interesting. I didn't try with PAR=1:1, but I just did now and like you said, it works on that clip.
So it looks like failing to specify PAR results in the Tivo guessing and stretching non 720/1080 in wierd ways. But actually setting PAR=1:1 (assuming that's what the source's actual PAR is) fixes the issue.
Cool. Now if only I could figure out why the Tivo seems to drop frames on the mp4's I produce by using MP4Box and MP4Creator to mux elementary streams extracted from mkv files with mkvextract. Trying to vary the interleave timing with MP4Box and forcing constant framerate with -nodrop and -packed on the import helped a little, but still not perfect. Also the Tivo doesn't seem to care about the hinting track, just that the file is interleaved.
Guess I'll just have to re-rip/re-encode the movies I care about.
Rdian06
03-22-2009, 02:24 AM
Spoke too soon. The Tivo seems to treat 1920 width resolutions and 1280 width resolutions differently.
With the source being 1920x800, you can set PAR 1:1 and it works.
But with source 1280x544, setting PAR 1:1 doesn't work. Picture appears to be pillarboxed and cropped on the right. Settings PAR 34:45 made it look double pillarboxed and still cropped on the right. Guess I'll experiment some more.
jcthorne
03-22-2009, 08:49 AM
I can verify that 1280x544 and setting par=1:1 does not work. Displays pillarboxed. I tried a number of par settings on a sample file and while they have an effect, none of the combinations I tried display properly.
moyekj
03-23-2009, 11:00 PM
I generated my own 1280x544 encoding and I too am truly baffled at how Tivo decoder is treating aspect ratio for those. Double pillar boxing and cutting off content when setting to 16:9 DAR makes no sense at all... No idea what the formula is but the correct setting should be a PAR value of 1:1 for that to show properly (and PC media players display it correctly with that PAR value). I thought that perhaps choosing 720p output on Tivo may make a difference (I usually have it on 1080i fixed) but that didn't change anything related to aspect ratio.
It doesn't bug me too much as I don't have encodings at that resolution but it would be nice to find out what Tivo is doing for those and not having to re-encode to a different resolution to fix the problem.
moyekj
03-25-2009, 11:17 AM
OK, here's an interesting clip on several levels:
http://tivostream.googlecode.com/files/test_h264_1280x544_ac3.mp4
This is an mp4 with 1280x544 H.264 video & 6 channel AC3 audio.
* Plays fine and with proper aspect ratio on an HDXL (so I assume TivoHD would work fine as well)
* Plays with blank video on my S3s though audio comes through fine.
This was generated from a short 720p mpeg2 clip using ffmpeg as follows:
ffmpeg -y -i INPUT -vcodec libx264 -s 1280x544 -coder 0 -level 41 -sameq -bufsize 14000k -b 2500k -maxrate 10000k -me_method epzs -trellis 2 -mbd 1 -acodec copy -f mp4 OUTPUT
* If I remove the resolution setting (-s 1280x544) then the resulting 1280x720 mp4 plays fine on both my S3s as well.
So this is yet another illustration of HDXL/THD mp4 decoder robustness compared to S3 decoder. To this point I only had examples of that for VC-1 encodings from Netflix. This is the 1st time I see this with H.264.
But as far as relevance to this thread, how come this one at 1280x544 has proper aspect ratio on playback?? (NOTE that DAR=16:9 for this one)
jcthorne
03-25-2009, 09:00 PM
This file is different. It has non-square pixels and plays incorrectly on the pc. Plays full frame on the Tivo. A 1280x544 vid should be letterboxed on a 720p frame panel. So the encode streached it horizontally and tivo squished it back. Did act differently than others I have pushed but not sure what it tells us.
moyekj
03-25-2009, 09:05 PM
This file is different. It has non-square pixels and plays incorrectly on the pc. Plays full frame on the Tivo. A 1280x544 vid should be letterboxed on a 720p frame panel. So the encode streached it horizontally and tivo squished it back. Did act differently than others I have pushed but not sure what it tells us. As I said the DAR is set to 16:9 so PAR has to be non-square at that resolution. ffmpeg will preserve source DAR unless you tell it otherwise (which I didn't when creating this sample). The way you describe would be the case if PAR was set to 1:1. This clip plays with correct aspect ratio for me with VLC on my PC.
I guess perhaps the lesson is that as long as the encoding is designed for 16:9 DAR it will work for Tivo decoder. I can try encoding again with goal of keeping PAR=1:1 (hence DAR = 544/1280 ratio) to see if that breaks things on the Tivo.
moyekj
03-26-2009, 02:22 AM
By adding -aspect 40:17 (so that PAR=1:1 and DAR=40:17) as in recipe below I did get letterboxing to happen on TivoHD playback. Of course that aspect ratio given source was 16:9 makes it looks stretched horizontally, but the point is that Tivo decoder can letterbox 720p targeted content.
ffmpeg -y -i INPUT -vcodec libx264 -s 1280x544 -aspect 40:17 -coder 0 -level 41 -sameq -bufsize 14000k -b 2500k -maxrate 10000k -me_method epzs -trellis 2 -mbd 1 -acodec copy -f mp4 OUTPUT
(This results in PAR=1:1, DAR=40:17 == 1280:544)
jcthorne
03-26-2009, 05:30 AM
Ok, it seems you have found a re-encoding method that generates a mp4 that works. What about it is now different than what we are sending? Why should it be necessary to re-encode. Could some simple changes to the atom cause most mp4 files to play correctly? Re-encoding full length features takes hours and its just as easy to encode with the added boarders to full frame going to the trouble. You had samples that did not work, what was different about them and why is Tivo incorrectly displaying them?
Unfortunatly, that ffmpeg statement will not work with an mkv as an input.
Oh, and I did get MPC to display your sample correctly, I had 'ignore aspect' turned on.
moyekj
03-26-2009, 04:59 PM
I did too much experimentation with this and lost the 1280x544 encoding that wasn't behaving properly and forget exactly how I generated it. Using ffmpeg no matter how I do it I can't generate one that doesn't work as expected anymore...
If you have a link to a clip of one that doesn't work let me know and I can experiment further.
Rdian06
03-26-2009, 07:14 PM
I did too much experimentation with this and lost the 1280x544 encoding that wasn't behaving properly and forget exactly how I generated it. Using ffmpeg no matter how I do it I can't generate one that doesn't work as expected anymore...
If you have a link to a clip of one that doesn't work let me know and I can experiment further.
I used MP4Box to extract the elementary streams from this 1280x544 Star Trek trailer and then mux it back into an mp4:
http://movies.apple.com/movies/paramount/star_trek/startrek-tlr3_h720p.mov
The resulting file with PAR=1:1 yielded the "4:3 letterbox cropped on the right" plus occasional video stutter when pushed without transcode to my S3.
moyekj
03-27-2009, 02:40 AM
I used MP4Box to extract the elementary streams from this 1280x544 Star Trek trailer and then mux it back into an mp4:
http://movies.apple.com/movies/paramount/star_trek/startrek-tlr3_h720p.mov
The resulting file with PAR=1:1 yielded the "4:3 letterbox cropped on the right" plus occasional video stutter when pushed without transcode to my S3.
I did the following to re-mux to mp4 container:
MP4box startrek.mov -raw 1
MP4box startrek.mov -raw 2
MP4box -add startrek_track1.h264 -add startrek_track2.aac -new startrek_new.mp4
Playing that stream on my HDXL (which mediainfo recognizes as DAR=40:17 but ffmpeg does not) was pillarboxed (squeezed horizontally).
Then I set 1:1 PAR explicitly (such that ffmpeg now recognizes as DAR=40:17):
MP4box -par 1=1:1 startrek_new.mp4
Then the clip plays with proper letterboxing and aspect ratio on my HDXL unit.
However, that same clip plays with pillar boxes and cropped to the right just as you described on my S3s.
=> Looks like the S3 H.264 decoders are really screwy but so far the HDXL decoder seems OK once you explicitly set PAR (and hence DAR) to proper values.
jcthorne I believe you have a THD unit. Can you confirm same results with your THD following above sequence?
Rdian06
03-27-2009, 07:59 PM
Playing that stream on my HDXL (which mediainfo recognizes as DAR=40:17 but ffmpeg does not) was pillarboxed (squeezed horizontally).
Then I set 1:1 PAR explicitly (such that ffmpeg now recognizes as DAR=40:17):
MP4box -par 1=1:1 startrek_new.mp4
Then the clip plays with proper letterboxing and aspect ratio on my HDXL unit.
However, that same clip plays with pillar boxes and cropped to the right just as you described on my S3s.
=> Looks like the S3 H.264 decoders are really screwy but so far the HDXL decoder seems OK once you explicitly set PAR (and hence DAR) to proper values.
I was afraid you were going to say that.
When you played it back on your HDXL and S3, did you notice any visual stuttering ever few seconds? I think where it's most visible is in the shot when they are panning across the cadets(?) all dressed in red/orange over to young Spock talking about fear. Right before it gets to Spock, I think my S3 glitches back a frame or freezes and then lurches forward again.
This might also explain why some of my mkv to mp4 conversions with MP4Box and MP4Creator result in smooth playback on the PC, but non-fluid playback on the S3 when the audio seems to work fine.
moyekj
03-27-2009, 08:17 PM
S3 playback was glitchy for sure (and of course wrong aspect ratio and lopped off on right side).
I don't recall video glitches for HDXL playback but will check it again tonight. Audio/video were pretty grossly out of sync however for the re-muxed clip (for PC playback as well).
moyekj
03-27-2009, 10:59 PM
P.S. Re-muxing with ffmpeg instead of MP4Box resulted in perfect audio/video sync so is a better and easier way of doing it:
ffmpeg -i startrek.mov -vcodec copy -copyts -acodec copy -f mp4 startrek.mp4
(Still needed MP4Box to explicitly set PAR=1:1 for it to play properly on HDXL)
EDIT: After careful viewing HDXL playback actually does have some glitching more towards the beginning (some tearing and macroblocking here and there) and whenever there is writing it shakes a little up and down. I don't see those issues during PC playback so it would seem the HDXL decoder is not perfect either.
orangeboy
03-09-2010, 03:15 PM
Resurrecting an old thread to ask my somewhat(?) related question.
Is ffmpeg capable of adding pillarboxes during transcode to videos that are 4:3, being transcoded to 16:9? A google search turned up this thread, and I know there are some pretty clever folks here! :up:
My recipe:
ffmpeg -i %1 -f mp4 -vcodec mpeg4 -b 436k -r 29.97 -s 320x180 -acodec libfaac -ar 44100 -ab 64k "F:\temp\%~n1.mp4"
FWIW, I'm also using mp4box to concatenate the resulting video to an existing file:
mp4box -cat "F:\temp\%~n1.mp4" "\\media-center\Dusty.Channel\Led.Zeppelin\Dusty.Channel.mp4"
"Dusty.Channel.mp4" (with my Led Zeppelin movies) is then served up through http to Second Life, and applied to a media texture. SL has some limits on what it can show.
TIA for any advice given!
gonzotek
03-09-2010, 03:29 PM
Resurrecting an old thread to ask my somewhat(?) related question.
Is ffmpeg capable of adding pillarboxes during transcode to videos that are 4:3, being transcoded to 16:9? A google search turned up this thread, and I know there are some pretty clever folks here! :up:
My recipe:
ffmpeg -i %1 -f mp4 -vcodec mpeg4 -b 436k -r 29.97 -s 320x180 -acodec libfaac -ar 44100 -ab 64k "F:\temp\%~n1.mp4"
FWIW, I'm also using mp4box to concatenate the resulting video to an existing file:
mp4box -cat "F:\temp\%~n1.mp4" "\\media-center\Dusty.Channel\Led.Zeppelin\Dusty.Channel.mp4"
"Dusty.Channel.mp4" (with my Led Zeppelin movies) is then served up through http to Second Life, and applied to a media texture. SL has some limits on what it can show.
TIA for any advice given!
I don't have time right now to do any tests before posting, but it sounds like you're looking for the padding options:
From http://ffmpeg.org/ffmpeg-doc.html :
`-aspect aspect'
Set aspect ratio (4:3, 16:9 or 1.3333, 1.7777).
`-croptop size'
Set top crop band size (in pixels).
`-cropbottom size'
Set bottom crop band size (in pixels).
`-cropleft size'
Set left crop band size (in pixels).
`-cropright size'
Set right crop band size (in pixels).
`-padtop size'
Set top pad band size (in pixels).
`-padbottom size'
Set bottom pad band size (in pixels).
`-padleft size'
Set left pad band size (in pixels).
`-padright size'
Set right pad band size (in pixels).
`-padcolor hex_color'
Set color of padded bands. The value for padcolor is expressed as a six digit hexadecimal number where the first two digits represent red, the middle two digits green and last two digits blue (default = 000000 (black)).
orangeboy
03-09-2010, 04:09 PM
I don't have time right now to do any tests before posting, but it sounds like you're looking for the padding options:
From http://ffmpeg.org/ffmpeg-doc.html :
`-aspect aspect'
Set aspect ratio (4:3, 16:9 or 1.3333, 1.7777).
`-croptop size'
Set top crop band size (in pixels).
`-cropbottom size'
Set bottom crop band size (in pixels).
`-cropleft size'
Set left crop band size (in pixels).
`-cropright size'
Set right crop band size (in pixels).
`-padtop size'
Set top pad band size (in pixels).
`-padbottom size'
Set bottom pad band size (in pixels).
`-padleft size'
Set left pad band size (in pixels).
`-padright size'
Set right pad band size (in pixels).
`-padcolor hex_color'
Set color of padded bands. The value for padcolor is expressed as a six digit hexadecimal number where the first two digits represent red, the middle two digits green and last two digits blue (default = 000000 (black)).
Thanks! I'll give that a shot. I'll throw some 4:3 at it, then some 16:9 to make sure the padding is ignored for 16:9.
txporter
03-09-2010, 05:09 PM
I don't think the padding will be ignored with 16:9. I would expect it to add however many pixels you request as rows (or columns) of black. These will now be part of your frame.
gonzotek
03-09-2010, 06:36 PM
I don't think the padding will be ignored with 16:9. I would expect it to add however many pixels you request as rows (or columns) of black. These will now be part of your frame.Yeah, if I'm understanding you correctly, orangeboy, you'll have to predetermine your existing and desired framesizes per video. If it's just a one-shot deal it's probably easiest to simply sit down and calculate it by hand. If you're going to be doing this again and again, you'll probably want to build some kind of script. pyTivo does some automatic padding calculations that might be a good starting point if python's understandable to you. I think streambaby might as well, and there are probably batch files and shell scripts around, if you look for them.
orangeboy
03-09-2010, 09:07 PM
Yeah, if I'm understanding you correctly, orangeboy, you'll have to predetermine your existing and desired framesizes per video. If it's just a one-shot deal it's probably easiest to simply sit down and calculate it by hand. If you're going to be doing this again and again, you'll probably want to build some kind of script. pyTivo does some automatic padding calculations that might be a good starting point if python's understandable to you. I think streambaby might as well, and there are probably batch files and shell scripts around, if you look for them.
Grr. I didn't want to spend cycles determining the source video resolution, what with parsing the output of some utility. I did that with the batch script that "converts" mkv to mp4 found in a thread somewhere in this forum. I have a feeling that's what pyTivo does, reading back the output from ffmpeg before transcoding to TiVo compatible specs. If I do nothing I get short fat people with 4:3 source video, if I add padding, I get tall skinny people with 16:9 source video. I guess I spending cycles parsing! I'll check pyTivo & streambaby first though to see if there's some magic to be found...
Thanks guys!
ggieseke
03-10-2010, 07:48 AM
Here's a batch file I use for padding lower res videos up to 640x480. You will need the command line version of MediaInfo somewhere in your path or the same folder as the batch file. With a few mods it should work for you.
@echo off
setlocal
set F1=%1
set F2=%2
for /f "tokens=1-3" %%i in ('"MediaInfo.exe %F1%|find /i "Width""') do set /a X0=%%k
for /f "tokens=1-3" %%i in ('"MediaInfo.exe %F1%|find /i "Height""') do set /a Y0=%%k
if %X0% GTR 640 goto :EOF
if %Y0% GTR 480 goto :EOF
set /a X1=640-%X0%
set /a Y1=480-%Y0%
set /a T=%Y1%/2
set /a B=480-%T%-%Y0%
set /a L=%X1%/2
set /a R=640-%L%-%X0%
set P=
if %T% GTR 0 set P=%P% -padtop %T%
if %B% GTR 0 set P=%P% -padbottom %B%
if %L% GTR 0 set P=%P% -padleft %L%
if %R% GTR 0 set P=%P% -padright %R%
ffmpeg.exe -i %F1% -vcodec mpeg2video -b 8000k -mbd 2 -trellis 2 -cmp 2 -subcmp 2 -g 18%P% -flags +ilme -ab 192k -ar 48000 %F2%
orangeboy
03-10-2010, 11:06 AM
Here's a batch file I use for padding lower res videos up to 640x480. You will need the command line version of MediaInfo somewhere in your path or the same folder as the batch file. With a few mods it should work for you.
@echo off
setlocal
set F1=%1
set F2=%2
for /f "tokens=1-3" %%i in ('"MediaInfo.exe %F1%|find /i "Width""') do set /a X0=%%k
for /f "tokens=1-3" %%i in ('"MediaInfo.exe %F1%|find /i "Height""') do set /a Y0=%%k
if %X0% GTR 640 goto :EOF
if %Y0% GTR 480 goto :EOF
set /a X1=640-%X0%
set /a Y1=480-%Y0%
set /a T=%Y1%/2
set /a B=480-%T%-%Y0%
set /a L=%X1%/2
set /a R=640-%L%-%X0%
set P=
if %T% GTR 0 set P=%P% -padtop %T%
if %B% GTR 0 set P=%P% -padbottom %B%
if %L% GTR 0 set P=%P% -padleft %L%
if %R% GTR 0 set P=%P% -padright %R%
ffmpeg.exe -i %F1% -vcodec mpeg2video -b 8000k -mbd 2 -trellis 2 -cmp 2 -subcmp 2 -g 18%P% -flags +ilme -ab 192k -ar 48000 %F2%
Thanks for sharing ggieseke - it's nice to not have to reinvent the wheel when I don't have to! :)
orangeboy
03-11-2010, 06:04 PM
Thanks for getting me on the right track. I got the following to work for me:
@ECHO off
cscript.exe //H:cscript //NoLogo //B
SetLocal EnableDelayedExpansion
:Loop
::-----------------------------------------::
:: Process all files until arguments empty ::
::-----------------------------------------::
IF "%~1"=="" GOTO Done
::-----------------------------------------::
:: Setup letterbox/pillarbox if needed ::
::-----------------------------------------::
CD /D "%~dp1"
FOR /f "usebackq" %%i IN (`"MediaInfo.exe --inform=Video;%%Width%% "%~nx1""`) DO SET /A X0=%%i
FOR /f "usebackq" %%i IN (`"MediaInfo.exe --inform=Video;%%Height%% "%~nx1""`) DO SET /A Y0=%%i
@ECHO Original Dimensions: %X0%x%Y0%
IF %X0% LSS 320 (
@ECHO Too Small
GOTO END
)
IF %Y0% LSS 180 (
@ECHO Too Small
GOTO END
)
FOR /f %%i IN ('domath //nologo 180/%Y0%') DO SET YD=%%i
FOR /f %%i IN ('domath //nologo %X0%*%YD%') DO SET X1=%%i
SET /a X1="X1+0"
SET /a Y1=180
IF %X1% GTR 320 (
FOR /f %%i IN ('domath //nologo 320/%X1%') DO SET XD=%%i
FOR /f %%i IN ('domath //nologo 180*%XD%') DO SET Y1=%%i
SET /a Y1=%Y1%+0
)
@ECHO Scaled Dimensions: %X1%x%Y1%
SET /a X2="320-X1"
SET /a Y2="180-Y1"
SET /a T=%Y2%/2
SET /a B=180-%T%-%Y1%
SET /a L=%X2%/2
SET /a R=320-%L%-%X1%
SET P=
IF %T% GTR 0 SET P=%P% -padtop %T%
IF %B% GTR 0 SET P=%P% -padbottom %B%
IF %L% GTR 0 SET P=%P% -padleft %L%
IF %R% GTR 0 SET P=%P% -padright %R%
::-----------------------------------------::
:: Convert file to SL compatible MP4 file ::
::-----------------------------------------::
ffmpeg -i "%~nx1" -f mp4 -vcodec mpeg4 -b 436k -r 29.97 -s %X1%x%Y1% %P% -acodec libfaac -ac 2 -ar 44100 -ab 64k "%usrtmp%\%~n1.mp4"
mp4box -cat "%usrtmp%\%~n1.mp4" "\\media-center\Dusty.Channel\Led.Zeppelin\Dusty.Test1.Channel.mp4"
del "%usrtmp%\%~n1.mp4"
:End
::-----------------------------------------::
:: File is done, go get next one ::
::-----------------------------------------::
SHIFT
GOTO Loop
:Done
::-----------------------------------------::
:: Files done. Go back from wence you came ::
::-----------------------------------------::
cscript.exe //H:wscript
EXIT /B
This is the "domath.vbs" that allows for accurate calculations in batch, and requires the cscript.exe additions found at the beginning and end of my batch:
Set objArgs = WScript.Arguments
wscript.echo eval(objArgs(0))
JohnnyLamb
05-24-2010, 03:09 PM
[clip]
I set 1:1 PAR explicitly (such that ffmpeg now recognizes as DAR=40:17):
MP4box -par 1=1:1 startrek_new.mp4
Then the clip plays with proper letterboxing and aspect ratio on my HDXL unit.
However, that same clip plays with pillar boxes and cropped to the right just as you described on my S3s.
[clip]
jcthorne I believe you have a THD unit. Can you confirm same results with your THD following above sequence?
Just wanted to confirm that this method DOES work for me on my TivoHD. No Re-encoding needed.
ReMuxing with MP4Box and adding an explicit PAR 1:1 setting successfully displays correct aspect ratio in Panel mode. Have tried this with several mp4's with 1280x544 & and one with 1280x688 resolutions. All worked fine whether pushed or pulled with PyTivo, streamed with Streambaby, or pushed with Streambaby.
If you have to re-encode anyway for some reason, I have found that Handbrake with loose anamorph set will also display correctly.
MrFlibble1
05-24-2010, 05:28 PM
If so, what work process and software are you using and how are your results?
I have found one process that works but its a long way round and take a good deal of time.
This is for HD video, not SD.
Mr. Flibble has encoded HD video with AC3 using Nero Recode. Nero Recode doesn't support AC3 as an internal encoder, but if the original source is AC3 it can copy it over to the MP4 output.
Mr. Flibble then transfers to Tivo using pyTivo.
No problems at all.
vBulletin® v3.6.8, Copyright ©2000-2012, Jelsoft Enterprises Ltd.