From 18853a69850ce65763286d049551c4fc14b8ac5b Mon Sep 17 00:00:00 2001 From: van Date: Tue, 2 Jun 2009 03:34:20 +0000 Subject: [PATCH] Fix for New Zealand TV not following the mpeg2 standard git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2466 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- libhb/stream.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libhb/stream.c b/libhb/stream.c index 1e49d76f5..c98f901db 100644 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -1986,7 +1986,13 @@ static int decode_PAT(const uint8_t *buf, hb_stream_t *stream) static void hb_ts_stream_find_pids(hb_stream_t *stream) { - // align to first packet + // To be different from every other broadcaster in the world, New Zealand TV + // changes PMTs (and thus video & audio PIDs) when 'programs' change. Since + // we may have the tail of the previous program at the beginning of this + // file, take our PMT from the middle of the file. + fseeko(stream->file_handle, 0, SEEK_END); + uint64_t fsize = ftello(stream->file_handle); + fseeko(stream->file_handle, fsize >> 1, SEEK_SET); align_to_next_packet(stream); // Read the Transport Stream Packets (188 bytes each) looking at first for PID 0 (the PAT PID), then decode that -- 2.40.0