pyTivo Discussion Forum Forum Index pyTivo Discussion Forum
Answers and the development of pyTivo a TiVo transcoding server
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Remux without reencoding for MKV, AVCHD, etc. in Push
Goto page 1, 2, 3, 4, 5, 6, 7  Next
 
Post new topic   Reply to topic    pyTivo Discussion Forum Forum Index -> pyTivo
 View previous topic :: View next topic  
Author Message
wmcbrine



Joined: 04 Jan 2008
Posts: 2008
Location: Maryland

PostPosted: Sat Mar 26, 2011 3:29 am    Post subject: Remux without reencoding for MKV, AVCHD, etc. in Push Reply with quote

For files with MP4-compatible video and audio, but the wrong container type -- like your typical Matroska (MKV) file, as well as AVCHD, and perhaps others -- I've added a quick-and-dirty remux before push, instead of having to reencode these to MPEG-2. It works, but it's a bit rough -- you'll see a long delay on the web interface before you get the "Queued for Transfer" page, for instance, because the remuxing is done before the request is submitted to the mind server. Files that can't be remuxed, for whatever reason (as determined by a non-zero return code from ffmpeg) will be reencoded to MPEG-2 on the fly as usual instead.

Since streamable MP4s can't be built in one pass, temporary files are written to the location of the original, but with the added extension ".pyTivo-temp". These are then processed by qtfaststart* during the transfer, and removed at the end. Transfers using this system may not be resumable, and if the same file is pushed to more than one TiVo at a time, only the first will get the remuxed version.

I've only tested this with a small set of files. My first was the first episode of Pioneer One, which worked fine. But the second episode failed with the infamous "non-monotone timestamp" error. That will probably come up a lot.

* Incidentally, I updated qtfaststart the other day based on a new upstream version, and so far it seems to work much better than before. Some things that were garbled by the old version now come out perfect.

_________________
My pyTivo fork . My page
Back to top
View user's profile Send private message Visit poster's website
rdian06



Joined: 12 Apr 2008
Posts: 1420

PostPosted: Sat Mar 26, 2011 8:08 pm    Post subject: Reply with quote

Sounds very cool.
Back to top
View user's profile Send private message
jcthorne



Joined: 30 Jan 2008
Posts: 243
Location: Houston, TX

PostPosted: Mon Mar 28, 2011 1:00 pm    Post subject: Reply with quote

Really cool. Glad to see you adding features etc to pytivo again. Will give it a try.
Back to top
View user's profile Send private message
raghu1111



Joined: 28 May 2009
Posts: 46

PostPosted: Wed Mar 30, 2011 1:00 am    Post subject: Reply with quote

very nice update. pulled the changes. will report if there are any issues.

Do you think using a pipe rather than ".pyTivo-temp" might work? qtfaststart seeks around the file, that could be the problem. One of the debug messages in qtfaststart says "directly streamable..." if ffmpeg output is streamable, then pipe would work.
Back to top
View user's profile Send private message
raghu1111



Joined: 28 May 2009
Posts: 46

PostPosted: Wed Mar 30, 2011 2:59 am    Post subject: Reply with quote

wmcbrine wrote:
No, it can't be done with quick changes. For one thing, to make a TiVo-compatible MP4 would require running qtfaststart on the encoded file. This means that it can't be done in a pipeline, the way it is for MPEG-2; and that means the whole thing would need to be restructured.

this quote from another thread sums it up.

Quote:
Rather than have pyTivo encode MP4s, I'm looking at doing transport streams with h.264, because I think they can be done in one pass. But even that is pretty hairy.

what does this mean?
Back to top
View user's profile Send private message
rdian06



Joined: 12 Apr 2008
Posts: 1420

PostPosted: Wed Mar 30, 2011 3:24 am    Post subject: Reply with quote

Transport streams (TS) are a container format just like MP4 and VOB. US Tivos can handle h264 in MP4 containers and MPEG2 in VOB and TS. US digital broadcasts are sent as MPEG2 in TS and the Tivo pretty much captures them as is.

New Zealand/Australia Tivos support h264 in TS because some of their broadcasts use that format.

wmcbrine suspects that the US Tivos either already support h264 in TS containers and we just haven't discovered the right command to trigger the transfer OR that some future software update will incorporate some of the New Zealand/Australia code and allow it. The Tivo software from down under has higher version number than the US Tivos, but much of the system is the same.
Back to top
View user's profile Send private message
Iluvatar



Joined: 29 Feb 2008
Posts: 335

PostPosted: Wed Mar 30, 2011 4:47 pm    Post subject: Reply with quote

Would it also be possible to re-encode the audio stream if necessary to be compatible? I would think should add minimal overhead to the remux process on most systems and can be integrated into a single ffmpeg command. If we are going to start working with MKV files then it needs to be taken into account that many files wont be compatible based on the audio stream alone due to >448kbps AC3 or other codec.
Back to top
View user's profile Send private message
wmcbrine



Joined: 04 Jan 2008
Posts: 2008
Location: Maryland

PostPosted: Thu Mar 31, 2011 2:28 am    Post subject: Reply with quote

Are there actually files with an audio stream that's too high a bitrate, but a video stream that's OK? BTW, the Premiere can apparently handle full Blu-Ray rate audio, so that's something to tweak in the future.

Meanwhile, I just added a bit that says files with a ".mov" extension are using an incompatible container, which allows them to be remuxed to MP4 and pushed (if h264 video/AAC or AC3 audio). Previously these would be pushed as-is and fail. I was hesitant to do this, since for the most part the extension is ignored in pyTivo, as it's more reliable to check the file itself. But I couldn't see a better way.

_________________
My pyTivo fork . My page
Back to top
View user's profile Send private message Visit poster's website
Iluvatar



Joined: 29 Feb 2008
Posts: 335

PostPosted: Thu Mar 31, 2011 2:40 am    Post subject: Reply with quote

wmcbrine wrote:
Are there actually files with an audio stream that's too high a bitrate, but a video stream that's OK? BTW, the Premiere can apparently handle full Blu-Ray rate audio, so that's something to tweak in the future.


Well as for bitrate that may be ok for the Premiere but the HD/S3 could benefit. Also many of the MKV videos that are Bluray rips are primarily DTS audio, or at the very least include the 640kbps AC3 stream on the secondary audio stream.

Perhaps pyTivo could discriminate between the audio streams to pick out which is the AC3 stream (re-encode to 448kbps if sending to a HD/S3) or if no other compatible stream is available just flat out re-encode the incompatible stream to 448kbps AC3.
Back to top
View user's profile Send private message
raghu1111



Joined: 28 May 2009
Posts: 46

PostPosted: Thu Mar 31, 2011 6:13 pm    Post subject: Reply with quote

rdian06 wrote:

wmcbrine suspects that the US Tivos either already support h264 in TS containers and we just haven't discovered the right command to trigger the transfer OR that some future software update will incorporate some of the New Zealand/Australia code and allow it. The Tivo software from down under has higher version number than the US Tivos, but much of the system is the same.

Thanks for the detailed explanation. So h264 in TS container would allow steaming. nice.
Back to top
View user's profile Send private message
Iluvatar



Joined: 29 Feb 2008
Posts: 335

PostPosted: Mon Apr 04, 2011 11:33 pm    Post subject: Reply with quote

--Edit: Never mind I reinstalled latest version again and its gone. I may have been one revision off, although I could have swore I just got the latest. Oh well.

-------

I am receiving an error on 'vCodec' that I believe is related to this new code.

Happens on push only. Pull works fine. FFmpeg lists the video codec as

Code:

Stream #0.0(eng): Video: h264 (High), yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 50 tbc


Here is the log:
Code:

4/4/11 7:19:05 PM   pyTivo[46]   DEBUG:pyTivo.video.transcode:CACHE HIT! /Volumes/Videos/TV Shows/Documentaries/Wonders of the Universe/BBC.Wonders.of.the.Universe.1of4.Destiny.HDTV.x264.AC3.MVGroup.org.mkv
4/4/11 7:19:05 PM   pyTivo[46]   Unhandled exception in thread started by <unbound method Video.process_queue>
4/4/11 7:19:05 PM   pyTivo[46]   ERROR:pyTivo:Exception in pyTivo
4/4/11 7:19:05 PM   pyTivo[46]   Traceback (most recent call last):
4/4/11 7:19:05 PM   pyTivo[46]     File "/Applications/pyTivo/plugins/video/video.py", line 452, in process_queue
4/4/11 7:19:05 PM   pyTivo[46]       self.push_one_file(item)
4/4/11 7:19:05 PM   pyTivo[46]     File "/Applications/pyTivo/plugins/video/video.py", line 407, in push_one_file
4/4/11 7:19:05 PM   pyTivo[46]       if transcode.tivo_compatible(f['path'], f['tsn'], m)[0]:
4/4/11 7:19:05 PM   pyTivo[46]     File "/Applications/pyTivo/plugins/video/transcode.py", line 684, in tivo_compatible
4/4/11 7:19:05 PM   pyTivo[46]       vmessage = tivo_compatible_video(vInfo, tsn, mime)
4/4/11 7:19:05 PM   pyTivo[46]     File "/Applications/pyTivo/plugins/video/transcode.py", line 538, in tivo_compatible_video
4/4/11 7:19:05 PM   pyTivo[46]       codec = vInfo['vCodec']
Back to top
View user's profile Send private message
wmcbrine



Joined: 04 Jan 2008
Posts: 2008
Location: Maryland

PostPosted: Tue Apr 05, 2011 2:40 am    Post subject: Reply with quote

Surely that's not the whole log? The actual error doesn't appear.
_________________
My pyTivo fork . My page
Back to top
View user's profile Send private message Visit poster's website
Iluvatar



Joined: 29 Feb 2008
Posts: 335

PostPosted: Tue Apr 05, 2011 3:20 am    Post subject: Reply with quote

wmcbrine wrote:
Surely that's not the whole log? The actual error doesn't appear.


No its not the entire console dump. I just copied the only lines that looked useful. Everything before and after was normal looking. If I come across it again I will copy further back.


Last edited by Iluvatar on Tue Apr 05, 2011 3:26 am; edited 1 time in total
Back to top
View user's profile Send private message
wmcbrine



Joined: 04 Jan 2008
Posts: 2008
Location: Maryland

PostPosted: Tue Apr 05, 2011 3:25 am    Post subject: Reply with quote

Well, thanks, but it's not useful... like I say, the actual error doesn't appear. It should be at the end of the traceback.
_________________
My pyTivo fork . My page
Back to top
View user's profile Send private message Visit poster's website
Iluvatar



Joined: 29 Feb 2008
Posts: 335

PostPosted: Sun May 29, 2011 10:05 pm    Post subject: Reply with quote

I have worked a bit on this and finally managed to get pyTivo to transcode the audio if it does not meet codec requirements while copying the video codec. It's not as fast as a straight codec copy but still 5 times faster than transcoding the entire file unnecessarily. So this means all compatible h264 video regardless of audio codec (as long as ffmpeg recognizes it) is compatible now and can still be streamed.

60% of my content was DTS audio but contained compatible video, unfortunately it was being kicked out into the normal transcode function slowing everything down.

It's probably not up to wmcbrine's standards (i'm not a programmer and it took forever to figure out what was going on) but I will post the changes for others once I test it a bit more.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    pyTivo Discussion Forum Forum Index -> pyTivo All times are GMT
Goto page 1, 2, 3, 4, 5, 6, 7  Next
Page 1 of 7

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
Site is in NO WAY affiliated with TiVo Inc

Powered by phpBB © 2001, 2005 phpBB Group
phpBB SEO

Get pytivo at SourceForge.net. Fast, secure and Free Open Source software downloads
[ Time: 0.1528s ][ Queries: 12 (0.0099s) ][ GZIP on - Debug on ]