libVLC 视频裁剪

使用 libVLC 进行视频裁剪并不是直接支持的功能,因为 libVLC 主要是一个媒体播放库。然而,你可以通过调整播放窗口的大小和设置视频输出的区域来实现一种“视觉上的裁剪”。这意味着视频本身并没有被修改,但可以控制显示给用户的视频区域。

如果你的目标是在播放时只显示视频的一部分,你可以通过设置视频输出的裁剪区域来实现。以下是如何使用 libVLC 设置视频裁剪区域的基本步骤:

1. 初始化 libVLC 和媒体播放器

首先,你需要初始化 libVLC 实例和媒体播放器对象。

#include <vlc/vlc.h>int main(int argc, char* argv[])
{libvlc_instance_t* inst;libvlc_media_player_t* mp;libvlc_media_t* m;// 加载 libVLC 引擎inst = libvlc_new(0, NULL);// 创建一个新的 itemm = libvlc_media_new_location(inst, "your_video_path_here");mp = libvlc_media_player_new_from_media(m);// 不再需要媒体对象libvlc_media_release(m);
}

2. 设置视频裁剪区域

你可以通过设置 libvlc_video_set_crop_geometry 来指定裁剪区域。这个函数允许你指定一个裁剪区域,格式为 “NxN”(例如,“16:9”、“4:3” 等)或者像素值(例如 “640x480”)。

// 设置裁剪区域
libvlc_video_set_crop_geometry(mp, "16:9");

3. 播放视频

最后,播放视频。

// 播放媒体播放器
libvlc_media_player_play(mp);// 保持程序运行,直到视频播放完成
while (libvlc_media_player_is_playing(mp)) {// 可以在这里加入延时
}// 清理 libVLC
libvlc_media_player_stop(mp);
libvlc_media_player_release(mp);
libvlc_release(inst);return 0;

以下是VLC播放器中使用的视频裁剪,我们仿照这个做一个界面。 

以下是做出来的效果:

首先做一个菜单:

//设置裁剪菜单m_cropMenu = new QMenu(this);m_cropAction->setMenu(m_cropMenu);m__cropDefault = m_cropMenu->addAction(QIcon(":/image/images/point.png"), "默认");m__crop16_10 = m_cropMenu->addAction("16:10");m__crop16_9 = m_cropMenu->addAction("16:9");m__crop4_3 = m_cropMenu->addAction("4:3");m__crop1_85_1 = m_cropMenu->addAction("1.85:1");m__crop2_21_1 = m_cropMenu->addAction("2.21:1");m__crop2_35_1 = m_cropMenu->addAction("2.35:1");m__crop2_39_1 = m_cropMenu->addAction("2.39:1");m__crop5_3 = m_cropMenu->addAction("5:3");m__crop5_4 = m_cropMenu->addAction("5:4");m__crop1_1 = m_cropMenu->addAction("1:1");m_preCrop = m__cropDefault;m_cropGroup = new QActionGroup(this);m_cropGroup->addAction(m__cropDefault);m_cropGroup->addAction(m__crop16_10);m_cropGroup->addAction(m__crop16_9);m_cropGroup->addAction(m__crop4_3);m_cropGroup->addAction(m__crop1_85_1);m_cropGroup->addAction(m__crop2_21_1);m_cropGroup->addAction(m__crop2_35_1);m_cropGroup->addAction(m__crop2_39_1);m_cropGroup->addAction(m__crop5_3);m_cropGroup->addAction(m__crop5_4);m_cropGroup->addAction(m__crop1_1);connect(m_cropGroup, &QActionGroup::triggered, this, &showWidget::slotCropActionTriggered);

接受槽函数的响应事件:

void showWidget::slotCropActionTriggered(QAction *action)
{if (!vlc_mediaPlayer)return;if (action == m__cropDefault)libvlc_video_set_crop_geometry(vlc_mediaPlayer, m_defalutCrop);else if (action == m__crop16_10)libvlc_video_set_crop_geometry(vlc_mediaPlayer, "16:10");else if (action == m__crop16_9)libvlc_video_set_crop_geometry(vlc_mediaPlayer, "16:9");else if (action == m__crop4_3)libvlc_video_set_crop_geometry(vlc_mediaPlayer, "4:3");else if (action == m__crop1_85_1)libvlc_video_set_crop_geometry(vlc_mediaPlayer, "185:100");else if (action == m__crop2_21_1)libvlc_video_set_crop_geometry(vlc_mediaPlayer, "221:100");else if (action == m__crop2_35_1)libvlc_video_set_crop_geometry(vlc_mediaPlayer, "235:100");else if (action == m__crop2_39_1)libvlc_video_set_crop_geometry(vlc_mediaPlayer, "239:100");else if (action == m__crop5_3)libvlc_video_set_crop_geometry(vlc_mediaPlayer, "5:3");else if (action == m__crop5_4)libvlc_video_set_crop_geometry(vlc_mediaPlayer, "5:4");else if (action == m__crop1_1)libvlc_video_set_crop_geometry(vlc_mediaPlayer, "1:1");action->setIcon(QIcon(":/image/images/point.png"));m_preCrop->setIcon(QIcon());m_preCrop = action;
}

设置鼠标右键弹出菜单:重写鼠标点击事件,弹出菜单。

首先设置libvlc忽略鼠标事件libvlc_video_set_mouse_input(vlc_mediaPlayer, 0);

再重写鼠标事件:

void showWidget::mousePressEvent(QMouseEvent *event)
{switch (event->button()){case Qt::RightButton://this->setWindowState(Qt::WindowMinimized);m_menu->exec(event->globalPos());break;default:QWidget::mousePressEvent(event);}
}

完整代码:

头文件。

#pragma once#include <QtWidgets/QWidget>
#include "ui_showWidget.h"
#include <QMenu>
#include <QActionGroup>
#include <vlc/vlc.h>
#include <QDebug>
#include <QFileDialog>
#include <QThread>
#include <QMouseEvent>enum Rate
{Rate2X,Rate1_5X,Rate1_25X,Rate1_0X,Rate0_75X,Rate0_5X
};class showWidget : public QWidget
{Q_OBJECTpublic:showWidget(QWidget *parent = nullptr);~showWidget();protected:virtual void mousePressEvent(QMouseEvent *event);private slots:void slotOpenFile();void slotPlay();void slotPause();void slotStop();void slotValueChanged(int value);void slotCurrentIndexChanged(int index);void slotActionTriggered(QAction *action);void slotCropActionTriggered(QAction *action);private://事件处理回调static void vlcEvents(const libvlc_event_t *ev, void *param);//初始化menuvoid initMenu();private:Ui::showWidgetClass ui;private:libvlc_instance_t *vlc_base = nullptr;libvlc_media_t *vlc_media = nullptr;libvlc_media_player_t *vlc_mediaPlayer = nullptr;QList<float> m_lstRate;QMenu *m_menu = nullptr;QAction *m_video = nullptr;QAction *m_scaleAction = nullptr;	//缩放QAction *m_aspectRatioAction = nullptr;	//宽高比QAction *m_cropAction = nullptr;	//裁剪QMenu *m_videoMenu = nullptr;//宽高比QMenu *m_aspectRatioMenu = nullptr;QAction *m_default = nullptr;QAction *m_16_9 = nullptr;QAction *m_4_3 = nullptr;QAction *m_1_1 = nullptr;QAction *m_16_10 = nullptr;QAction *m_2_21_1 = nullptr;QAction *m_2_35_1= nullptr;QAction *m_2_38_1 = nullptr;QAction *m_5_4 = nullptr;QActionGroup *m_group = nullptr;QAction *m_preAspectRatio = nullptr;//宽高比//裁剪QMenu *m_cropMenu = nullptr;QAction *m__cropDefault = nullptr;QAction *m__crop16_10 = nullptr;QAction *m__crop16_9 = nullptr;QAction *m__crop4_3 = nullptr;QAction *m__crop1_85_1 = nullptr;QAction *m__crop2_21_1 = nullptr;QAction *m__crop2_35_1 = nullptr;QAction *m__crop2_39_1 = nullptr;QAction *m__crop5_3 = nullptr;QAction *m__crop5_4 = nullptr;QAction *m__crop1_1 = nullptr;QActionGroup *m_cropGroup = nullptr;QAction *m_preCrop= nullptr;//裁剪char *m_defalutRate = nullptr;char *m_defalutCrop = nullptr;
};

cpp文件。 

#include "showWidget.h"
#include <QTimer>
#include <QTime>#pragma execution_character_set("utf-8")showWidget::showWidget(QWidget *parent): QWidget(parent)
{ui.setupUi(this);this->setWindowTitle("视频播放器");ui.cbxRate->setCurrentIndex(Rate1_0X);m_lstRate << 2.0 << 1.5 << 1.25 << 1.0 << 0.75 << 0.5;initMenu();connect(ui.btnOpen, &QPushButton::clicked, this, &showWidget::slotOpenFile);connect(ui.btnPlay, &QPushButton::clicked, this, &showWidget::slotPlay);connect(ui.btnPause, &QPushButton::clicked, this, &showWidget::slotPause);connect(ui.btnStop, &QPushButton::clicked, this, &showWidget::slotStop);connect(ui.hSliderVolumn, &QSlider::valueChanged, this, &showWidget::slotValueChanged);connect(ui.cbxRate,SIGNAL(currentIndexChanged(int)), this, SLOT(slotCurrentIndexChanged(int)));
}showWidget::~showWidget()
{libvlc_release(vlc_base); //减少libvlc实例的引用计数,并销毁
}void showWidget::mousePressEvent(QMouseEvent *event)
{switch (event->button()){case Qt::RightButton://this->setWindowState(Qt::WindowMinimized);m_menu->exec(event->globalPos());break;default:QWidget::mousePressEvent(event);}
}void showWidget::slotOpenFile()
{/*选择文件*/QString filename = QFileDialog::getOpenFileName(this, "选择打开的文件", "D:/", tr("*.*"));std::replace(filename.begin(), filename.end(), QChar('/'), QChar('\\'));vlc_base = libvlc_new(0, NULL);vlc_media = libvlc_media_new_path(vlc_base, filename.toUtf8().data());if (!vlc_media) {return;}// 创建libvlc实例和媒体播放器vlc_mediaPlayer = libvlc_media_player_new_from_media(vlc_media);if (!vlc_mediaPlayer) {return;}// 等待元数据加载完成libvlc_media_parse(vlc_media);m_defalutRate = libvlc_video_get_aspect_ratio(vlc_mediaPlayer);m_defalutCrop = libvlc_video_get_crop_geometry(vlc_mediaPlayer);libvlc_video_set_mouse_input(vlc_mediaPlayer, 0);libvlc_video_set_key_input(vlc_mediaPlayer, 0);// 获取各种元数据const char *title = libvlc_media_get_meta(vlc_media, libvlc_meta_Title);const char *artist = libvlc_media_get_meta(vlc_media, libvlc_meta_Artist);const char *album = libvlc_media_get_meta(vlc_media, libvlc_meta_Album);const char *url = libvlc_media_get_meta(vlc_media, libvlc_meta_URL);const char *date = libvlc_media_get_meta(vlc_media, libvlc_meta_Date);const char *lang = libvlc_media_get_meta(vlc_media, libvlc_meta_Language);int duration = libvlc_media_get_duration(vlc_media);  // 获取时长(单位:毫秒)qDebug("Title: %s", title ? title : "N/A");qDebug("Artist: %s", artist ? artist : "N/A");qDebug("Album: %s", album ? album : "N/A");qDebug("Duration: %d ms", duration);qDebug("url: %s", url ? url : "N/A");qDebug("date: %s", date ? date : "N/A");qDebug("lang: %s", lang ? lang : "N/A");libvlc_media_track_t **tracks;int track_count = libvlc_media_tracks_get(vlc_media,&tracks);for (unsigned i = 0; i < track_count; i++) {libvlc_media_track_t* track = tracks[i];// 显示轨道信息printf("Track #%u: %s\n", i, track->psz_description);// 这里可以获取到每一个轨道的信息,比如轨道类型 track->i_type// 可能是 libvlc_track_video, libvlc_track_audio 或者 libvlc_track_text (字幕)if (track->i_type == libvlc_track_video) {// 处理视频轨道信息qDebug("width = %d",track->video->i_width);qDebug("height = %d", track->video->i_height);qDebug("rate_num = %d", track->video->i_frame_rate_num);qDebug("rate_den = %d", track->video->i_frame_rate_den);}else if (track->i_type == libvlc_track_audio) {// 处理音频轨道信息qDebug("channels = %d", track->audio->i_channels);qDebug("rate = %d", track->audio->i_rate);}else if (track->i_type == libvlc_track_text) {// 处理字幕轨道信息}}设置 logo 叠加//libvlc_video_set_logo_int(vlc_mediaPlayer, libvlc_logo_enable, 1);//libvlc_video_set_logo_string(vlc_mediaPlayer, libvlc_logo_file, "D:\\2.png");libvlc_video_set_logo_int(vlc_mediaPlayer, libvlc_logo_position, libvlc_position_top_left);//libvlc_video_set_logo_int(vlc_mediaPlayer, libvlc_logo_x, 100);//libvlc_video_set_logo_int(vlc_mediaPlayer, libvlc_logo_y, 0);//libvlc_video_set_logo_int(vlc_mediaPlayer, libvlc_logo_opacity, 255);//libvlc_video_set_logo_int(vlc_mediaPlayer, libvlc_logo_repeat, 1);创建并设置水印文本//libvlc_video_set_marquee_int(vlc_mediaPlayer, libvlc_marquee_Enable, 1);//libvlc_video_set_marquee_int(vlc_mediaPlayer, libvlc_marquee_Position, libvlc_position_center);//libvlc_video_set_marquee_int(vlc_mediaPlayer, libvlc_marquee_Refresh, 2000);//libvlc_video_set_marquee_int(vlc_mediaPlayer, libvlc_marquee_Size, 24);//libvlc_video_set_marquee_string(vlc_mediaPlayer, libvlc_marquee_Text, "这里是水印文本");libvlc_video_set_marquee_int(w->vlc_mediaPlayer, libvlc_marquee_Timeout, 5000);//libvlc_video_set_marquee_int(vlc_mediaPlayer, libvlc_marquee_Opacity, 255); // 不透明//获取事件管理器libvlc_event_manager_t *em = libvlc_media_player_event_manager(vlc_mediaPlayer);// 注册事件监听器libvlc_event_attach(em, libvlc_MediaPlayerTimeChanged, vlcEvents, this);libvlc_event_attach(em, libvlc_MediaPlayerEndReached, vlcEvents, this);libvlc_event_attach(em, libvlc_MediaPlayerStopped, vlcEvents, this);libvlc_event_attach(em, libvlc_MediaPlayerPlaying, vlcEvents, this);libvlc_event_attach(em, libvlc_MediaPlayerPaused, vlcEvents, this);libvlc_media_player_set_hwnd(vlc_mediaPlayer, (void *)ui.widgetShow->winId());QTimer::singleShot(1000, this, &showWidget::slotPlay);
}void showWidget::slotPlay()
{if (vlc_mediaPlayer)libvlc_media_player_play(vlc_mediaPlayer);
}void showWidget::slotPause()
{if (vlc_mediaPlayer)libvlc_media_player_pause(vlc_mediaPlayer);
}void showWidget::slotStop()
{if (vlc_mediaPlayer)libvlc_media_player_stop(vlc_mediaPlayer);
}void showWidget::slotValueChanged(int value)
{if (vlc_mediaPlayer)libvlc_audio_set_volume(vlc_mediaPlayer, value);
}void showWidget::slotCurrentIndexChanged(int index)
{if (vlc_mediaPlayer)libvlc_media_player_set_rate(vlc_mediaPlayer, m_lstRate[index]);
}void showWidget::slotActionTriggered(QAction *action)
{if (!vlc_mediaPlayer)return;if (action == m_default)libvlc_video_set_aspect_ratio(vlc_mediaPlayer,m_defalutRate);else if(action == m_16_9)libvlc_video_set_aspect_ratio(vlc_mediaPlayer, "16:9");else if (action == m_4_3)libvlc_video_set_aspect_ratio(vlc_mediaPlayer, "4:3");else if (action == m_1_1)libvlc_video_set_aspect_ratio(vlc_mediaPlayer, "1:1");else if (action == m_16_10)libvlc_video_set_aspect_ratio(vlc_mediaPlayer, "16:10");else if (action == m_2_21_1)libvlc_video_set_aspect_ratio(vlc_mediaPlayer, "221:100");else if (action == m_2_35_1)libvlc_video_set_aspect_ratio(vlc_mediaPlayer, "235:100");else if (action == m_2_38_1)libvlc_video_set_aspect_ratio(vlc_mediaPlayer, "238:100");else if (action == m_5_4)libvlc_video_set_aspect_ratio(vlc_mediaPlayer, "5:4");action->setIcon(QIcon(":/image/images/point.png"));m_preAspectRatio->setIcon(QIcon());m_preAspectRatio = action;
}void showWidget::slotCropActionTriggered(QAction *action)
{if (!vlc_mediaPlayer)return;if (action == m__cropDefault)libvlc_video_set_crop_geometry(vlc_mediaPlayer, m_defalutCrop);else if (action == m__crop16_10)libvlc_video_set_crop_geometry(vlc_mediaPlayer, "16:10");else if (action == m__crop16_9)libvlc_video_set_crop_geometry(vlc_mediaPlayer, "16:9");else if (action == m__crop4_3)libvlc_video_set_crop_geometry(vlc_mediaPlayer, "4:3");else if (action == m__crop1_85_1)libvlc_video_set_crop_geometry(vlc_mediaPlayer, "185:100");else if (action == m__crop2_21_1)libvlc_video_set_crop_geometry(vlc_mediaPlayer, "221:100");else if (action == m__crop2_35_1)libvlc_video_set_crop_geometry(vlc_mediaPlayer, "235:100");else if (action == m__crop2_39_1)libvlc_video_set_crop_geometry(vlc_mediaPlayer, "239:100");else if (action == m__crop5_3)libvlc_video_set_crop_geometry(vlc_mediaPlayer, "5:3");else if (action == m__crop5_4)libvlc_video_set_crop_geometry(vlc_mediaPlayer, "5:4");else if (action == m__crop1_1)libvlc_video_set_crop_geometry(vlc_mediaPlayer, "1:1");action->setIcon(QIcon(":/image/images/point.png"));m_preCrop->setIcon(QIcon());m_preCrop = action;
}//事件回调
void showWidget::vlcEvents(const libvlc_event_t *ev, void *param)
{showWidget *w = (showWidget*)param;//处理不同的事件switch (ev->type) {case libvlc_MediaPlayerTimeChanged:{//qDebug() << "VLC媒体播放器时间已更改";qint64 len = libvlc_media_player_get_time(w->vlc_mediaPlayer);libvlc_time_t lenSec = len / 1000;libvlc_time_t totalLen = libvlc_media_player_get_length(w->vlc_mediaPlayer);libvlc_time_t totalLenSec = totalLen / 1000;int thh, tmm, tss;thh = lenSec / 3600;tmm = (lenSec % 3600) / 60;tss = (lenSec % 60);QTime time(thh, tmm, tss);w->ui.lbCurTime->setText(time.toString("hh:mm:ss"));thh = totalLenSec / 3600;tmm = (totalLenSec % 3600) / 60;tss = (totalLenSec % 60);QTime TotalTime(thh, tmm, tss);w->ui.lbTotalTime->setText(TotalTime.toString("hh:mm:ss"));double pos = (double)lenSec / totalLenSec * 100;w->ui.horizontalSlider->setValue(pos);}break;case libvlc_MediaPlayerEndReached:qDebug() << "VLC播放完毕.";break;case libvlc_MediaPlayerStopped:qDebug() << "VLC停止播放";break;case libvlc_MediaPlayerPlaying:qDebug() << "VLC开始播放";break;case libvlc_MediaPlayerPaused:qDebug() << "VLC暂停播放";break;}
}void showWidget::initMenu()
{//总菜单m_menu = new QMenu(this);m_video = m_menu->addAction("视频");//视频菜单m_videoMenu = new QMenu(this);m_scaleAction = m_videoMenu->addAction("缩放");m_aspectRatioAction = m_videoMenu->addAction("宽高比");m_cropAction = m_videoMenu->addAction("裁剪");m_video->setMenu(m_videoMenu);//宽高比菜单m_aspectRatioMenu = new QMenu(this);m_aspectRatioAction->setMenu(m_aspectRatioMenu);//设置宽高比菜单m_default = m_aspectRatioMenu->addAction(QIcon(":/image/images/point.png"), "默认");m_16_9 = m_aspectRatioMenu->addAction("16:9");m_4_3 = m_aspectRatioMenu->addAction("4:3");m_1_1 = m_aspectRatioMenu->addAction("1:1");m_16_10 = m_aspectRatioMenu->addAction("16:10");m_2_21_1 = m_aspectRatioMenu->addAction("2.21:1");m_2_35_1 = m_aspectRatioMenu->addAction("2.35:1");m_2_38_1 = m_aspectRatioMenu->addAction("2.38:1");m_5_4 = m_aspectRatioMenu->addAction("5:4");m_preAspectRatio = m_default;m_group = new QActionGroup(this);m_group->addAction(m_default);m_group->addAction(m_16_9);m_group->addAction(m_4_3);m_group->addAction(m_1_1);m_group->addAction(m_16_10);m_group->addAction(m_2_21_1);m_group->addAction(m_2_35_1);m_group->addAction(m_2_38_1);m_group->addAction(m_5_4);connect(m_group, &QActionGroup::triggered, this, &showWidget::slotActionTriggered);//设置裁剪菜单m_cropMenu = new QMenu(this);m_cropAction->setMenu(m_cropMenu);m__cropDefault = m_cropMenu->addAction(QIcon(":/image/images/point.png"), "默认");m__crop16_10 = m_cropMenu->addAction("16:10");m__crop16_9 = m_cropMenu->addAction("16:9");m__crop4_3 = m_cropMenu->addAction("4:3");m__crop1_85_1 = m_cropMenu->addAction("1.85:1");m__crop2_21_1 = m_cropMenu->addAction("2.21:1");m__crop2_35_1 = m_cropMenu->addAction("2.35:1");m__crop2_39_1 = m_cropMenu->addAction("2.39:1");m__crop5_3 = m_cropMenu->addAction("5:3");m__crop5_4 = m_cropMenu->addAction("5:4");m__crop1_1 = m_cropMenu->addAction("1:1");m_preCrop = m__cropDefault;m_cropGroup = new QActionGroup(this);m_cropGroup->addAction(m__cropDefault);m_cropGroup->addAction(m__crop16_10);m_cropGroup->addAction(m__crop16_9);m_cropGroup->addAction(m__crop4_3);m_cropGroup->addAction(m__crop1_85_1);m_cropGroup->addAction(m__crop2_21_1);m_cropGroup->addAction(m__crop2_35_1);m_cropGroup->addAction(m__crop2_39_1);m_cropGroup->addAction(m__crop5_3);m_cropGroup->addAction(m__crop5_4);m_cropGroup->addAction(m__crop1_1);connect(m_cropGroup, &QActionGroup::triggered, this, &showWidget::slotCropActionTriggered);
}

更多参考:

libVLC 事件机制-CSDN博客

libVLC windows开发环境搭建-CSDN博客

https://sunnnnnn666.blog.csdn.net/article/details/136854500

libVLC 元数据-CSDN博客

libVLC 添加图片和文本水印-CSDN博客

https://sunnnnnn666.blog.csdn.net/article/details/136920169

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

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

相关文章

视频推拉流EasyDSS点播平台云端录像播放异常的问题排查与解决

视频推拉流EasyDSS视频直播点播平台可提供一站式的视频转码、点播、直播、视频推拉流、播放H.265视频等服务&#xff0c;搭配RTMP高清摄像头使用&#xff0c;可将无人机设备的实时流推送到平台上&#xff0c;实现无人机视频推流直播、巡检等应用。 有用户反馈&#xff0c;项目现…

Mysql数据库:日志管理、备份与恢复

目录 前言 一、MySQL日志管理 1、存放日志和数据文件的目录 2、日志的分类 2.1 错误日志 2.2 通用查询日志 2.3 二进制日志 2.4 慢查询日志 2.5 中继日志 3、日志综合配置 4、查询日志是否开启 二、数据备份概述 1、数据备份的重要性 2、备份类型 2.1 从物理与…

SpringBoot学习之ElasticSearch下载安装和启动(Windows版)(三十)

本文先写windows下的下载安装和启动,后续有时间再补充其他环境下(Mac、Linux、Docker)的,这里我们后续对ElasticSearch简称为ES,读者习惯这一称呼就好。 一,ES下载 可以百度【ElasticSearch官网】或者直接点击这里的ES官网下载地址:​​​​​ Download Elasticsearch…

数字乡村战略实施:科技引领农村经济社会全面发展

随着信息技术的快速发展&#xff0c;数字化已经成为推动经济社会发展的重要力量。在乡村振兴战略的大背景下&#xff0c;数字乡村战略的实施成为了引领农村经济社会全面发展的关键。本文将从数字乡村战略的内涵、实施现状、面临挑战及未来展望等方面&#xff0c;探讨科技如何引…

Mac 装 虚拟机 vmware、centos7等

vmware&#xff1a; https://www.vmware.com/products/fusion.html centos7 清华镜像&#xff1a; 暂时没有官方的 m1 arm架构镜像 centos7 链接: https://pan.baidu.com/s/1oZw1cLyl6Uo3lAD2_FqfEw?pwdzjt4 提取码: zjt4 复制这段内容后打开百度网盘手机App&#xff0c;操…

[flask]cookie的基本使用/

彻底理解 Cookie - 知乎 (zhihu.com) 是什么 cookie是当你浏览某个网站的时候&#xff0c;由web服务器存储在你的机器硬盘上的一个小的文本文件。它其中记录了你的用户名、密码、浏览的网页、停留的时间等等信息。当你再次来到这个网站时&#xff0c;web服务器会先看看有没有…

[音视频学习笔记]八、FFMpeg结构体分析 -上一个项目用到的数据结构简单解析:AVFrame、AVFormatContext、AVCodecContext

前言 上次我们做了一个简单的视频解码&#xff0c;MediaPlay-FFmpeg - Public 这一次简单对这个代码进行一个剖析&#xff0c;对其中的数据结构进行一个解析。 这些数据结构之间的关系 AVFrame 、AVFormatContext 、AVCodecContext 、AVIOContext 、AVCodec 、AVStream 、AV…

flask_restful规范返回值之类型设置

大型的互联网项目中&#xff0c;返回的数据格式&#xff0c;有时是比较复杂的结构。 如&#xff1a;豆瓣电影 https://movie.douban.com/j/chart/top_list?type24&interval_id 100%3A90&action&start20&limit20 返回的值里有 json 或者列表数据&#xff0c…

第十一届蓝桥杯大赛第二场省赛试题 CC++ 研究生组-子串分值和

solution1&#xff08;通过40%&#xff09; 依次求子串并统计出现过的字母个数 #include<iostream> #include<string> #include<set> using namespace std; int main(){string s, subs;cin >> s;int len s.size(), ans 0;for(int j 1; j < len…

vscode下c++的boost库安装

Boost Downloadshttps://www.boost.org/users/download/下载最新的库文件。在shell中&#xff0c;使用命令bootstrap.bat gcc生成b2.exe文件。然后是.\b2.exe toolsetgcc生成库文件&#xff0c;在stage\lib文件夹下把stage\lib文件夹中的库文件拷贝到mingw64\x86_64-w64-mingw3…

Node.js之沙盒专题

​ Node.js一直是薄弱项&#xff0c;今天特意整理一下&#xff0c;基本上是各个大佬写的大杂烩&#xff0c;仅用于学习记录~~~ 1. child_process 首先介绍一下nodejs中用来执行系统命令的模块child_process。Nodejs通过使用child_process模块来生成多个子进程来处理其他事物…

(三)Qt+OpenCV调用海康工业相机SDK抓拍示例

系列文章目录 提示&#xff1a;这里是该系列文章的所有文章的目录 第一章&#xff1a; &#xff08;一&#xff09;QtOpenCV调用海康工业相机SDK示例开发 第二章&#xff1a; &#xff08;二&#xff09;Qt多线程实现海康工业相机图像实时采集 第三章&#xff1a; &#xff08;…

命令模式(请求与具体实现解耦)

目录 前言 UML plantuml 类图 实战代码 模板 Command Invoker Receiver Client 前言 命令模式解耦了命令请求者&#xff08;Invoker&#xff09;和命令执行者&#xff08;receiver&#xff09;&#xff0c;使得 Invoker 不再直接引用 receiver&#xff0c;而是依赖于…

学习vue3第十一节(依赖注入:provide/inject)

本机介绍&#xff1a;provide/inject 注意&#xff1a;大家在看此小节时候&#xff0c;默认大家已经了解一些组件的使用方法 1、依赖注入的用途&#xff1a; 当嵌套层级多的时候&#xff0c;某个子组件需要较远层级的父组件数据时候&#xff0c;如果我们依然使用props 传递数…

数据挖掘与机器学习 1. 绪论

于高山之巅&#xff0c;方见大河奔涌&#xff1b;于群峰之上&#xff0c;便觉长风浩荡 —— 24.3.24 一、数据挖掘和机器学习的定义 1.数据挖掘的狭义定义 背景&#xff1a;大数据时代——知识贫乏 数据挖掘的狭义定义&#xff1a; 数据挖掘就是从大量的、不完全的、有噪声的、…

CI/CD实战-jenkins结合docker 5

实验准备&#xff1a; 在docker主机要下载git工具 禁掉key的校验 确保在立即构建项目时不会出现任何报错&#xff1a; 自动化构建docker镜像 在server3上安装docker-ce 修改内核参数 拷贝证书 添加默认仓库 添加harbor仓库的解析 测试拉取 登录harbor私有仓库 在jenkins安装d…

微服务day06 -- Elasticsearch的数据搜索功能。分别使用DSL和RestClient实现搜索

1.DSL查询文档 elasticsearch的查询依然是基于JSON风格的DSL来实现的。 1.1.DSL查询分类 Elasticsearch提供了基于JSON的DSL&#xff08;Domain Specific Language&#xff09;来定义查询。常见的查询类型包括&#xff1a; 查询所有&#xff1a;查询出所有数据&#xff0c;一…

linux用户管理1

linux系统可以多用户同时登录&#xff0c;在各自权限下做各自的事情 useradd添加普通用户&#xff0c;之后使用suusername切换用户 所有用户中&#xff0c;root用户权限最大&#xff0c;对应uid&#xff0c;gid均为0&#xff0c;uid为用户编号&#xff0c;gid为用户所在组编号…

AcWing 4609:火柴棍数字 ← 贪心算法

【题目来源】 https://www.acwing.com/problem/content/4612/【题目描述】 给定 n 个火柴棍&#xff0c;你可以用它们摆出数字 0∼9。 摆出每个数字所需要的具体火柴棍数量如下图所示&#xff1a; 请你用这些火柴棍摆成若干个数字&#xff0c;并把这些数字排成一排组成一个整数…

【数据结构和算法初阶(C语言)】二叉树的链式结构--前、中、后序遍历实现详解,节点数目计算及oj题目详解---二叉树学习日记③

目录 ​编辑 1.二叉树的链式存储 2.二叉树链式结构的实现 2.1树的创建 2.2二叉树的再理解 3.链式结构二叉树的遍历 3.1前序遍历实现&#xff1a; ​编辑 3.2中序遍历实现 3.3后序遍历 ​编辑 4.链式二叉树节点数目的计算 4.1 总节点个数的计算 错误代码1&#xff1a; 错误代…