Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

payloadOffset is larger than TS_FRAME_SIZE?! #4

Open
a1291762 opened this issue Feb 4, 2017 · 0 comments
Open

payloadOffset is larger than TS_FRAME_SIZE?! #4

a1291762 opened this issue Feb 4, 2017 · 0 comments

Comments

@a1291762
Copy link

a1291762 commented Feb 4, 2017

Hi,

I've been using tivodecode 0.4.4 for a while now so that I can download TS files from my TiVo. TS is how they come OTA (I'm in Australia, if that's relevant) and having the TiVo convert them to PS does not always work (particularly for certain channels). I originally used ffmpeg to convert to PS (for better seeking) but these days I do a quick mpeg4 re-encode for faster seeking and better handling of the occasional invalid video chunk.

Anyway, I have a show I just recorded that crashes tivodecode. After looking at a stack trace, I made the below change to reject the packets that are bad. The end result is that I get all the video but audio stops about 10 minute in. The file plays just fine on the TiVo itself.

The things is, I'm not really sure about what's going on with the internals of tivodecode so I don't know if this really is a bad packet (ie. the TiVo has given me crap) or if there's just some kind of decode issue.

I was pointed to this project, which continues from tivodecode 0.4.4 and it has the same issue.

diff --git a/tivo_decoder_ts_stream.cxx b/tivo_decoder_ts_stream.cxx
index 78e85cc..28a1b1e 100644
--- a/tivo_decoder_ts_stream.cxx
+++ b/tivo_decoder_ts_stream.cxx
@@ -74,6 +74,10 @@ bool TiVoDecoderTsStream::addPkt(TiVoDecoderTsPacket *pPkt)
             VVERBOSE("DEQUE : PktID %d from PID 0x%04x\n", pPkt2->packetId,
                     stream_pid);
 
+            int size = (TS_FRAME_SIZE - pPkt2->payloadOffset);
+            if (size <= 0)
+                return false;
+
             std::memcpy(&pesDecodeBuffer[pesDecodeBufferLen],
                         &pPkt2->buffer[pPkt2->payloadOffset],
                         TS_FRAME_SIZE - pPkt2->payloadOffset);

I was also pointed to tivolibre, a Java version of the tivodecode logic. Out of curiosity, I ran the same video through it and it completed successfuly, keeping the audio intact. Interesting... I might take a look at what it's doing and see if I can bring the changes/improvements over to C++.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant