[Libav-user] remuxing MKV/H.264 to MPEG2 Elemntary Stream
Pavel Sokolov
pavel at sokolov.me
Sun Feb 19 22:26:34 CET 2012
19.02.2012 15:35, Alex Cohn пишет:
> Please have a look at mpegts_write_packet() public function in the
> same c file. You notice that it accepts h264 packets in annex B format
> only:
Alex, thank you, now all works fine with the two steps:
1. Adding 'h264_mp4toannexb' bitstream filter processing after each call
of the av_read_frame
2. Adding the next code from mpegtsenc.c after bitstream filter:
do {
p = avpriv_mpv_find_start_code(p, buf_end, &state);
//av_log(s, AV_LOG_INFO, "nal %d\n", state & 0x1f);
} while (p < buf_end && (state & 0x1f) != 9 &&
(state & 0x1f) != 5 && (state & 0x1f) != 1);
if ((state & 0x1f) != 9) { // AUD NAL
data = av_malloc(pkt->size+6);
if (!data)
return -1;
memcpy(data+6, pkt->data, pkt->size);
AV_WB32(data, 0x00000001);
data[4] = 0x09;
data[5] = 0xf0; // any slice type (0xe) + rbsp stop one bit
buf = data;
size = pkt->size+6;
}
--
With best regards, Pavel A. Sokolov
mobile: +7(921)419-1819
skype: pavel_a_sokolov
More information about the Libav-user
mailing list