[Libav-user] remuxing MKV/H.264 to MPEG2 Elemntary Stream

Alex Cohn alexcohn at netvision.net.il
Sun Feb 19 23:02:04 CET 2012


On Feb 19, 2012 11:27 PM, "Pavel Sokolov" <pavel at sokolov.me> wrote:
>
> 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

Ура!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20120220/cb9545e5/attachment.html>


More information about the Libav-user mailing list