[FFmpeg-user] Unable to Retrieve codec_name from video stream codec context.

whoami Jils get2jils at gmail.com
Wed Feb 19 12:54:10 CET 2014


I am trying the below code:

   if (avformat_open_input(&pFormatCtx, "rtsp://<ip>:<port>/", NULL, NULL)
!= 0)  {
                return -1; // Couldn't open file
        }


   vStream = -1;
        for (i = 0; i < pFormatCtx->nb_streams; i++)
                if (pFormatCtx->streams[i]->codec->codec_type ==
AVMEDIA_TYPE_VIDEO) {
                        vStream = i;
                        break;
                }
        if (vStream == -1)
                return -1; // Didn't find a video stream



        // Get a pointer to the codec context for the video stream
        pCodecCtx = pFormatCtx->streams[videoStream]->codec;

        LOGD (" Codec Context Height %d  Width %d Codec Name %s ",
pCodecCtx->height, pCodecCtx->width, pCodecCtx->codec_name );


I get the output  0 0,
and for codec_name nothing gets printed. due to this lots of other issues
are raising, as i dont have proper value in it.

It is expected behavior that stream may not have information ?


More information about the ffmpeg-user mailing list