On Tue, Sep 18, 2012 at 9:03 AM, chinos <[email protected]> wrote:

>  hi all,****
>
> I am trying to decode TS file on android with hardware decoder. And I use
> ffmpeg MPEGTS demuxer.****
>
> To init hardware decoder, extradata (SPS, PPS or sth.) is needed to be set
> for both audio and video decoders. But I can not get extradata of TS file
> by ffmpeg demuxer.****
>
> Does anyone know how to get extradata of TS file using ffmpeg?
>

// open the file...
if (avformat_open_input(&pFormatCtx, filename, NULL, NULL) != 0)
    return -1; // Couldn't open file

// Retrieve stream information
if (avformat_find_stream_info(pFormatCtx, &codec_opts) < 0)
    return -1; // Couldn't find stream information

// Loop over the streams
for(i=0; i<pFormatCtx->nb_streams; i++)
{
    int size = pFormatCtx->streams[i]->codec->extradata_size; // HERE IS
THE SIZE YOU WANT!
    // pFormatCtx->streams[i]->codec->extradata // HERE IS WHAT YOU WANT!
put this into the decoder...

    // let's print it for debug...
    for (int j = 0; j < size; j++ )
    {
        char * p = (char*)(pFormatCtx->streams[i]->codec->extradata + j);
        printf( "%02X", (unsigned char)*p );
     }
}



> ****
>
> Any help is appreciate.****
>
> _______________________________________________
> Libav-user mailing list
> [email protected]
> http://ffmpeg.org/mailman/listinfo/libav-user
>
>
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to