Linux下开发ffmpeg(3),Ffmpeg版本的HelloWorld


目录


重要函数

/**
 * @addtogroup lavu_log
 *
 * @{
 *
 * @defgroup lavu_log_constants Logging Constants
 *
 * @{
 */

/**
 * Print no output.
 */
#define AV_LOG_QUIET    -8

/**
 * Something went really wrong and we will crash now.
 */
#define AV_LOG_PANIC     0

/**
 * Something went wrong and recovery is not possible.
 * For example, no header was found for a format which depends
 * on headers or an illegal combination of parameters is used.
 */
#define AV_LOG_FATAL     8

/**
 * Something went wrong and cannot losslessly be recovered.
 * However, not all future data is affected.
 */
#define AV_LOG_ERROR    16

/**
 * Something somehow does not look correct. This may or may not
 * lead to problems. An example would be the use of '-vstrict -2'.
 */
#define AV_LOG_WARNING  24

/**
 * Standard information.
 */
#define AV_LOG_INFO     32

/**
 * Detailed information.
 */
#define AV_LOG_VERBOSE  40

/**
 * Stuff which is only useful for libav* developers.
 */
#define AV_LOG_DEBUG    48
/**
 * Set the log level
 *
 * @see lavu_log_constants
 *
 * @param level Logging level
 */
void av_log_set_level(int level);
/**
 * 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 or NULL if general log.
 * @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);

在(1)(2)的基础上写一个ffmpeg版本的HelloWorld

mylog.c


#include 
#include 

int main(int argc,char* argv[]){
        //设置debug级别以上的日志都被打印
        av_log_set_level(AV_LOG_DEBUG);
        av_log(NULL,AV_LOG_DEBUG,"Hello World\n");
        return 0;
}

编译mylog

gcc -g -o mylog mylog.c -I /usr/local/ffmpeg/include/ -L /usr/local/ffmpeg/lib/ -lavutil

运行

root@zhangyu-virtual-machine:/home/zhangyu/test# gcc -g -o mylog mylog.c -I /usr/local/ffmpeg/include/ -L /usr/local/ffmpeg/lib/ -lavutil
root@zhangyu-virtual-machine:/home/zhangyu/test# ./mylog 
Hello World

你可能感兴趣的:(音视频,Linux,C/C++)