ffmpeg.c(ffmpeg.exe)调试笔记一

调试参数:

ffmpeg -ss 00:00:00 -i D:\media\Linux.mpg -vcodec copy -acodec copy -t 00:01:00 C:\Users\a\Desktop\half.mpg

一共16个参数

find_option找到了我们传递的参数选项,如ss

 

/* Register a function to be called when `exit' is called.  */

int atexit (void (*__func) (void))

 

strchr

strchr查找字符s中首次出现字符c位置

返回首次出现c的位置的指针,如果s中不存在c则返回NULL

 

 

函数名: setvbuf

: 把缓冲区与流相关

int setvbuf(FILE *stream, char *buf, int type, unsigned size);

参数:stream :指向流的指针 

buf       期望缓冲区的地址;

type    期望缓冲区的类型:

_IOFBF(满缓冲):当缓冲区为空时,从流读入数据。或者当缓冲区满时,向流写入数  据。

_IOLBF(行缓冲):每次从流中读入一行数据或向流中写入一行数据。

_IONBF(无缓冲):直接从流中读入数据或直接向流中写入数据,而没有缓冲区。

size      缓冲区内字节的数量。

注意:This function should be called once the file associated with the stream has already been opened but before any input or output operation has taken place.

意思是这个函数应该在打开流后,立即调用,在任何对该流做输入输出前

 

ld.exe: cannot open output file ffmpeg_g.exe: Permission denied

结束进程,如果不能结束,重新启动eclipse

 

函数名: strncmp

: 串比较

: int strncmp(char *str1, char *str2, int maxlen);

说明:此函数功能即比较字符str1str2maxlen个字符。如果前maxlen字节完全相等,返回值就=0;在前maxlen字节比较过程中,如果出现str1[n]str2[n]不等,则返回(str1[n]-str2[n])。

avformat_network_deinit

Undo the initialization done by avformat_network_init. 

signal

signal(SIGINT , sigterm_handler); /* Interrupt (ANSI).    */

能: 设置某一信号的对应动作

memset

void *memset(void *s,int ch,size_t n);

函数解释:将 s 中前 n 字节 ch 替换并返回 s

memset:作用是在一段内存块中填充某个给定的值,它是对较大的结构体数组进行清零操作的一种最快方法

 

 

OptionParseContext//上下文

 

prepare_app_arguments//wide-char to UTF-8 conversion

 

至于UYVY422转为YUV420P,会用到sws_getContext()sws_scale()函数。struct SwsContext结构体一般用于不同格式之间的转换。sws_getContext函数会把UYVY422格式转换为YUV420P

日志

虽然有

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

但实际在eclipse中调试时不输出调试信息:

跟踪代码发现:

if (level > av_log_level)  //32

        return;

#define AV_LOG_DEBUG    48

 

解决

#include "libavutil/log.h"

av_log_set_level(AV_LOG_DEBUG);

 


 

AVOptions尚未跟踪进去(在split_commandline

 

时间问题

max_analyze_duration 5000000 reached at 5000000

 

> I feel this must be a really obvious question but after 
> searching online I find many mentions but no explanation: 

> a)what exactly this message means 

That 5000000 bytes were used to compute the overall duration, 
and this was >= the maximum size for computing the overall 
duration, either specified by you or the default (which 
is 5000000). 

> b)what will happen as a result 

The overall duration may be computed incorrectly. 

> c)what I'm supposed to do about it 

Either ignore it or specify a larger -analyzeduration

(It is absolutely possible that none of the above applies to 
the image2 demuxer, I just gave the general answer.) 

avformat_find_stream_info

max_analyze_duration

if (t >= ic->max_analyze_duration) {

                av_log(ic, AV_LOG_WARNING, "max_analyze_duration %d reached at %"PRId64"\n", ic->max_analyze_duration, t);

                break;

mediainfo显示2分钟,但ffmpeg后面有个.04是什么意思?

1秒=1000毫秒,那500毫秒如何表示?

根据源码

(100 * us) / AV_TIME_BASE)  //AV_TIME_BASE=1000000

500毫秒=500 000微秒*100=50  0 00  0 00再除以1 000 000=50结果会显示50,即将毫秒(千进制)转化成100进制表示。

此处的45000表示微秒(转换为45毫秒),转化后为4.5,结果取整就是04.(%2d)

反过来:

04就是4,(因为千进制现在转化成百进制,所以想知道其含义,就乘以10就可以了,即40毫秒

 

%02d

2是宽度很简单。如果整数不够2列就补上0
比如
printf("%02d" ,3);

结果就是
03
如果大于2没有影响
printf("%02d",1234);
1234

time_base

AVRational time_base;

// 帧率做分母,秒做分子,那么time_base也就是一帧所用时间。(时间基!)

c->time_base.den = STREAM_FRAME_RATE;

c->time_base.num = 1;

 

volatile

volatile的作用: 作为指令关键字,确保本条指令不会因编译器的优化而省略,且要求每次直接读值.

简单地说就是防止编译器对代码进行优化.

volatile提醒编译器它后面所定义的变量随时都有可能改变,因此编译后的程序每次需要存储或读取这个变量的时候,都会直接从变量地址中读取数据。如果没有volatile关键字,则编译器可能优化读取和存储,可能暂时使用寄存器中的值,如果这个变量由别的程序更新了的话,将出现不一致的现象。

 

“int64_t”: 将此类型用作表达式非法

error C2275: “int64_t”: 将此类型用作表达式非法

移植c++代码到c的时候,经常会出现一个奇怪的错误, error C2275: “XXX”: 将此类型用作表达式非法,
这个错误是由于c的编译器要求将变量的声明放在所有函数调用语句之前,而c++没有这样的要求造成的。
解决的办法就是把变量的声明全部放在变量的生存块的开始

原文地址:https://www.cnblogs.com/elesos/p/2989177.html