ffmpeg系列-解决ffmpeg获取aac音频文件duration不准

2023-05-16

这个问题是这样产生的,一同事反应会随机出现ijk获取到的aac文件的duration不准,发来一看,确实不准,在AE或者系统mediaplayer中得到的都是8.4秒(准确时间是MtkAACExtractor: ADTS: duration = 8448000 us),ijk得到的是9.3秒,在播放的时候,在8秒的时候流就结束了,放到编译的ffmpeg中,一看也是9.3秒。

1.分析问题

下面开始分析这个问题,命令行看下这个文件,ffmpeg中获取到的确实是9.3秒
image

仔细看下红色箭头所指,这个意思是获取到的duration是根据比特率计算的,可能不准确。这种获取音视频info有问题的我们一般可以从avformat_find_stream_info函数开始分析。

这里直接从log开始看,waring出现出现在utils.c/libavformat下

static void estimate_timings_from_bit_rate(AVFormatContext *ic)
{
    int64_t filesize, duration;
    int i, show_warning = 0;
    AVStream *st;
	
	av_log(ic, AV_LOG_WARNING,
				   "hxk-->ic->bit_rate:%lld\n",ic->bit_rate);
	//这里从log可以看到,bitrate也没获取到,bitrate = 0
    /* if bit_rate is already set, we believe it */
    if (ic->bit_rate <= 0) {
        int64_t bit_rate = 0;
        for (i = 0; i < ic->nb_streams; i++) {
            st = ic->streams[i];
			
            if (st->codecpar->bit_rate <= 0 && st->internal->avctx->bit_rate > 0)
                st->codecpar->bit_rate = st->internal->avctx->bit_rate;
            if (st->codecpar->bit_rate > 0) {
                if (INT64_MAX - st->codecpar->bit_rate < bit_rate) {
                    bit_rate = 0;
                    break;
                }
                bit_rate += st->codecpar->bit_rate;
            } else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->codec_info_nb_frames > 1) {
                // If we have a videostream with packets but without a bitrate
                // then consider the sum not known
                bit_rate = 0;
                break;
            }
        }
        //这里算出来一个bitrate
        ic->bit_rate = bit_rate;
		av_log(ic, AV_LOG_WARNING,
				   "hxk-->ic->bit_rate:%lld\n",ic->bit_rate);
    }
    //从log中可以看到,这里的duration也是0

    /* if duration is already set, we believe it */
	av_log(ic, AV_LOG_WARNING,
               "hxk-->ic->duration:%lld\n",ic->duration);
    if (ic->duration == AV_NOPTS_VALUE &&
        ic->bit_rate != 0) {
        filesize = ic->pb ? avio_size(ic->pb) : 0;
		av_log(ic, AV_LOG_WARNING,
               "hxk-->ic->filesize:%lld\n",filesize);
        if (filesize > ic->internal->data_offset) {
            filesize -= ic->internal->data_offset;
            for (i = 0; i < ic->nb_streams; i++) {
                st      = ic->streams[i];
                if (   st->time_base.num <= INT64_MAX / ic->bit_rate
                    && st->duration == AV_NOPTS_VALUE) {
                    //这里根据文件字节*8 /比特率来计算duration,这里cbr这样计算可以计算,但是如果vbr(码率动态)的话就有问题了
                    duration = av_rescale(8 * filesize, st->time_base.den,
                                          ic->bit_rate *
                                          (int64_t) st->time_base.num);
                //获取到的duration就不准确了
                    st->duration = duration;
                    show_warning = 1;
                }
            }
        }
    }
    if (show_warning)
        av_log(ic, AV_LOG_WARNING,
               "Estimating duration from bitrate, this may be inaccurate\n");
}

调用上面这个函数的地方是utils.c/libavofrmat:

static void estimate_timings(AVFormatContext *ic, int64_t old_offset)
{
    int64_t file_size;

    /* get the file size, if possible */
    if (ic->iformat->flags & AVFMT_NOFILE) {
        file_size = 0;
    } else {
        file_size = avio_size(ic->pb);
        file_size = FFMAX(0, file_size);
    }
	av_log(ic, AV_LOG_WARNING, "hxk->ic->iformat->name:%s\n", ic->iformat->name);
	av_log(ic, AV_LOG_WARNING, "hxk->file_size:%lld\n", file_size);
	av_log(ic, AV_LOG_WARNING, "hxk->ic->pb->seekable:%d\n", ic->pb->seekable);

    if ((!strcmp(ic->iformat->name, "mpeg") ||
         !strcmp(ic->iformat->name, "mpegts")) &&
        file_size && (ic->pb->seekable & AVIO_SEEKABLE_NORMAL)) {
        /* get accurate estimate from the PTSes */
        estimate_timings_from_pts(ic, old_offset);
        ic->duration_estimation_method = AVFMT_DURATION_FROM_PTS;
    } else if (has_duration(ic)) {
    //如果在demuxer中获取到duration了
        /* at least one component has timings - we use them for all
         * the components */
        fill_all_stream_timings(ic);
        ic->duration_estimation_method = AVFMT_DURATION_FROM_STREAM;
    } else {
    //这个文件没有获取到duration,所以走的是这里
        /* less precise: use bitrate info */
        estimate_timings_from_bit_rate(ic);
        ic->duration_estimation_method = AVFMT_DURATION_FROM_BITRATE;
    }
    update_stream_timings(ic);

    {
        int i;
        AVStream av_unused *st;
        for (i = 0; i < ic->nb_streams; i++) {
            st = ic->streams[i];
            av_log(ic, AV_LOG_TRACE, "stream %d: start_time: %0.3f duration: %0.3f\n", i,
                   (double) st->start_time * av_q2d(st->time_base),
                   (double) st->duration   * av_q2d(st->time_base));
        }
        av_log(ic, AV_LOG_TRACE,
                "format: start_time: %0.3f duration: %0.3f bitrate=%"PRId64" kb/s\n",
                (double) ic->start_time / AV_TIME_BASE,
                (double) ic->duration   / AV_TIME_BASE,
                (int64_t)ic->bit_rate / 1000);
    }
}

调用上面这个方法是在avformat_find_stream_info/utils.c/libavformat函数中。

2.解决问题

原因已经知道了,那么可以如何解决这个问题呢?
aac的duration可以如何获取呢?
我们看下android系统中libstagefright框架中aacextractore的实现

AACExtractor.cpp/libstagefrgiht

AACExtractor::AACExtractor(
        const sp<DataSource> &source, const sp<AMessage> &_meta)
    : mDataSource(source),
      mInitCheck(NO_INIT),
      mFrameDurationUs(0) {
    sp<AMessage> meta = _meta;

    if (meta == NULL) {
        String8 mimeType;
        float confidence;
        sp<AMessage> _meta;

        if (!SniffAAC(mDataSource, &mimeType, &confidence, &meta)) {
            return;
        }
    }

    int64_t offset;
    CHECK(meta->findInt64("offset", &offset));

    uint8_t profile, sf_index, channel, header[2];
    if (mDataSource->readAt(offset + 2, &header, 2) < 2) {
        return;
    }
//获取profile
    profile = (header[0] >> 6) & 0x3;
//获取采样索引
    sf_index = (header[0] >> 2) & 0xf;
//获取采样率
    uint32_t sr = get_sample_rate(sf_index);
    if (sr == 0) {
        return;
    }
//通道
    channel = (header[0] & 0x1) << 2 | (header[1] >> 6);

    mMeta = MakeAACCodecSpecificData(profile, sf_index, channel);

    off64_t streamSize, numFrames = 0;
    size_t frameSize = 0;
    int64_t duration = 0;
//获取文件大小
    if (mDataSource->getSize(&streamSize) == OK) {
         while (offset < streamSize) {
         //获取adts每一帧大小
            if ((frameSize = getAdtsFrameLength(source, offset, NULL)) == 0) {
                return;
            }

            mOffsetVector.push(offset);

            offset += frameSize;//偏移加加
            numFrames ++;//计算帧数目
        }
//***************重点看下这里,这里在下面分析aac文件格式的时候会讲解细致一点*************
        // Round up and get the duration
        mFrameDurationUs = (1024 * 1000000ll + (sr - 1)) / sr;
        duration = numFrames * mFrameDurationUs;//总帧数x一个AAC音频帧的播放时间
        mMeta->setInt64(kKeyDuration, duration);
    }

    mInitCheck = OK;
}

我们再看下getAdtsFrameLength/AACExtractor.cpp/libstagefrgiht函数,这个函数其实就是根据adts头来计算出每一个framesize的大小的

static size_t getAdtsFrameLength(const sp<DataSource> &source, off64_t offset, size_t* headerSize) {
//CRC
    const size_t kAdtsHeaderLengthNoCrc = 7;
    const size_t kAdtsHeaderLengthWithCrc = 9;

    size_t frameSize = 0;
//同步字
    uint8_t syncword[2];
    if (source->readAt(offset, &syncword, 2) != 2) {
        return 0;
    }
    if ((syncword[0] != 0xff) || ((syncword[1] & 0xf6) != 0xf0)) {
        return 0;
    }
//0没有crc,1有crc
    uint8_t protectionAbsent;
	
    if (source->readAt(offset + 1, &protectionAbsent, 1) < 1) {
        return 0;
    }
    protectionAbsent &= 0x1;

    uint8_t header[3];
    if (source->readAt(offset + 3, &header, 3) < 3) {
        return 0;
    }
//获取framesize的大小
    frameSize = (header[0] & 0x3) << 11 | header[1] << 3 | header[2] >> 5;

    // protectionAbsent is 0 if there is CRC
    size_t headSize = protectionAbsent ? kAdtsHeaderLengthNoCrc : kAdtsHeaderLengthWithCrc;
    if (headSize > frameSize) {
        return 0;
    }
    if (headerSize != NULL) {
        *headerSize = headSize;
    }

    return frameSize;
}

上面的实现原理就是根据一个AAC原始帧包含一段时间内1024个采样及相关数据。一个AAC音频帧的播放时间=一个AAC帧对应的采样样本的个数/采样率。所以aac音频文件总时间t=总帧数x一个AAC音频帧的播放时间

下面看一下aac的demuxer,在aacdec.c/libavformat下,发现里面连对aidf头的处理都没有,这个先不管了。

AAC格式:

下面我们先简单看下aac的格式:

详细的AAC格式参考下这篇文章吧,实在懒得写。

AAC文件格式与音频文件时长计算

解决问题

下面我们看下ffmpeg中这个格式的demuxer,这个文件封装格式raw ADTS AAC,下面我们看下aacdec.c/libavformat

修改aacdec.c文件,新加函数

//add by hxk
//获取adts frame的帧长
static int getAdtsFrameLength(AVFormatContext *s,int64_t offset,int* headerSize)
{
	int64_t filesize, position = avio_tell(s->pb);  
    filesize = avio_size(s->pb);
	//av_log(NULL, AV_LOG_WARNING, "hxk->getAdtsFrameLength.filesize:%d\n",filesize);
    const int kAdtsHeaderLengthNoCrc = 7;
    const int kAdtsHeaderLengthWithCrc = 9;
    int frameSize = 0;
    uint8_t syncword[2];
	avio_seek(s->pb, offset, SEEK_SET);
	//读取同步字
    if(avio_read(s->pb,&syncword, 2)!= 2){
		return 0;
	}
    if ((syncword[0] != 0xff) || ((syncword[1] & 0xf6) != 0xf0)) {
        return 0;
    }
	uint8_t protectionAbsent;
	avio_seek(s->pb, offset+1, SEEK_SET);
	//读取protectionAbsent
    if (avio_read(s->pb, &protectionAbsent, 1) < 1) {
        return 0;
    }
    protectionAbsent &= 0x1;
    uint8_t header[3];
//读取header
	avio_seek(s->pb, offset+3, SEEK_SET);
    if (avio_read(s->pb, &header, 3) < 3) {
        return 0;
    }
    
    //获取framesize
    frameSize = (header[0] & 0x3) << 11 | header[1] << 3 | header[2] >> 5;
    // protectionAbsent is 0 if there is CRC
    int headSize = protectionAbsent ? kAdtsHeaderLengthNoCrc : kAdtsHeaderLengthWithCrc;
    if (headSize > frameSize) {
        return 0;
    }
    if (headerSize != NULL) {
        *headerSize = headSize;
    }
    return frameSize;
}
//根据采样率下标获取采样率
static uint32_t get_sample_rate(const uint8_t sf_index)
{
    static const uint32_t sample_rates[] =
    {
        96000, 88200, 64000, 48000, 44100, 32000,
        24000, 22050, 16000, 12000, 11025, 8000
    };

    if (sf_index < sizeof(sample_rates) / sizeof(sample_rates[0])) {
        return sample_rates[sf_index];
    }

    return 0;
}

//add end

修改adts_aac_read_header函数

static int adts_aac_read_header(AVFormatContext *s)
{
	av_log(NULL, AV_LOG_WARNING, "hxk->adts_aac_read_header!\n");

    AVStream *st;
    uint16_t state;

    st = avformat_new_stream(s, NULL);
    if (!st)
        return AVERROR(ENOMEM);

    st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
    st->codecpar->codec_id   = s->iformat->raw_codec_id;
    st->need_parsing         = AVSTREAM_PARSE_FULL_RAW;
    ff_id3v1_read(s);
    if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) &&
        !av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) {
        int64_t cur = avio_tell(s->pb);
        ff_ape_parse_tag(s);
        avio_seek(s->pb, cur, SEEK_SET);
    }

    // skip data until the first ADTS frame is found
    state = avio_r8(s->pb);
    while (!avio_feof(s->pb) && avio_tell(s->pb) < s->probesize) {
        state = (state << 8) | avio_r8(s->pb);
        if ((state >> 4) != 0xFFF)
            continue;
        avio_seek(s->pb, -2, SEEK_CUR);
        break;
    }
    if ((state >> 4) != 0xFFF)
        return AVERROR_INVALIDDATA;

    // LCM of all possible ADTS sample rates
 //   avpriv_set_pts_info(st, 64, 1, 28224000);
//add by hxk
#if  1
        //句柄指回起点
		avio_seek(s->pb, 0, SEEK_SET);
		uint8_t profile, sf_index, channel, header[2];
		//文件指针移动到文件起点前2个字节
		avio_seek(s->pb, 2, SEEK_SET);
		if (avio_read(s->pb,&header, 2) < 2) {
			av_log(NULL, AV_LOG_ERROR, "avio_read header error!\n");
			return 0;
		}
		int64_t offset = 0;
		//获取profile
		profile = (header[0] >> 6) & 0x3;
		st->codecpar->profile = profile;
		//av_log(NULL, AV_LOG_WARNING, "hxk->profile:%d!\n",profile);
		sf_index = (header[0] >> 2) & 0xf;
		//获取采样率
		uint32_t sr = get_sample_rate(sf_index);
		//av_log(NULL, AV_LOG_WARNING, "hxk->samplerate:%d!\n",sr);
		if (sr == 0) {
			av_log(NULL, AV_LOG_ERROR, "avio_read read sampletare error!\n");
			return 0;
		}
		//赋值给codec参数
		st->codecpar->sample_rate = sr;
		//获取通道
		channel = (header[0] & 0x1) << 2 | (header[1] >> 6);
		if (channel == 0) {
			av_log(NULL, AV_LOG_ERROR, "adts_aac_read_header read channel error!\n");
			return 0;
		}
	    //赋值给codec 参数
		st->codecpar->channels = channel;
		//av_log(NULL, AV_LOG_WARNING, "hxk->channel:%d!\n",channel);
		sf_index = (header[0] >> 2) & 0xf;
		int frameSize = 0;
		int64_t mFrameDurationUs = 0;
		int64_t duration = 0;
		//采样率赋值给codec
		st->codecpar->sample_rate = sr;
		int64_t streamSize, numFrames = 0;
	    avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
	    //获取文件大小
		streamSize =  avio_size(s->pb);
	//	av_log(NULL, AV_LOG_WARNING, "hxk->streamSize:%d!\n",streamSize);
		if (streamSize > 0) {
			while (offset < streamSize) {
				if ((frameSize = getAdtsFrameLength(s, offset, NULL)) == 0) {
					  return 0;
				}
				offset += frameSize;//偏移加加
				numFrames ++;//帧数加加,获取总帧数
			//	av_log(NULL, AV_LOG_WARNING, "hxk->frameSize:%d!\n",frameSize);
			}
		//	av_log(NULL, AV_LOG_WARNING, "hxk->numFrames:%lld!\n",numFrames);
			// Round up and get the duration,计算每一帧时间
			mFrameDurationUs = (1024 * 1000000ll + (sr - 1)) / sr;
			duration = numFrames * mFrameDurationUs;//us
			//时间基转换avstream的,us单位(AV_TIME_BASE_Q)转avstream的时间基
			duration = av_rescale_q(duration,AV_TIME_BASE_Q, st->time_base);
			st->duration = duration;
		//	av_log(NULL, AV_LOG_WARNING, "hxk->duration:%d!\n",duration);
		}
		
#endif
//add end

    return 0;
}

这样在demuxer中就获得了duration,在上面的estimate_timings函数中就直接走has_duration这个判断了,得到的duration也是比较准确的了。

运行一下修改后的代码,从下图可以看到时间已经改变了,和android中MtkAACExtractor获取的duration是一样的了。

image

后续

正满心欢喜解决了问题后,把改动的代码移植到ijk上的时候,发现不能播放,没报任何错误,文件info读取都是正确的,seek一下的时候报了这么一行错误

IJKMEDIA: /storage/emulated/0/3ee807175fc2488d8264ac014ccf55ff.aac: error while seeking

原来忘记把句柄置回去了
修改如下:

static int adts_aac_read_header(AVFormatContext *s)
{
    AVStream *st;
    uint16_t state;

    st = avformat_new_stream(s, NULL);
    if (!st)
        return AVERROR(ENOMEM);

    st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
    st->codecpar->codec_id   = s->iformat->raw_codec_id;
    st->need_parsing         = AVSTREAM_PARSE_FULL_RAW;

    ff_id3v1_read(s);
    if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) &&
        !av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) {
        int64_t cur = avio_tell(s->pb);
        ff_ape_parse_tag(s);
        avio_seek(s->pb, cur, SEEK_SET);
    }

    // skip data until the first ADTS frame is found
    state = avio_r8(s->pb);
    while (!avio_feof(s->pb) && avio_tell(s->pb) < s->probesize) {
        state = (state << 8) | avio_r8(s->pb);
        if ((state >> 4) != 0xFFF)
            continue;
        avio_seek(s->pb, -2, SEEK_CUR);
        break;
    }
    if ((state >> 4) != 0xFFF)
        return AVERROR_INVALIDDATA;

    // LCM of all possible ADTS sample rates
   // avpriv_set_pts_info(st, 64, 1, 28224000);
	//add by hxk
#if  1
			
			avio_seek(s->pb, 0, SEEK_SET);
			uint8_t profile, sf_index, channel, header[2];
			avio_seek(s->pb, 2, SEEK_SET);
			if (avio_read(s->pb,&header, 2) < 2) {
				av_log(NULL, AV_LOG_ERROR, "avio_read header error!\n");
				return 0;
			}
			int64_t offset = 0;
			profile = (header[0] >> 6) & 0x3;
			st->codecpar->profile = profile;
			sf_index = (header[0] >> 2) & 0xf;
			uint32_t sr = get_sample_rate(sf_index);
			if (sr == 0) {
				av_log(NULL, AV_LOG_ERROR, "adts_aac_read_header read sampletare error!\n");
				return 0;
			}
			st->codecpar->sample_rate = sr;
			channel = (header[0] & 0x1) << 2 | (header[1] >> 6);
			if(channel == 0) {
				av_log(NULL, AV_LOG_ERROR, "adts_aac_read_header read channel error!\n");
				return 0;
			}
			st->codecpar->channels = channel;
			sf_index = (header[0] >> 2) & 0xf;
			int frameSize = 0;
			int64_t mFrameDurationUs = 0;
			int64_t duration = 0;
			st->codecpar->sample_rate = sr;
			int64_t streamSize, numFrames = 0;
			avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
			streamSize =  avio_size(s->pb);
			//av_log(NULL, AV_LOG_WARNING, "hxk->streamSize:%d!\n",streamSize);
			if (streamSize > 0) {
				while (offset < streamSize) {
					if ((frameSize = getAdtsFrameLength(s, offset, NULL)) == 0) {
						  return 0;
					}
					offset += frameSize;
					numFrames ++;
				//av_log(NULL, AV_LOG_WARNING, "hxk->frameSize:%d!\n",frameSize);
				}
				// av_log(NULL, AV_LOG_WARNING, "hxk->numFrames:%lld!\n",numFrames);
				// Round up and get the duration
				mFrameDurationUs = (1024 * 1000000ll + (sr - 1)) / sr;
				duration = numFrames * mFrameDurationUs;//us
				duration = av_rescale_q(duration,AV_TIME_BASE_Q, st->time_base);
				st->duration = duration;
				//av_log(NULL, AV_LOG_WARNING, "hxk->duration:%d!\n",duration);
			}
			//置回句柄
			avio_seek(s->pb, 0, SEEK_SET);
			
#endif
	//add end

    return 0;
}

嗯,可以获取正确的时间来正常播放了。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ffmpeg系列-解决ffmpeg获取aac音频文件duration不准 的相关文章

随机推荐

  • 【matlab】 GMSK的调制与解调【附详尽注释】

    简介code 1 简介 MSK调制是调制指数为0 5的二元数字频率调制 xff0c 具有很好的特性 xff0c 如恒包络 相对窄的带宽 并可以相干检测 MSK 最小频移键控 信号在任一码元间隔内 xff0c 其相位变化为 2 xff0c 而
  • 【matlab】利用matlab在图形中绘制箭头、标注、圈圈 - 很帅很酷炫

    转载声明 xff1a 感谢 xff1a MyBear 尊重原作者劳动 xff1a http www 360doc com content 14 0527 21 1054746 381542462 shtml 一 二维箭头 1 xff0e 调
  • 【杂谈】甘于平凡?还是思索求生?

    前言 不觉然 xff0c 已19年 xff0c 不知不觉 xff0c 求学生涯至此告一段落 有感觉 xff0c 岁月的痕迹开始发酵 xff0c 身体抑或精神 xff0c 今不如往 思考下 xff0c 互联网浪潮之下 xff0c 之后 xff
  • 匈牙利算法-看这篇绝对就够了!

    本文讲述的是匈牙利算法 xff0c 即图论中寻找最大匹配的算法 xff0c 暂不考虑加权的最大匹配 xff08 用KM算法实现 xff09 xff0c 文章整体结构如下 xff1a 基础概念介绍 算法的实现 好的 xff0c 开始 xff0
  • 面试的一般流程及其常见的问题

    又是一年毕业季 xff0c 也要踏上求职之路 xff0c 在这段时间也关注很多求职方面的消息 下面是一些面试的一般流程及其常见的问题 xff1a 面试职位 xff1a XXXX 开始语 xff1a 你好 xff0c 首先祝贺你通过了前几个环
  • 构建库函数(STM32)

    一 定义外设的各基地址 xff0c 参考存储器映射 span class token comment 由存储器的映射可知 xff0c 片上外设基地址0x4000 0000 span span class token macro proper
  • PID控制器原理概述

    PID控制 PID概述 xff1a 控制框图 xff1a 增量式PID和位置式PID特点 xff1a PID控制参数整定口诀 xff1a 注 xff1a 本文部分内容摘自 先进PID控制MATLAB仿真 xff08 第4版 xff09 刘金
  • PyQt5 事件处理机制

    PyQt5 事件处理机制 PyQt为事件处理提供了两种机制 xff1a 高级的信号与槽机制 xff0c 以及低级的事件处理机制 信号与槽可以说是对事件处理机制的高级封装 常见事件类型 xff1a 键盘事件 xff1a 按键按下和松开 鼠标事
  • PyQt5 实现串口接数据波形显示工具

    PyQt5 实现串口接数据波形显示工具 工具简述主程序代码Qt Designer设计UI界面程序运行效果 工具简述 基于PyQt5开发UI界面使用QtDesigner设计 xff0c 需要使用到serial模块 xff08 串口库 xff0
  • ROS CMakeLists.txt的编写学习

    调用ROS中的函数 xff0c cmakelists的编写学习过程 如有错误 xff0c 请留言指教 多谢 A 首先要了解的 CMakeLists txt是CMake的构建系统构建软件包的输入文件 任何兼容的CMake都包含了描述如何构建代
  • 【Node】Buffer 与 Stream

    node 为什么会出现 Buffer 这个模块 在最初的时候 xff0c JavaScript 只运行在浏览器端 xff0c 对于处理 Unicode 编码的字符串很容易 xff0c 但是对于处理二进制以及非 Unicode 编码的数据便无
  • ROS的tf包中坐标变换的方法

    1 setRotation函数的参数 在坐标变换的时候常有这样的写法 xff1a tfTutorialsAdding a frame C 43 43 transform setOrigin span class hljs symbol tf
  • 卡尔曼滤波的理解以及参数调整

    一 前言 卡尔曼滤波器是一种最优线性状态估计方法 xff08 等价于 在最小均方误差准则下的最佳线性滤波器 xff09 xff0c 所谓状态估计就是通过数学方法寻求与观测数据最佳拟合的状态向量 在移动机器人导航方面 xff0c 卡尔曼滤波是
  • ROS自定义msg类型及使用

    一 创建msg消息 参考 xff1a CreatingMsgAndSrv 首先创建一个空的package单独存放msg类型 xff08 当然也可以在任意的package中自定义msg类型 xff09 这里为便于说明 xff0c 建立一个名为
  • WebRTC-集成qsv硬解码实现

    1 Window下QSV硬解码配置 在libavcodec codec list c下添加 amp ff h264 qsv decoder 在ffmpeg generate gni下加入 34 libavcodec h264idct c 3
  • [ROS] ROS基础,创建工作空间,创建功能包,ros功能包相关命令,Catkin编译系统,catkin_make的编译方式

    1 工作空间 工作空间 xff08 work space xff09 是ROS系统中存放工程开发相关的文件夹 xff0c 其目录结构如下 xff1a src xff1a 代码空间 xff08 Source Space xff09 xff0c
  • ijkplayer-添加播放截图功能

    应用播放的时候需要截图 xff0c 可以在上层使用TexturView来使用截图 xff0c 不过太具有局限性呢 xff0c 还是在底层处理比较好 那么先分析下可以在哪里加截图呢 xff1f 看到网上很多做的都不能支持硬解截图 xff0c
  • avformat_seek_file及其flag含义

    我们从ijk中seek的处理流程来看ffmpeg的这个问题 int ffp seek to l FFPlayer ffp long msec assert ffp VideoState is 61 ffp gt is int64 t sta
  • 单例模式

    单例模式 xff1a include lt iostream gt using namespace std class Singleton public Singleton cout lt lt 34 Singleton虚构函数 34 lt
  • ffmpeg系列-解决ffmpeg获取aac音频文件duration不准

    这个问题是这样产生的 xff0c 一同事反应会随机出现ijk获取到的aac文件的duration不准 xff0c 发来一看 xff0c 确实不准 xff0c 在AE或者系统mediaplayer中得到的都是8 4秒 xff08 准确时间是M