GNOME Bugzilla – Bug 708532
tsdemux: skips too much when scanning for last PCR
Last modified: 2014-12-01 14:06:17 UTC
Created attachment 255480 [details] [review] Patch Probably a typo. Causes shorter duration reported than the real duration.
I'm also not sure about this: if (mpegts_packetizer_has_packets (base->packetizer)) { while (1) { /* Eat up all packets */ pret = mpegts_packetizer_process_next_packet (base->packetizer); if (pret == PACKET_NEED_MORE) break; if (pret != PACKET_BAD && mpegts_packetizer_get_seen_pcr (base->packetizer) > initial_pcr_seen) { GST_DEBUG ("Got last PCR"); done = TRUE; >> break; } } } Why is the break there? This will find the first PCR in the block, but that is not necessarily the last PCR in file.
I pushed a refactoring of pcr/offset handling. Please try again, the results are quite different now.
The reason why it breaks is to limit amount of data to scan (and get results faster). With the new pcr/offset handling it ends up giving a proper duration.
Created attachment 280211 [details] [review] mpegtbase: Improve last PCR detection When dealing with random-access content (such as files), we initially search for the last PCR in order to figure out duration and to handle other position estimation such as those used in seeking. Previously, the code looking for that last PCR would search in the last 640kB of the file going forward, and stop at the first PCR encountered. The problem with that was two-fold: * It wouldn't really be the last PCR (it would be the first one within those last 640kB. In case of VBR files, this would put off duration and seek code slightly. * It would fail on files with bitrates higher than 52Mbit/s (not common) Instead this patch modifies that code by: * Scanning over the last 2048kB (allows to cope with streams up to 160Mbit/s) * Starts by the end of the file, going over chunks of 300 MPEG-TS packets * Doesn't stop at the first PCR detected in a chunk, but instead records all of them, and only stop searching if there was "at least" one PCR within that chunk This should improve duration reporting and seeking operations on VBR files
commit 56ae254dd31f6c1ca468aa43bb3262d2fc84422e Author: Edward Hervey <bilboed@bilboed.com> Date: Wed Jul 9 10:11:40 2014 +0200 mpegtbase: Improve last PCR detection When dealing with random-access content (such as files), we initially search for the last PCR in order to figure out duration and to handle other position estimation such as those used in seeking. Previously, the code looking for that last PCR would search in the last 640kB of the file going forward, and stop at the first PCR encountered. The problem with that was two-fold: * It wouldn't really be the last PCR (it would be the first one within those last 640kB. In case of VBR files, this would put off duration and seek code slightly. * It would fail on files with bitrates higher than 52Mbit/s (not common) Instead this patch modifies that code by: * Scanning over the last 2048kB (allows to cope with streams up to 160Mbit/s) * Starts by the end of the file, going over chunks of 300 MPEG-TS packets * Doesn't stop at the first PCR detected in a chunk, but instead records all of them, and only stop searching if there was "at least" one PCR within that chunk This should improve duration reporting and seeking operations on VBR files https://bugzilla.gnome.org/show_bug.cgi?id=708532