zoukankan      html  css  js  c++  java
  • 在CB2010中调用ffmpeg(4)

    1. Log

    多看一些代码,发现av_log函数。不用猜,av_log肯定是日志记录之类的。

    一般而言,Log对于编程调试有较大帮助。今天先从这里入手。

    不过看声明,倒是有点云里雾里。

    /**

    * Send the specified message to the log if the level is less than or equal

    * to the current av_log_level. By default, all logging messages are sent to

    * stderr. This behavior can be altered by setting a different logging callback

    * function.

    * @see av_log_set_callback

    *

    * @param avcl A pointer to an arbitrary struct of which the first field is a

    * pointer to an AVClass struct.

    * @param level The importance level of the message expressed using a @ref

    * lavu_log_constants "Logging Constant".

    * @param fmt The format string (printf-compatible) that specifies how

    * subsequent arguments are converted to output.

    */

    void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4);

    继续找,找到定义

    #ifdef __GNUC__

    # define av_builtin_constant_p __builtin_constant_p

    # define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos)))

    #else

    # define av_builtin_constant_p(x) 0

    # define av_printf_format(fmtpos, attrpos)

    #endif

    还是不明白。还是看下注释。

    哦,日志写到stderr,这下怎么看?

    幸亏还有callback方式。

    不过,这用法还有点奇葩,不然别人怎么会写得如此专业。我以前写的程序都是自己用,日志等功能基本都是写到文件中,级别倒是分了,但从来没有写成回调形式的。

    看来我算是业余选手。

    不过,回调应该好处理,自己加一个:

    static void avLogByDrGraph(void *, int level, const char * szFmt, va_list varg) {

        UnicodeString info, fmt = szFmt;

        va_list args;

        va_start(args, fmt);

        info.vprintf(fmt.w_str(), args);

        va_end(args);

        FFMPEGTestForm->Memo1->Lines->Add(info);

    }

    这效果,刚刚的。

  • 相关阅读:
    合并报表优化记录
    如何在后台代码中执行原生sql?
    eclipse从数据库逆向生成Hibernate实体类
    用Eclipse进行远程Debug代码
    hibernate自动生成数据库表
    hibernate自动生成数据库表
    php通过UNIX源码编译安装
    php设置方法
    php其他配制选项
    终于做出了目录认证!
  • 原文地址:https://www.cnblogs.com/drgraph/p/3607694.html
Copyright © 2011-2022 走看看