[FFmpeg-soc] Extend TSMuxer to H264 muxing

zhentan feng spyfeng at gmail.com
Mon Apr 14 08:40:54 CEST 2008


Hi

2008/4/14, Michael Niedermayer <michaelni at gmx.at>:
>
> On Mon, Apr 14, 2008 at 01:52:41AM +0800, zhentan feng wrote:
> > Hi
> >
> > 2008/4/3, Baptiste Coudurier <baptiste.coudurier at smartjog.com>:
> > >
> > > Hi,
> > >
> > > zhentan feng wrote:
> > > > [...]
> > >
> > > >
> > > >  New Add fields:
> > > >       1,AVC video descriptor
> > > >       2,AVC timing and HRD descriptor
> > >
> > >
> > > Those are worth to be added.
> > >
> > > Also We must ensure in some way that H264 bitstream contains AUD NAL
> > > units.
> > >
> > >
> > > >
> > > > (4)At last, how do I test the code works right for H264 muxing?
> > > > Tank you for any advice.
> > > >
> > >
> > >
> > > Well for now, use VLC to play back streams, but justify all your
> changes
> > > by the specs.
> > >
> > >
> > I add AVC video descriptor and AVC timing and HRD descriptor when write
> PMT
> > in TS init,
> > and check the AUD nal units for pkt->data.
> >
> > here is the patch attached below.
> >
> > Thanks for your any advice.
>
>
> [...]
> > +int check_aud_nal_units(AVPacket * pkt)
> > +{
> > +    int size = pkt->size;
> > +    uint8_t *buf = pkt->data;
> > +    int buf_index = 0;
> > +    int is_aud = 0;
> > +    uint8_t *new_buf = 0;
> > +    for(; buf_index + 3 < size; buf_index++){
> > +        if(buf[buf_index] == 0 && buf[buf_index+1] == 0 &&
> buf[buf_index+2] == 1){
> > +            is_aud = 1;
> > +            break;
> > +        }
> > +    }
>
> > +    if(!is_aud){
> > +    new_buf = av_mallocz(size + 3);
>
> missing indention
>
>
> > +    if (!new_buf)
> > +        return 0;
> > +    new_buf[0] = 0;
> > +    new_buf[1] = 0;
> > +    new_buf[2] = 1;
> > +    memcpy(new_buf + 3, buf, size);
> > +    av_free(buf);
> > +    pkt->data = new_buf;
> > +    pkt->size = size + 3;
>
> trailing whitespace
>
>
> [...]
> > @@ -406,7 +439,12 @@
> >      int64_t pts, dts;
> >      PacketDesc *pkt_desc;
> >      const int preload= av_rescale(ctx->preload, 90000, AV_TIME_BASE);
> > +    if(st->codec->codec_id == CODEC_ID_H264)
> > +        check_aud_nal_units(pkt);
> >
> > +    int size= pkt->size;
> > +    uint8_t *buf= pkt->data;
> > +
>
> mixing declarations and statements, breaks gcc 2.95 support
>
>
> >      pts= pkt->pts;
> >      dts= pkt->dts;
> >
> > Index: mpegtsenc.c
> > ===================================================================
> > --- mpegtsenc.c       (revision 2130)
> > +++ mpegtsenc.c       (working copy)
> > @@ -288,6 +288,39 @@
> >                  put16(&q, 1); /* ancillary page id */
> >              }
> >              break;
> > +        case CODEC_TYPE_VIDEO:
> > +            {
> > +                if(st->codec->codec_id == CODEC_ID_H264){
> > +                    H264Context * h_st = st->codec->priv_data;
>
> This is invalid, there is a reason why its called priv_data, and that is
> that it is private to the codec.



I think it is the key point to write descriptors into PMT for AVC stream.
Can't I get the h264 codec information when init TS out stream?
Do you mean the *priv_data* only could be used by libavcodec functions, we
can't read some information from it by other extern functions?
If so, I am a little confused how could I get information when init the
descriptor?






-- 
Best wishes~



More information about the FFmpeg-soc mailing list