Thanks Stefano, for your suggest. I never used av_log then I looked around.
I implemented the follow avlog callback, to log info into file.

--------
static void ffmpeg_avcodec_log(void *ptr, int val, const char * msg, va_list
ap)
{
        AVClass* avc= ptr ? *(AVClass**)ptr : NULL;

        FILE *flog=fopen("MMedia.log","a");
        fprintf(flog, "[%s @ %p] ", avc->item_name(ptr), avc);
      vfprintf(flog, msg, ap);
        fclose(flog);
}
---------

And the new code is this:

---------
int CFFDecode::Init(int codec_id, int width, int height, int fps)
{
        if ((width & 1) == 1) return E_INVALIDARG;
        if ((height & 1) == 1) return E_INVALIDARG;

        av_log_set_callback( ffmpeg_avcodec_log );

        m_codec = avcodec_find_decoder((CodecID)codec_id);
        if (m_codec == NULL) {DbgOut("FFINIT OK");return E_FAIL;}

        m_c = avcodec_alloc_context(); 
        if (m_c == NULL) 
                {DbgOut("avcodec_alloc_context error");return
E_OUTOFMEMORY;}

        avcodec_get_context_defaults2(m_c, CODEC_TYPE_VIDEO);
        avcodec_get_frame_defaults(&m_picture);
        
        m_c->codec_id = (CodecID) codec_id;
        m_c->codec_type = CODEC_TYPE_VIDEO;
        m_c->strict_std_compliance = 0;

        m_c->width = width;
        m_c->height = height;
        m_c->time_base.den = fps;
        m_c->time_base.num = 1;
        m_c->gop_size = 12;
        m_c->pix_fmt = PIX_FMT_BGR24;

        /* open the codec */
        int iRetOpen = avcodec_open(m_c, m_codec);
        if ( iRetOpen < 0) {
                av_log(m_c, AV_LOG_DEBUG, "Fail avcodec_open\n");
                return E_FAIL;
                
        }
--------------

Into log file I've only this information!

[NULL @ 68C432E0] Fail avcodec_open

I can't undertand where is the problem

thanks


Stefano Falasca


_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to