文档章节

FFMPEG调用函数init_input()初始化流时日志说明

andrew810810
 andrew810810
发布于 2016/12/09 15:02
字数 980
阅读 210
收藏 0
点赞 0
评论 0

日志示例:

[root@andrew ffmpeg-3.2]# ./ffmpeg -i rtmp://180.97.184.107:1936/live?vhost=cc.com/stream_1 -c copy -y -f flv test_out1.flv -v 56 -t 10
ffmpeg version 3.2-static Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-16)
  configuration: --enable-gpl --enable-nonfree --disable-shared --enable-postproc --enable-bzlib --enable-zlib --enable-parsers --enable-libx264 --enable-libx265 --enable-libmp3lame --enable-libfdk-aac --enable-pthreads --extra-ldflags=-static --disable-ffserver --enable-ffplay --enable-asm --enable-yasm --enable-optimizations --pkg-config-flags=--static --extra-cflags=--static --extra-version=static --enable-libspeex --extra-ldflags=-L/usr/local/lib --extra-cflags=-I/usr/local/include --extra-libs=-lrtmp
  libavutil      55. 34.100 / 55. 34.100
  libavcodec     57. 64.100 / 57. 64.100
  libavformat    57. 56.100 / 57. 56.100
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
Splitting the commandline.
Reading option '-i' ... matched as input file with argument 'rtmp://180.97.184.107:1936/live?vhost=cc.com/stream_1'.
Reading option '-c' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'flv'.
Reading option 'test_out1.flv' ... matched as output file.
Reading option '-v' ... matched as option 'v' (set logging level) with argument '56'.
Reading option '-t' ... matched as option 't' (record or transcode "duration" seconds of audio/video) with argument '10'.
Trailing options were found on the commandline.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option y (overwrite output files) with argument 1.
Applying option v (set logging level) with argument 56.
Successfully parsed a group of options.
Parsing a group of options: input file rtmp://180.97.184.107:1936/live?vhost=cc.com/stream_1.
Successfully parsed a group of options.
Opening an input file: rtmp://180.97.184.107:1936/live?vhost=cc.com/stream_1.
[rtmp @ 0x3a615e0] No default whitelist set
[tcp @ 0x3a61ac0] No default whitelist set
[rtmp @ 0x3a615e0] Handshaking...
[rtmp @ 0x3a615e0] Type answer 3
[rtmp @ 0x3a615e0] Server version 13.14.10.13
[rtmp @ 0x3a615e0] Proto = rtmp, path = /live?vhost=cc.com/stream_1, app = live?vhost=cc.com, fname = stream_1
[rtmp @ 0x3a615e0] Server bandwidth = 5000000
[rtmp @ 0x3a615e0] Client bandwidth = 5000000
[rtmp @ 0x3a615e0] New incoming chunk size = 4096
[rtmp @ 0x3a615e0] Creating stream...
[rtmp @ 0x3a615e0] Sending play command for 'stream_1'
Probing flv score:100 size:2048
Probing mp3 score:1 size:2048
[flv @ 0x3a60c80] Format flv probed with size=2048 and score=100
[flv @ 0x3a60c80] Before avformat_find_stream_info() pos: 13 bytes read:33294 seeks:0 nb_streams:0
[flv @ 0x3a60c80] type:18, size:405, last:-1, dts:0 pos:21
[flv @ 0x3a60c80] type:8, size:7, last:-1, dts:1614036 pos:441
[flv @ 0x3a60c80] audio stream discovered after head already parsed
[flv @ 0x3a60c80] 1 AF 0 
[flv @ 0x3a60c80] type:9, size:56, last:-1, dts:1614046 pos:463
[flv @ 0x3a60c80] video stream discovered after head already parsed
[flv @ 0x3a60c80] 0 17 0 
[flv @ 0x3a60c80] type:9, size:52148, last:-1, dts:1614088 pos:534
[flv @ 0x3a60c80] 0 17 0 
[NULL @ 0x3a74ee0] nal_unit_type: 7, nal_ref_idc: 3
[NULL @ 0x3a74ee0] nal_unit_type: 8, nal_ref_idc: 3
[h264 @ 0x3a74ee0] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x3a74ee0] nal_unit_type: 8, nal_ref_idc: 3
[h264 @ 0x3a74ee0] nal_unit_type: 5, nal_ref_idc: 3
[h264 @ 0x3a74ee0] Reinit context to 1920x1088, pix_fmt: yuv420p
[h264 @ 0x3a74ee0] no picture

 

日志函数av_log()

void av_log(void* avcl, int level, const char *fmt, ...)
{
    AVClass* avc = avcl ? *(AVClass **) avcl : NULL;
    va_list vl;
    va_start(vl, fmt);
    if (avc && avc->version >= (50 << 16 | 15 << 8 | 2) &&
        avc->log_level_offset_offset && level >= AV_LOG_FATAL)
        level += *(int *) (((uint8_t *) avcl) + avc->log_level_offset_offset);
    av_vlog(avcl, level, fmt, vl);
    va_end(vl);
}

 

av_log()第一个参数为NULL

例如:

av_log(NULL, AV_LOG_DEBUG, "Splitting the commandline.\n");

直接输出日志内容

av_log()第一个参数有明确的类型

例如:

av_log(uc, AV_LOG_DEBUG, "No default whitelist set\n");

其中URLContext *uc。

根据av_log定义,输出class_name的内容。

其中libavformat/rtmpproto.c,对于rtmp协议,item_name()函数回调av_default_item_name函数(),而class_name为rtmp

const char *av_default_item_name(void *ptr)
{
    return (*(AVClass **) ptr)->class_name;
}


#define RTMP_PROTOCOL(flavor)                    \
static const AVClass flavor##_class = {          \
    .class_name = #flavor,                       \
    .item_name  = av_default_item_name,          \
    .option     = rtmp_options,                  \
    .version    = LIBAVUTIL_VERSION_INT,         \
};                                               \
                                                 \
const URLProtocol ff_##flavor##_protocol = {     \
    .name           = #flavor,                   \
    .url_open       = rtmp_open,                 \
    .url_read       = rtmp_read,                 \
    .url_read_seek  = rtmp_seek,                 \
    .url_read_pause = rtmp_pause,                \
    .url_write      = rtmp_write,                \
    .url_close      = rtmp_close,                \
    .priv_data_size = sizeof(RTMPContext),       \
    .flags          = URL_PROTOCOL_FLAG_NETWORK, \
    .priv_data_class= &flavor##_class,           \
};


RTMP_PROTOCOL(rtmp)
RTMP_PROTOCOL(rtmpe)
RTMP_PROTOCOL(rtmps)
RTMP_PROTOCOL(rtmpt)
RTMP_PROTOCOL(rtmpte)
RTMP_PROTOCOL(rtmpts)

其中libavformat/tcp.c,对于tcp协议,item_name()函数回调av_default_item_name函数(),而class_name为tcp

const char *av_default_item_name(void *ptr)
{
    return (*(AVClass **) ptr)->class_name;
}


static const AVClass tcp_class = {
    .class_name = "tcp",
    .item_name  = av_default_item_name,
    .option     = options,
    .version    = LIBAVUTIL_VERSION_INT,
};

const URLProtocol ff_tcp_protocol = {
    .name                = "tcp",
    .url_open            = tcp_open,
    .url_accept          = tcp_accept,
    .url_read            = tcp_read,
    .url_write           = tcp_write,
    .url_close           = tcp_close,
    .url_get_file_handle = tcp_get_file_handle,
    .url_shutdown        = tcp_shutdown,
    .priv_data_size      = sizeof(TCPContext),
    .flags               = URL_PROTOCOL_FLAG_NETWORK,
    .priv_data_class     = &tcp_class,
};

av_log()第一个参数使用默认类型

例如:

av_log(logctx, AV_LOG_DEBUG,
                       "Format %s probed with size=%d and score=%d\n",
                       (*fmt)->name, probe_size, score);

static const char* format_to_name(void* ptr)
{
    AVFormatContext* fc = (AVFormatContext*) ptr;
    if(fc->iformat) return fc->iformat->name;
    else if(fc->oformat) return fc->oformat->name;
    else return "NULL";
}

static const AVClass av_format_context_class = {
    .class_name     = "AVFormatContext",
    .item_name      = format_to_name,
    .option         = avformat_options,
    .version        = LIBAVUTIL_VERSION_INT,
    .child_next     = format_child_next,
    .child_class_next = format_child_class_next,
    .category       = AV_CLASS_CATEGORY_MUXER,
    .get_category   = get_category,
};


static void avformat_get_context_defaults(AVFormatContext *s)
{
    memset(s, 0, sizeof(AVFormatContext));

    s->av_class = &av_format_context_class;

    s->io_open  = io_open_default;
    s->io_close = io_close_default;

    av_opt_set_defaults(s);
}

static const AVClass flv_class = {
    .class_name = "flvdec",
    .item_name  = av_default_item_name,
    .option     = options,
    .version    = LIBAVUTIL_VERSION_INT,
};

AVInputFormat ff_flv_demuxer = {
    .name           = "flv",
    .long_name      = NULL_IF_CONFIG_SMALL("FLV (Flash Video)"),
    .priv_data_size = sizeof(FLVContext),
    .read_probe     = flv_probe,
    .read_header    = flv_read_header,
    .read_packet    = flv_read_packet,
    .read_seek      = flv_read_seek,
    .read_close     = flv_read_close,
    .extensions     = "flv",
    .priv_class     = &flv_class,
};

其中函数item_name()回调函数format_to_name(),所以打印出:[flv @ 0x3a60c80] Format flv probed with size=2048 and score=100

© 著作权归作者所有

共有 人打赏支持
andrew810810
粉丝 3
博文 127
码字总数 117648
作品 0
朝阳
android端采用FFmpeg进行音频混合与拼接剪切

接触FFmpeg有一段时间了,它是音视频开发的开源库,几乎其他所有播放器、直播平台都基于FFmpeg进行二次开发。本篇文章来总结下采用FFmpeg进行音频处理:音频混合、音频剪切、音频拼接与音频转...

mp624183768 ⋅ 05/13 ⋅ 0

ONVIF协议网络摄像机(IPC)客户端程序开发(12):读取音视频流

1 专栏导读 本专栏第一篇文章「专栏开篇」列出了专栏的完整目录,按目录顺序阅读,有助于你的理解,专栏前面文章讲过的知识点(或代码段),后面文章不会赘述。为了节省篇幅,突出重点,在文...

benkaoya ⋅ 2017/05/19 ⋅ 0

centos上安装ffmpeg

FFmpeg介绍 FFmpeg是一个开源免费跨平台的视频和音频流方案,属于自由软件,采用LGPL或GPL许可证(依据你选择的组件)。它提供了录制、转换以及流化音视频的完整解决方案。它包含了非常先进的...

水墨如丹青 ⋅ 04/13 ⋅ 0

通过FFmpeg解码和OpenGL的YUV转RGB实现Android视频播放

前言 在我的博文 https://blog.csdn.net/ericbar/article/details/80506390 中,我们在Android平台上,实现了通过FFmpeg在native(C/C++)层进行视频解码,并通过OpenGL实现了硬件渲染工作,...

ericbar ⋅ 05/30 ⋅ 0

FFMPEG命令行处理视频进阶——高阶必读

FFMPEG拥有强大的视频处理能力,可惜的是有很多人不知道如何使用。本文深入介绍如何用编译好ffmpeg.exe程序处理视频,既有常用的简单的处理,也有一些比较少见的高大上的处理,一定能让你受益...

zhangamxqun ⋅ 05/13 ⋅ 0

ckplayer播放器解决MP4文件缓冲结束前无法播放的方法

最近给客户上传mp4的视频,发现不下载完成,不会播放,查了下,视频要等加载完才能播放,而不是边加载边播放这是因为视频的元数据信息不在第一帧所致。元数据是指保存视频属性的一组参数,比...

likeni1314 ⋅ 2017/05/10 ⋅ 0

ffmpeg: hls 转流 rtmp

最近遇到一个需求,需要将hls协议的直播流转换成rtmp协议的直播流;在网上找了很长时间,没有找到相应的技术文章,最后leader给了一个终极命令搞定: 如果提示缺少 libx264 ,可能是你安装f...

那只是一股逆流 ⋅ 04/27 ⋅ 0

ffmpeg多种码率控制方式的实现

ffmpeg是我们进行视频编解码常用的工具,而对于ffmpeg中编码时对码率的控制方式一直没找合适的教程,无意中在stackoverflow上发现了答案,在此进行总结备忘。 视频编码器常用的码率控制方式包...

tifentan ⋅ 04/13 ⋅ 0

M3U8下载,直播源下载,FLASH下载(一)-ffmpeg安装手册(windows)

前言 FFmpeg是一套可以用来记录、转换数字音频、视频,并能将其转化为流的开源计算机程序。采用LGPL或GPL许可证。它提供了录制、转换以及流化音视频的完整解决方案。它包含了非常先进的音频/...

u_ascend ⋅ 05/23 ⋅ 0

FFmpeg 4.0.1 版本发布,多媒体处理工具合集

FFmpeg 4.0.1 已发布,FFmpeg 是用于处理音频、视频、字幕和相关元数据的多媒体内容的库和工具的合集。 库: 提供广泛的编解码器实现 流协议、容器格式和基本 I / O 访问实现 hashers、decom...

王练 ⋅ 06/18 ⋅ 0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

Jenkins实践3 之脚本

#!/bin/sh# export PROJ_PATH=项目路径# export TOMCAT_PATH=tomcat路径killTomcat(){pid=`ps -ef | grep tomcat | grep java|awk '{print $2}'`echo "tom...

晨猫 ⋅ 今天 ⋅ 0

Spring Bean的生命周期

前言 Spring Bean 的生命周期在整个 Spring 中占有很重要的位置,掌握这些可以加深对 Spring 的理解。 首先看下生命周期图: 再谈生命周期之前有一点需要先明确: Spring 只帮我们管理单例模...

素雷 ⋅ 今天 ⋅ 0

zblog2.3版本的asp系统是否可以超越卢松松博客的流量[图]

最近访问zblog官网,发现zlbog-asp2.3版本已经进入测试阶段了,虽然正式版还没有发布,想必也不久了。那么作为aps纵横江湖十多年的今天,blog2.2版本应该已经成熟了,为什么还要发布这个2.3...

原创小博客 ⋅ 今天 ⋅ 0

聊聊spring cloud的HystrixCircuitBreakerConfiguration

序 本文主要研究一下spring cloud的HystrixCircuitBreakerConfiguration HystrixCircuitBreakerConfiguration spring-cloud-netflix-core-2.0.0.RELEASE-sources.jar!/org/springframework/......

go4it ⋅ 今天 ⋅ 0

二分查找

二分查找,也称折半查找、二分搜索,是一种在有序数组中查找某一特定元素的搜索算法。搜素过程从数组的中间元素开始,如果中间元素正好是要查找的元素,则搜素过程结束;如果某一特定元素大于...

人觉非常君 ⋅ 今天 ⋅ 0

VS中使用X64汇编

需要注意的是,在X86项目中,可以使用__asm{}来嵌入汇编代码,但是在X64项目中,再也不能使用__asm{}来编写嵌入式汇编程序了,必须使用专门的.asm汇编文件来编写相应的汇编代码,然后在其它地...

simpower ⋅ 今天 ⋅ 0

ThreadPoolExecutor

ThreadPoolExecutor public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, ......

4rnold ⋅ 昨天 ⋅ 0

Java正无穷大、负无穷大以及NaN

问题来源:用Java代码写了一个计算公式,包含除法和对数和取反,在页面上出现了-infinity,不知道这是什么问题,网上找答案才明白意思是负的无穷大。 思考:为什么会出现这种情况呢?这是哪里...

young_chen ⋅ 昨天 ⋅ 0

前台对中文编码,后台解码

前台:encodeURI(sbzt) 后台:String param = URLDecoder.decode(sbzt,"UTF-8");

west_coast ⋅ 昨天 ⋅ 0

实验楼—MySQL基础课程-挑战3实验报告

按照文档要求创建数据库 sudo sercice mysql startwget http://labfile.oss.aliyuncs.com/courses/9/createdb2.sqlvim /home/shiyanlou/createdb2.sql#查看下数据库代码 代码创建了grade......

zhangjin7 ⋅ 昨天 ⋅ 0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部