[Libav-user] how to get extradata of MPEGTS using ffmpeg?
Wagner Patriota
wagner.patriota at gmail.com
Tue Sep 18 21:17:56 CEST 2012
On Tue, Sep 18, 2012 at 9:03 AM, chinos <chinos at microrapid.com> 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
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20120918/d09bdfbc/attachment.html>
More information about the Libav-user
mailing list