diff --git a/src/mkvextract_tracks.cpp b/src/mkvextract_tracks.cpp index 031958176..8ec8f776d 100644 --- a/src/mkvextract_tracks.cpp +++ b/src/mkvextract_tracks.cpp @@ -582,6 +582,7 @@ unpack_real_video_frames(kax_track_t *track, uint32_t timecode, bool is_key) { unsigned char *src_ptr, *ptr, *dst; + uint32_t merged; int num_subpackets, i, offset, total_len; vector packet_offsets, packet_lengths; rmff_frame_t *frame; @@ -619,26 +620,30 @@ unpack_real_video_frames(kax_track_t *track, if (num_subpackets == 1) { *ptr = 0xc1; // complete frame ptr++; +// merged = 0x8000; + merged = 0x0000; } else { - *ptr = num_subpackets + 1; +// *ptr = num_subpackets; + *ptr = 1; if (i == (num_subpackets - 1)) // last fragment? *ptr |= 0x80; ptr++; *ptr = i + 1; // fragment number - if (is_key) // key frame? - *ptr |= 0x80; +// if (is_key) // key frame? +// *ptr |= 0x80; ptr++; + merged = 0; } // total packet length: if (total_len > 0x3fff) { - put_uint16_be(ptr, ((total_len & 0x3fff0000) >> 16)); + put_uint16_be(ptr, merged | ((total_len & 0x3fff0000) >> 16)); ptr += 2; put_uint16_be(ptr, total_len & 0x0000ffff); } else - put_uint16_be(ptr, 0x4000 | total_len); + put_uint16_be(ptr, merged | 0x4000 | total_len); ptr += 2; // fragment offset from beginning/end: @@ -659,7 +664,7 @@ unpack_real_video_frames(kax_track_t *track, ptr += 2; // sequence number = frame number & 0xff - *ptr = track->packetno & 0xff; + *ptr = (track->packetno - 1) & 0xff; ptr++; memcpy(ptr, src_ptr, packet_lengths[i]);