ffmpeg ts 关于av_seek_frame

1 ffmpeg命令行

一般对视频文件的裁剪 我们通过一行 ffmpeg命令行即可实现,比如

ffmpeg -ss 0.5 - t 3 - i a.mp4 vcodec copy b.mp4

 其中 -ss 放置较前  开启精准seek定位 对于mp4而言 seek将从moov中相关索引表查找 0.5s时刻附近最近的关键帧 (此描述可能不精确)

ffmpeg根据此命令是如何裁剪呢?

1.1 命令行入口

执行代码位置

fftools/ffmpeg.c 

int main(int argc, char **argv)
{int i, ret;BenchmarkTimeStamps ti;init_dynload();register_exit(ffmpeg_cleanup);setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */av_log_set_flags(AV_LOG_SKIP_REPEATED);parse_loglevel(argc, argv, options);if(argc>1 && !strcmp(argv[1], "-d")){run_as_daemon=1;av_log_set_callback(log_callback_null);argc--;argv++;}#if CONFIG_AVDEVICEavdevice_register_all();
#endifavformat_network_init();show_banner(argc, argv, options);/* parse options and open all input/output files */ret = ffmpeg_parse_options(argc, argv);if (ret < 0)exit_program(1);if (nb_output_files <= 0 && nb_input_files == 0) {show_usage();av_log(NULL, AV_LOG_WARNING, "Use -h to get full help or, even better, run 'man %s'\n", program_name);exit_program(1);}/* file converter / grab */if (nb_output_files <= 0) {av_log(NULL, AV_LOG_FATAL, "At least one output file must be specified\n");exit_program(1);}for (i = 0; i < nb_output_files; i++) {if (strcmp(output_files[i]->ctx->oformat->name, "rtp"))want_sdp = 0;}current_time = ti = get_benchmark_time_stamps();if (transcode() < 0)exit_program(1);if (do_benchmark) {int64_t utime, stime, rtime;current_time = get_benchmark_time_stamps();utime = current_time.user_usec - ti.user_usec;stime = current_time.sys_usec  - ti.sys_usec;rtime = current_time.real_usec - ti.real_usec;av_log(NULL, AV_LOG_INFO,"bench: utime=%0.3fs stime=%0.3fs rtime=%0.3fs\n",utime / 1000000.0, stime / 1000000.0, rtime / 1000000.0);}av_log(NULL, AV_LOG_DEBUG, "%"PRIu64" frames successfully decoded, %"PRIu64" decoding errors\n",decode_error_stat[0], decode_error_stat[1]);if ((decode_error_stat[0] + decode_error_stat[1]) * max_error_rate < decode_error_stat[1])exit_program(69);exit_program(received_nb_signals ? 255 : main_return_code);return main_return_code;
}

1.2 执行流程

代码流程比较清晰 主要流程如下:

1.3 输入上下文设置 

ffmpeg将解析的参数存放到OptionParseContext中包含输入及输出参数设置,然后进入输入上下文

根据之前解析的数据OptionPareseContext作为参数传入,确定好seek点,然后调用 avformat_seek_file 

static int open_input_file(OptionsContext *o, const char *filename)
{InputFile *f;AVFormatContext *ic;AVInputFormat *file_iformat = NULL;int err, i, ret;int64_t timestamp;AVDictionary *unused_opts = NULL;AVDictionaryEntry *e = NULL;char *   video_codec_name = NULL;char *   audio_codec_name = NULL;char *subtitle_codec_name = NULL;char *    data_codec_name = NULL;int scan_all_pmts_set = 0;if (o->stop_time != INT64_MAX && o->recording_time != INT64_MAX) {o->stop_time = INT64_MAX;av_log(NULL, AV_LOG_WARNING, "-t and -to cannot be used together; using -t.\n");}if (o->stop_time != INT64_MAX && o->recording_time == INT64_MAX) {int64_t start_time = o->start_time == AV_NOPTS_VALUE ? 0 : o->start_time;if (o->stop_time <= start_time) {av_log(NULL, AV_LOG_ERROR, "-to value smaller than -ss; aborting.\n");exit_program(1);} else {o->recording_time = o->stop_time - start_time;}}if (o->format) {if (!(file_iformat = av_find_input_format(o->format))) {av_log(NULL, AV_LOG_FATAL, "Unknown input format: '%s'\n", o->format);exit_program(1);}}if (!strcmp(filename, "-"))filename = "pipe:";stdin_interaction &= strncmp(filename, "pipe:", 5) &&strcmp(filename, "/dev/stdin");/* get default parameters from command line */ic = avformat_alloc_context();if (!ic) {print_error(filename, AVERROR(ENOMEM));exit_program(1);}if (o->nb_audio_sample_rate) {av_dict_set_int(&o->g->format_opts, "sample_rate", o->audio_sample_rate[o->nb_audio_sample_rate - 1].u.i, 0);}if (o->nb_audio_channels) {/* because we set audio_channels based on both the "ac" and* "channel_layout" options, we need to check that the specified* demuxer actually has the "channels" option before setting it */if (file_iformat && file_iformat->priv_class &&av_opt_find(&file_iformat->priv_class, "channels", NULL, 0,AV_OPT_SEARCH_FAKE_OBJ)) {av_dict_set_int(&o->g->format_opts, "channels", o->audio_channels[o->nb_audio_channels - 1].u.i, 0);}}if (o->nb_frame_rates) {/* set the format-level framerate option;* this is important for video grabbers, e.g. x11 */if (file_iformat && file_iformat->priv_class &&av_opt_find(&file_iformat->priv_class, "framerate", NULL, 0,AV_OPT_SEARCH_FAKE_OBJ)) {av_dict_set(&o->g->format_opts, "framerate",o->frame_rates[o->nb_frame_rates - 1].u.str, 0);}}if (o->nb_frame_sizes) {av_dict_set(&o->g->format_opts, "video_size", o->frame_sizes[o->nb_frame_sizes - 1].u.str, 0);}if (o->nb_frame_pix_fmts)av_dict_set(&o->g->format_opts, "pixel_format", o->frame_pix_fmts[o->nb_frame_pix_fmts - 1].u.str, 0);MATCH_PER_TYPE_OPT(codec_names, str,    video_codec_name, ic, "v");MATCH_PER_TYPE_OPT(codec_names, str,    audio_codec_name, ic, "a");MATCH_PER_TYPE_OPT(codec_names, str, subtitle_codec_name, ic, "s");MATCH_PER_TYPE_OPT(codec_names, str,     data_codec_name, ic, "d");if (video_codec_name)ic->video_codec    = find_codec_or_die(video_codec_name   , AVMEDIA_TYPE_VIDEO   , 0);if (audio_codec_name)ic->audio_codec    = find_codec_or_die(audio_codec_name   , AVMEDIA_TYPE_AUDIO   , 0);if (subtitle_codec_name)ic->subtitle_codec = find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0);if (data_codec_name)ic->data_codec     = find_codec_or_die(data_codec_name    , AVMEDIA_TYPE_DATA    , 0);ic->video_codec_id     = video_codec_name    ? ic->video_codec->id    : AV_CODEC_ID_NONE;ic->audio_codec_id     = audio_codec_name    ? ic->audio_codec->id    : AV_CODEC_ID_NONE;ic->subtitle_codec_id  = subtitle_codec_name ? ic->subtitle_codec->id : AV_CODEC_ID_NONE;ic->data_codec_id      = data_codec_name     ? ic->data_codec->id     : AV_CODEC_ID_NONE;ic->flags |= AVFMT_FLAG_NONBLOCK;if (o->bitexact)ic->flags |= AVFMT_FLAG_BITEXACT;ic->interrupt_callback = int_cb;if (!av_dict_get(o->g->format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE)) {av_dict_set(&o->g->format_opts, "scan_all_pmts", "1", AV_DICT_DONT_OVERWRITE);scan_all_pmts_set = 1;}/* open the input file with generic avformat function */err = avformat_open_input(&ic, filename, file_iformat, &o->g->format_opts);if (err < 0) {print_error(filename, err);if (err == AVERROR_PROTOCOL_NOT_FOUND)av_log(NULL, AV_LOG_ERROR, "Did you mean file:%s?\n", filename);exit_program(1);}if (scan_all_pmts_set)av_dict_set(&o->g->format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);remove_avoptions(&o->g->format_opts, o->g->codec_opts);assert_avoptions(o->g->format_opts);/* apply forced codec ids */for (i = 0; i < ic->nb_streams; i++)choose_decoder(o, ic, ic->streams[i]);if (find_stream_info) {AVDictionary **opts = setup_find_stream_info_opts(ic, o->g->codec_opts);int orig_nb_streams = ic->nb_streams;/* If not enough info to get the stream parameters, we decode thefirst frames to get it. (used in mpeg case for example) */ret = avformat_find_stream_info(ic, opts);for (i = 0; i < orig_nb_streams; i++)av_dict_free(&opts[i]);av_freep(&opts);if (ret < 0) {av_log(NULL, AV_LOG_FATAL, "%s: could not find codec parameters\n", filename);if (ic->nb_streams == 0) {avformat_close_input(&ic);exit_program(1);}}}if (o->start_time != AV_NOPTS_VALUE && o->start_time_eof != AV_NOPTS_VALUE) {av_log(NULL, AV_LOG_WARNING, "Cannot use -ss and -sseof both, using -ss for %s\n", filename);o->start_time_eof = AV_NOPTS_VALUE;}if (o->start_time_eof != AV_NOPTS_VALUE) {if (o->start_time_eof >= 0) {av_log(NULL, AV_LOG_ERROR, "-sseof value must be negative; aborting\n");exit_program(1);}if (ic->duration > 0) {o->start_time = o->start_time_eof + ic->duration;if (o->start_time < 0) {av_log(NULL, AV_LOG_WARNING, "-sseof value seeks to before start of file %s; ignored\n", filename);o->start_time = AV_NOPTS_VALUE;}} elseav_log(NULL, AV_LOG_WARNING, "Cannot use -sseof, duration of %s not known\n", filename);}timestamp = (o->start_time == AV_NOPTS_VALUE) ? 0 : o->start_time;/* add the stream start time */if (!o->seek_timestamp && ic->start_time != AV_NOPTS_VALUE)timestamp += ic->start_time;/* if seeking requested, we execute it */if (o->start_time != AV_NOPTS_VALUE) {int64_t seek_timestamp = timestamp;if (!(ic->iformat->flags & AVFMT_SEEK_TO_PTS)) {int dts_heuristic = 0;for (i=0; i<ic->nb_streams; i++) {const AVCodecParameters *par = ic->streams[i]->codecpar;if (par->video_delay) {dts_heuristic = 1;break;}}if (dts_heuristic) {seek_timestamp -= 3*AV_TIME_BASE / 23;}}ret = avformat_seek_file(ic, -1, INT64_MIN, seek_timestamp, seek_timestamp, 0);if (ret < 0) {av_log(NULL, AV_LOG_WARNING, "%s: could not seek to position %0.3f\n",filename, (double)timestamp / AV_TIME_BASE);}}/* update the current parameters so that they match the one of the input stream */add_input_streams(o, ic);/* dump the file content */av_dump_format(ic, nb_input_files, filename, 0);GROW_ARRAY(input_files, nb_input_files);f = av_mallocz(sizeof(*f));if (!f)exit_program(1);input_files[nb_input_files - 1] = f;f->ctx        = ic;f->ist_index  = nb_input_streams - ic->nb_streams;f->start_time = o->start_time;f->recording_time = o->recording_time;f->input_ts_offset = o->input_ts_offset;f->ts_offset  = o->input_ts_offset - (copy_ts ? (start_at_zero && ic->start_time != AV_NOPTS_VALUE ? ic->start_time : 0) : timestamp);f->nb_streams = ic->nb_streams;f->rate_emu   = o->rate_emu;f->accurate_seek = o->accurate_seek;f->loop = o->loop;f->duration = 0;f->time_base = (AVRational){ 1, 1 };
#if HAVE_THREADSf->thread_queue_size = o->thread_queue_size > 0 ? o->thread_queue_size : 8;
#endif/* check if all codec options have been used */unused_opts = strip_specifiers(o->g->codec_opts);for (i = f->ist_index; i < nb_input_streams; i++) {e = NULL;while ((e = av_dict_get(input_streams[i]->decoder_opts, "", e,AV_DICT_IGNORE_SUFFIX)))av_dict_set(&unused_opts, e->key, NULL, 0);}e = NULL;while ((e = av_dict_get(unused_opts, "", e, AV_DICT_IGNORE_SUFFIX))) {const AVClass *class = avcodec_get_class();const AVOption *option = av_opt_find(&class, e->key, NULL, 0,AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);const AVClass *fclass = avformat_get_class();const AVOption *foption = av_opt_find(&fclass, e->key, NULL, 0,AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);if (!option || foption)continue;if (!(option->flags & AV_OPT_FLAG_DECODING_PARAM)) {av_log(NULL, AV_LOG_ERROR, "Codec AVOption %s (%s) specified for ""input file #%d (%s) is not a decoding option.\n", e->key,option->help ? option->help : "", nb_input_files - 1,filename);exit_program(1);}av_log(NULL, AV_LOG_WARNING, "Codec AVOption %s (%s) specified for ""input file #%d (%s) has not been used for any stream. The most ""likely reason is either wrong type (e.g. a video option with ""no video streams) or that it is a private option of some decoder ""which was not actually used for any stream.\n", e->key,option->help ? option->help : "", nb_input_files - 1, filename);}av_dict_free(&unused_opts);for (i = 0; i < o->nb_dump_attachment; i++) {int j;for (j = 0; j < ic->nb_streams; j++) {AVStream *st = ic->streams[j];if (check_stream_specifier(ic, st, o->dump_attachment[i].specifier) == 1)dump_attachment(st, o->dump_attachment[i].u.str);}}input_stream_potentially_available = 1;return 0;
}

1.4 avformat_seek_file

int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts,int64_t ts, int64_t max_ts, int flags)
{if (min_ts > ts || max_ts < ts)return -1;if (stream_index < -1 || stream_index >= (int)s->nb_streams)return AVERROR(EINVAL);if (s->seek2any>0)flags |= AVSEEK_FLAG_ANY;flags &= ~AVSEEK_FLAG_BACKWARD;if (s->iformat->read_seek2) {int ret;ff_read_frame_flush(s);if (stream_index == -1 && s->nb_streams == 1) {AVRational time_base = s->streams[0]->time_base;ts = av_rescale_q(ts, AV_TIME_BASE_Q, time_base);min_ts = av_rescale_rnd(min_ts, time_base.den,time_base.num * (int64_t)AV_TIME_BASE,AV_ROUND_UP   | AV_ROUND_PASS_MINMAX);max_ts = av_rescale_rnd(max_ts, time_base.den,time_base.num * (int64_t)AV_TIME_BASE,AV_ROUND_DOWN | AV_ROUND_PASS_MINMAX);stream_index = 0;}ret = s->iformat->read_seek2(s, stream_index, min_ts,ts, max_ts, flags);if (ret >= 0)ret = avformat_queue_attached_pictures(s);return ret;}if (s->iformat->read_timestamp) {// try to seek via read_timestamp()}// Fall back on old API if new is not implemented but old is.// Note the old API has somewhat different semantics.if (s->iformat->read_seek || 1) {int dir = (ts - (uint64_t)min_ts > (uint64_t)max_ts - ts ? AVSEEK_FLAG_BACKWARD : 0);int ret = av_seek_frame(s, stream_index, ts, flags | dir);if (ret<0 && ts != min_ts && max_ts != ts) {ret = av_seek_frame(s, stream_index, dir ? max_ts : min_ts, flags | dir);if (ret >= 0)ret = av_seek_frame(s, stream_index, ts, flags | (dir^AVSEEK_FLAG_BACKWARD));}return ret;}// try some generic seek like seek_frame_generic() but with new ts semanticsreturn -1; //unreachable
}

ffmpeg中大部分fromat都定义实现了read_seek ,一般情况下都会调用av_seek_frame,因为输入文件是mp4格式 .format对应 mov ,

av_ssek_frame->seek_frame_internal-> read_seek ->mov_read_seek

AVInputFormat ff_mov_demuxer = {.name           = "mov,mp4,m4a,3gp,3g2,mj2",.long_name      = NULL_IF_CONFIG_SMALL("QuickTime / MOV"),.priv_class     = &mov_class,.priv_data_size = sizeof(MOVContext),.extensions     = "mov,mp4,m4a,3gp,3g2,mj2",.read_probe     = mov_probe,.read_header    = mov_read_header,.read_packet    = mov_read_packet,.read_close     = mov_read_close,.read_seek      = mov_read_seek,.flags          = AVFMT_NO_BYTE_SEEK | AVFMT_SEEK_TO_PTS,
};

真正确定seek位置代码函数 ff_index_search_timestamp flags不同 查询规则有所不同

int ff_index_search_timestamp(const AVIndexEntry *entries, int nb_entries,int64_t wanted_timestamp, int flags)
{int a, b, m;int64_t timestamp;a = -1;b = nb_entries;// Optimize appending index entries at the end.if (b && entries[b - 1].timestamp < wanted_timestamp)a = b - 1;while (b - a > 1) {m         = (a + b) >> 1;// Search for the next non-discarded packet.while ((entries[m].flags & AVINDEX_DISCARD_FRAME) && m < b && m < nb_entries - 1) {m++;if (m == b && entries[m].timestamp >= wanted_timestamp) {m = b - 1;break;}}timestamp = entries[m].timestamp;if (timestamp >= wanted_timestamp)b = m;if (timestamp <= wanted_timestamp)a = m;}m = (flags & AVSEEK_FLAG_BACKWARD) ? a : b;if (!(flags & AVSEEK_FLAG_ANY))while (m >= 0 && m < nb_entries &&!(entries[m].flags & AVINDEX_KEYFRAME))m += (flags & AVSEEK_FLAG_BACKWARD) ? -1 : 1;if (m == nb_entries)return -1;return m;
}

flags:

#define AVSEEK_FLAG_BACKGROUND 1              ///<<Seek Background 往后移,

#define AVSEEK_FALG_BYTE         ///<<<seeking based on position in bytes 让时间戳
变成一个 byte, 按照文件的大小位置跳到那个位置

#define AVSEEK_FLAG_ANY         ///<<<seek to any frame, even non-keyframes // 移动到任意帧的位置,不去找前面的关键帧,

#define AVSEEK_FLAG_FRAME        ///<<<seeking based on frame number // 找关键帧,一般与 AVSEEK_FLAG_BACKGROUND 一起使用

2  TS 

对于ts切割格式采用同样的方式分析  mpegts.c , 并未定义 read_seek

AVInputFormat ff_mpegts_demuxer = {.name           = "mpegts",.long_name      = NULL_IF_CONFIG_SMALL("MPEG-TS (MPEG-2 Transport Stream)"),.priv_data_size = sizeof(MpegTSContext),.read_probe     = mpegts_probe,.read_header    = mpegts_read_header,.read_packet    = mpegts_read_packet,.read_close     = mpegts_read_close,.read_timestamp = mpegts_get_dts,.flags          = AVFMT_SHOW_IDS | AVFMT_TS_DISCONT,.priv_class     = &mpegts_class,
};

从而进入 ff_seek_frame_binary 方法,由于是实时流没有index_entry 调用ff_gen_search 生成seek pos  gen_seek

int ff_seek_frame_binary(AVFormatContext *s, int stream_index,int64_t target_ts, int flags)
{const AVInputFormat *avif = s->iformat;int64_t av_uninit(pos_min), av_uninit(pos_max), pos, pos_limit;int64_t ts_min, ts_max, ts;int index;int64_t ret;AVStream *st;if (stream_index < 0)return -1;av_log(s, AV_LOG_TRACE, "read_seek: %d %s\n", stream_index, av_ts2str(target_ts));ts_max =ts_min = AV_NOPTS_VALUE;pos_limit = -1; // GCC falsely says it may be uninitialized.st = s->streams[stream_index];if (st->index_entries) {AVIndexEntry *e;/* FIXME: Whole function must be checked for non-keyframe entries in* index case, especially read_timestamp(). */index = av_index_search_timestamp(st, target_ts,flags | AVSEEK_FLAG_BACKWARD);index = FFMAX(index, 0);e     = &st->index_entries[index];if (e->timestamp <= target_ts || e->pos == e->min_distance) {pos_min = e->pos;ts_min  = e->timestamp;av_log(s, AV_LOG_TRACE, "using cached pos_min=0x%"PRIx64" dts_min=%s\n",pos_min, av_ts2str(ts_min));} else {av_assert1(index == 0);}index = av_index_search_timestamp(st, target_ts,flags & ~AVSEEK_FLAG_BACKWARD);av_assert0(index < st->nb_index_entries);if (index >= 0) {e = &st->index_entries[index];av_assert1(e->timestamp >= target_ts);pos_max   = e->pos;ts_max    = e->timestamp;pos_limit = pos_max - e->min_distance;av_log(s, AV_LOG_TRACE, "using cached pos_max=0x%"PRIx64" pos_limit=0x%"PRIx64" dts_max=%s\n", pos_max, pos_limit, av_ts2str(ts_max));}}pos = ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit,ts_min, ts_max, flags, &ts, avif->read_timestamp);if (pos < 0)return -1;/* do the seek */if ((ret = avio_seek(s->pb, pos, SEEK_SET)) < 0)return ret;ff_read_frame_flush(s);ff_update_cur_dts(s, st, ts);return 0;
}

注意avid->read_timestamap  mpegts 将通过mpegts_get_dts 通过时间戳查询pos

AVInputFormat ff_mpegts_demuxer = {.name           = "mpegts",.long_name      = NULL_IF_CONFIG_SMALL("MPEG-TS (MPEG-2 Transport Stream)"),.priv_data_size = sizeof(MpegTSContext),.read_probe     = mpegts_probe,.read_header    = mpegts_read_header,.read_packet    = mpegts_read_packet,.read_close     = mpegts_read_close,.read_timestamp = mpegts_get_dts,.flags          = AVFMT_SHOW_IDS | AVFMT_TS_DISCONT,.priv_class     = &mpegts_class,
};
static int64_t mpegts_get_dts(AVFormatContext *s, int stream_index,int64_t *ppos, int64_t pos_limit)
{MpegTSContext *ts = s->priv_data;int64_t pos;int pos47 = ts->pos47_full % ts->raw_packet_size;pos = ((*ppos  + ts->raw_packet_size - 1 - pos47) / ts->raw_packet_size) * ts->raw_packet_size + pos47;ff_read_frame_flush(s);if (avio_seek(s->pb, pos, SEEK_SET) < 0)return AV_NOPTS_VALUE;while(pos < pos_limit) {int ret;AVPacket pkt;av_init_packet(&pkt);ret = av_read_frame(s, &pkt);if (ret < 0)return AV_NOPTS_VALUE;if (pkt.dts != AV_NOPTS_VALUE && pkt.pos >= 0) {ff_reduce_index(s, pkt.stream_index);av_add_index_entry(s->streams[pkt.stream_index], pkt.pos, pkt.dts, 0, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */);if (pkt.stream_index == stream_index && pkt.pos >= *ppos) {int64_t dts = pkt.dts;*ppos = pkt.pos;av_packet_unref(&pkt);return dts;}}pos = pkt.pos;av_packet_unref(&pkt);}return AV_NOPTS_VALUE;
}

未完待续

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/97538.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【go语言】方法

go的方法是一种作用在接收者&#xff08;某种类型的变量&#xff0c;不能是接口和指针&#xff09;上的特殊函数 方法的声明 // 类型方法接收者是值类型 func (t TypeName) MethodName (ParamList ) (Returnlist) {//method body }// 类型方法接收者是指针 func (t *TypeName…

【Vue面试题十】、Vue中组件和插件有什么区别?

文章底部有个人公众号&#xff1a;热爱技术的小郑。主要分享开发知识、学习资料、毕业设计指导等。有兴趣的可以关注一下。为何分享&#xff1f; 踩过的坑没必要让别人在再踩&#xff0c;自己复盘也能加深记忆。利己利人、所谓双赢。 面试官&#xff1a;Vue中组件和插件有什么区…

大数据-玩转数据-Flink 海量数据实时去重

一、海量数据实时去重说明 借助redis的Set&#xff0c;需要频繁连接Redis&#xff0c;如果数据量过大, 对redis的内存也是一种压力&#xff1b;使用Flink的MapState&#xff0c;如果数据量过大, 状态后端最好选择 RocksDBStateBackend&#xff1b; 使用布隆过滤器&#xff0c;…

mysql八股

1、请你说说mysql索引&#xff0c;以及它们的好处和坏处 检索效率、存储资源、索引 索引就像指向表行的指针&#xff0c;是一个允许查询操作快速确定哪些行符合WHERE子句中的条件&#xff0c;并检索到这些行的其他列值的数据结构索引主要有普通索引、唯一索引、主键索引、外键…

攻防世界-T1 Training-WWW-Robots

文章目录 步骤1步骤二结束语 步骤1 看到文本——>提取有效信息——>利用有效信息 文本&#xff1a;In this little training challenge, you are going to learn about the Robots_exclusion_standard. The robots.txt file is used by web crawlers to check if they …

策略模式与模板方法结合案例

一、背景 上周在迁移项目MQ工程的时候&#xff0c;重新Review代码&#xff0c;发现有一段代码综合使用了策略模式和模板方法&#xff0c;下面讲解一下具体场景应用的思路。 二、模板方法 策略模式前段时间有一个关于库存具体案例&#xff0c;详见 库存管理与策略模式。 模板…

修改npm全局安装的插件(下载目录指向)

我们先打开终端 然后执行 npm config get prefix查看npm 的下载地址 一般都会在C盘 但是 我们都知道 C盘下东西多了是很不好的 所以 我们可以执行 npm config set prefix “E:\npmfile”将 npm 的下载地址 改变成 E盘下的 npmfile目录 这样 以后 默认全局安装的插件就会都到…

中国34省区市三维地形图(直接保存)

吉林 ▼ 辽宁 ▼ 北京 ▼ 河北 ▼ 山东 ▼ 山西 ▼ 天津 ▼ 江苏 ▼ 福建 ▼ 上海 ▼ 台湾 ▼ 浙江 ▼ 广东 ▼ 广西 ▼ 海南 ▼ 香港和澳门 ▼ 安徽 ▼ 河南 ▼ 湖北 ▼ 湖南 ▼ 江西 ▼ 甘肃 ▼ 内蒙古 ▼ 宁夏 ▼ 青海 ▼ 陕西 ▼ 新疆 ▼ 贵州 …

016 Spring Boot + Vue 图书管理系统

Spring Boot Vue 图书馆管理系统&#xff08;library-system&#xff09; 本地快捷预览项目 第一步&#xff1a;运行 db 文件夹下的springboot-vue.sql(询问作者获取)&#xff0c;创建springboot-vue数据库 第二步&#xff1a;修改后端数据库配置文件&#xff0c;启动后端 …

计算机网络-计算机网络体系结构-概述,模型

目录 一、计算机网络概述 二、性能指标 速率 带宽 吞吐量 时延 往返时延RTT 利用率 三、计算机网络体系结构 分层结构 IOS模型 应用层-> 表示层-> 会话层-> 传输层-> 网络层-> 数据链路层-> 物理层-> TCP/IP模型 一、计算机网络概述 计…

浅谈OV SSL 证书的优势

随着网络威胁日益增多&#xff0c;保护网站和用户安全已成为每个企业和组织的重要任务。在众多SSL证书类型中&#xff0c;OV&#xff08;Organization Validation&#xff09;证书以其独特的优势备受关注。让我们深入探究OV证书的优势所在&#xff0c;为网站安全搭建坚实的防线…

10-Node.js模块化

01.模块化简介 目标 了解模块化概念和好处&#xff0c;以及 CommonJS 标准语法导出和导入 讲解 在 Node.js 中每个文件都被当做是一个独立的模块&#xff0c;模块内定义的变量和函数都是独立作用域的&#xff0c;因为 Node.js 在执行模块代码时&#xff0c;将使用如下所示的…

Vue中如何进行图像处理与图像滤镜

在Vue中进行图像处理与图像滤镜 图像处理和滤镜效果是现代Web应用程序中常见的功能之一。Vue.js作为一个流行的JavaScript框架&#xff0c;为实现这些功能提供了许多工具和库。本文将介绍如何使用Vue来进行图像处理与图像滤镜&#xff0c;包括使用HTML5 Canvas和CSS滤镜。 准备…

抖音账号矩阵系统开发源码----技术研发

一、技术自研框架开发背景&#xff1a; 抖音账号矩阵系统是一种基于数据分析和管理的全新平台&#xff0c;能够帮助用户更好地管理、扩展和营销抖音账号。 抖音账号矩阵系统开发源码 部分源码分享&#xff1a; ic function indexAction() { //面包屑 $breadc…

WEB 3D 技术,通过node环境创建一个three案例

好 文章 前端3D Three.js 在本地搭建一个官方网站 中我们 搭建了一个Three的官网 现在呢 我们就来创建第一个ThreeJs的资源 这里呢 我们还是选择一个脚手架的开发模式 因为现在基本所有的前端都在使用这样的开发方式 这里 我们创建一个文件夹目录 作为我们项目的存放目录 我们…

boost在不同平台下的编译(win、arm)

首先下载boost源码 下载完成之后解压 前提需要自行安装gcc等工具 window ./bootstrap.sh ./b2 ./b2 installarm &#xff08;linux&#xff09; sudo ./bootstrap.sh sudo ./b2 cxxflags-fPIC cflags-fPIC linkstatic -a threadingmulti sudo ./b2 installx86 (linux) su…

第8期ThreadX视频教程:应用实战,将裸机工程移植到RTOS的任务划分,驱动和应用层交互,中断DMA,C库和中间件处理等注意事项

视频教程汇总帖&#xff1a;【学以致用&#xff0c;授人以渔】2023视频教程汇总&#xff0c;DSP第12期&#xff0c;ThreadX第8期&#xff0c;BSP驱动第26期&#xff0c;USB实战第5期&#xff0c;GUI实战第3期&#xff08;2023-10-01&#xff09; - STM32F429 - 硬汉嵌入式论坛 …

HD-G2UL-GW高性能4G工业网关|介绍|参数

HD-G2UL-GW多功能型网关基于高性能低功耗 ARM 处理器设计&#xff0c;集成 4G、2路网口、4 路 RS-485、2路 RS-232&#xff08;与485有复用&#xff09;、WIFI等功能&#xff0c;在电力、环保、节能、消防、农业等领域有广泛应用。 HD-G2UL-GW板载的外设功能&#xff1a; 集成2…

10-Node.js入门

01.什么是 Node.js 目标 什么是 Node.js&#xff0c;有什么用&#xff0c;为何能独立执行 JS 代码&#xff0c;演示安装和执行 JS 文件内代码 讲解 Node.js 是一个独立的 JavaScript 运行环境&#xff0c;能独立执行 JS 代码&#xff0c;因为这个特点&#xff0c;它可以用来…

虚拟环境搭建、后台项目创建及目录调整、封装logger、封装全局异常、封装Response、后台数据库创建

1 虚拟环境搭建 #1 虚拟环境作用多个项目&#xff0c;自己有自己的环境&#xff0c;装的模块属于自己的# 2 使用pycharm创建-一般放在项目路径下&#xff1a;venv文件夹-lib文件夹---》site-package--》虚拟环境装的模块&#xff0c;都会放在这里-scripts--》python&#xff0…