[Libav-user] Accessing basic video parameters

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Libav-user] Accessing basic video parameters

rohit khali
Very surprsing, Can't we get basic details about stream without decoding using libavcodec APIs like width,height.?
It's all part of sps/pps. I am using  av_parser_parse2() API, which forms an AVC frame.
Please help.

Output:
{profile=100 level=31 width=0 height=0 codedwidth=0 codedheight=0 pix_fmt=(null) aspectRatio=0:1         frameRate=0:1 slices=0 } 

Code: /*In my case there is no Input File, I get H264-ES in "data" as below*/
AVCodec* codec = avcodec_find_decoder(AV_CODEC_ID_H264);
AVCodecParserContext* parser = av_parser_init(codec->id);
AVCodecContext* dec_ctx;
dec_ctx = avcodec_alloc_context3(codec);
av_parser_parse2(parser, dec_ctx, &pkt->data, &pkt->size,
                                   data, data_size, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);
if (pkt->size)
    { 
        printf("{profile=%d level=%d width=%d height=%d codedwidth=%d codedheight=%d pix_fmt=%s aspectRatio=%d:%d 
        frameRate=%d:%d slices=%d }\n",
        dec_ctx->profile,
        dec_ctx->level,
        dec_ctx->width,
        dec_ctx->height,
        dec_ctx->coded_width,
        dec_ctx->coded_height,
        av_get_pix_fmt_name((AVPixelFormat)dec_ctx->pix_fmt),
        dec_ctx->sample_aspect_ratio.num,
        dec_ctx->sample_aspect_ratio.den,
        dec_ctx->framerate.num,
        dec_ctx->framerate.den,
        dec_ctx->slices
        );
}

_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".