libVLC 视频缩放

libvlc是一个常用的开源多媒体框架,它可以用来播放和处理各种类型的音频和视频文件。如果想要缩放视频,可以通过libvlc提供的API来实现。

//设置视频的缩放比例。
libvlc_video_set_scale()

以下是如何使用 libVLC 设置视频缩放的基本步骤:

#include <vlc/vlc.h>

int main(int argc, char* argv[]) {
    libvlc_instance_t *vlcInstance;
    libvlc_media_player_t *mediaPlayer;
    libvlc_media_t *media;

    // 初始化 libVLC
    vlcInstance = libvlc_new(0, NULL);

    // 创建一个媒体对象
    media = libvlc_media_new_path(vlcInstance, "path_to_your_video_file.mp4");

    // 创建一个媒体播放器
    mediaPlayer = libvlc_media_player_new_from_media(media);

    // 设置视频缩放选项
    libvlc_video_set_scale(mediaPlayer, 0.5); // 缩放比例为 0.5,即将视频缩小一半

    // 设置视频输出窗口
    libvlc_media_player_set_hwnd(mediaPlayer, (void*)your_window_handle);

    // 播放视频
    libvlc_media_player_play(mediaPlayer);

    // 等待用户输入
    getchar();

    // 释放资源
    libvlc_media_player_release(mediaPlayer);
    libvlc_media_release(media);
    libvlc_release(vlcInstance);

    return 0;
}

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

以下是做出来的效果图。

首先做缩放菜单: 

	//.h
    //缩放
	QMenu *m_scaleMenu = nullptr;
	QAction *m_scale1_4 = nullptr;
	QAction *m_scale1_2 = nullptr;
	QAction *m_scale1_1 = nullptr;
	QAction *m_scale2_1 = nullptr;

	QActionGroup *m_scaleGroup = nullptr;
	QAction *m_preScale = nullptr;

    //.cpp
    //设置缩放菜单
	m_scaleMenu = new QMenu(this);
	m_scaleAction->setMenu(m_scaleMenu);

	m_scale1_4 = m_scaleMenu->addAction("1:4 四分之一");
	m_scale1_2 = m_scaleMenu->addAction("1:2 二分之一");
	m_scale1_1 = m_scaleMenu->addAction(QIcon(":/image/images/point.png"),"1:1 原始");
	m_scale2_1 = m_scaleMenu->addAction("2:1 双倍");

	m_scaleGroup = new QActionGroup(this);
	m_scaleGroup->addAction(m_scale1_4);
	m_scaleGroup->addAction(m_scale1_2);
	m_scaleGroup->addAction(m_scale1_1);
	m_scaleGroup->addAction(m_scale2_1);

	m_preScale = m_scale1_1;

	connect(m_scaleGroup, &QActionGroup::triggered, this, &showWidget::slotScaleActionTriggered);

接受槽函数的响应事件:

void showWidget::slotScaleActionTriggered(QAction *action)
{
	if (!vlc_mediaPlayer)
		return;

	if (action == m_scale1_4)
		libvlc_video_set_scale(vlc_mediaPlayer, 0.25);
	else if (action == m_scale1_2)
		libvlc_video_set_scale(vlc_mediaPlayer, 0.5);
	else if (action == m_scale1_1)
		libvlc_video_set_scale(vlc_mediaPlayer, 1);
	else if (action == m_scale2_1)
		libvlc_video_set_scale(vlc_mediaPlayer, 2);

	action->setIcon(QIcon(":/image/images/point.png"));
	m_preScale->setIcon(QIcon());
	m_preScale = 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>
#include <QKeyEvent>

enum Rate
{
	Rate2X,
	Rate1_5X,
	Rate1_25X,
	Rate1_0X,
	Rate0_75X,
	Rate0_5X
};

class showWidget : public QWidget
{
    Q_OBJECT

public:
    showWidget(QWidget *parent = nullptr);
    ~showWidget();

protected:
	virtual void mousePressEvent(QMouseEvent *event);
	virtual void mouseDoubleClickEvent(QMouseEvent *event);
	virtual void keyPressEvent(QKeyEvent *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);
	void slotScaleActionTriggered(QAction *action);

private:
	//事件处理回调
	static void vlcEvents(const libvlc_event_t *ev, void *param);

	//初始化menu
	void 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;
	//裁剪

	//缩放
	QMenu *m_scaleMenu = nullptr;
	QAction *m_scale1_4 = nullptr;
	QAction *m_scale1_2 = nullptr;
	QAction *m_scale1_1 = nullptr;
	QAction *m_scale2_1 = nullptr;

	QActionGroup *m_scaleGroup = nullptr;
	QAction *m_preScale = nullptr;
	//缩放

	char *m_defalutRate = nullptr;
	char *m_defalutCrop = nullptr;
	float m_defalutScale = 0;
};

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();

	ui.btnOpen->setFocusPolicy(Qt::NoFocus);
	ui.btnPlay->setFocusPolicy(Qt::NoFocus);
	ui.btnPause->setFocusPolicy(Qt::NoFocus);
	ui.btnStop->setFocusPolicy(Qt::NoFocus);
	ui.hSliderVolumn->setFocusPolicy(Qt::NoFocus);
	ui.cbxRate->setFocusPolicy(Qt::NoFocus);

	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::mouseDoubleClickEvent(QMouseEvent *event)
{
	if (this->isFullScreen())
	{
		this->showNormal();
	}
	else
	{
		this->showFullScreen();
	}
}

void showWidget::keyPressEvent(QKeyEvent *event)
{
	if (!vlc_mediaPlayer)
		return;

	int value = ui.hSliderVolumn->value();
	if (event->key() == Qt::Key_W)	//添加音量
	{
		qDebug() << "up";
		slotValueChanged(value+10);
	}
	else if (event->key() == Qt::Key_S)	//减小音量
	{
		slotValueChanged(value - 10);
	}
	else if (event->key() == Qt::Key_Space)
	{
		if (vlc_mediaPlayer && libvlc_media_player_get_state(vlc_mediaPlayer) == libvlc_Playing)
		{
			libvlc_media_player_pause(vlc_mediaPlayer);
		}
		else if (vlc_mediaPlayer && libvlc_media_player_get_state(vlc_mediaPlayer) == libvlc_Paused)
		{
			libvlc_media_player_play(vlc_mediaPlayer);
		}
	}
}

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) {
			// 处理字幕轨道信息
		}
	}

	//获取事件管理器
	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);
		m_defalutScale = libvlc_video_get_scale(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::slotScaleActionTriggered(QAction *action)
{
	if (!vlc_mediaPlayer)
		return;

	if (action == m_scale1_4)
		libvlc_video_set_scale(vlc_mediaPlayer, 0.25);
	else if (action == m_scale1_2)
		libvlc_video_set_scale(vlc_mediaPlayer, 0.5);
	else if (action == m_scale1_1)
		libvlc_video_set_scale(vlc_mediaPlayer, 1);
	else if (action == m_scale2_1)
		libvlc_video_set_scale(vlc_mediaPlayer, 2);

	action->setIcon(QIcon(":/image/images/point.png"));
	m_preScale->setIcon(QIcon());
	m_preScale = 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);


	//设置缩放菜单
	m_scaleMenu = new QMenu(this);
	m_scaleAction->setMenu(m_scaleMenu);

	m_scale1_4 = m_scaleMenu->addAction("1:4 四分之一");
	m_scale1_2 = m_scaleMenu->addAction("1:2 二分之一");
	m_scale1_1 = m_scaleMenu->addAction(QIcon(":/image/images/point.png"),"1:1 原始");
	m_scale2_1 = m_scaleMenu->addAction("2:1 双倍");

	m_scaleGroup = new QActionGroup(this);
	m_scaleGroup->addAction(m_scale1_4);
	m_scaleGroup->addAction(m_scale1_2);
	m_scaleGroup->addAction(m_scale1_1);
	m_scaleGroup->addAction(m_scale2_1);

	m_preScale = m_scale1_1;

	connect(m_scaleGroup, &QActionGroup::triggered, this, &showWidget::slotScaleActionTriggered);
}

更多参考:

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

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

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

根据IP地址获取归属地

IP获取归属地&#xff0c;通过地址库获取 如果使用API接口获取&#xff0c;可能会出现服务挂了&#xff0c;或者服务地址不提供服务了等问题。而采用本地地址库就没有这些问题。 本文采用离线IP地址定位库 Ip2region&#xff0c;Ip2region是一个离线IP地址定位库&#xff0c;微…

ElasticSearch之数据建模

写在前面 本文看下es数据建模相关的内容。 1&#xff1a;什么是数据建模 数据建模是对真实数据的一种抽象&#xff0c;最终映射为计算机形式的表现。其包括如下三个阶段&#xff1a; 1&#xff1a;概念模型 2&#xff1a;逻辑模型 3&#xff1a;数据模型2&#xff1a;es数据…

案例分享:F5助力车企打造智能高效自动化应用

纵观当下的汽车市场&#xff0c;智能汽车百花齐放。自动驾驶、车载娱乐、实时3D地图等实现人机互动的出行场景&#xff0c;解锁着全新的出行方式。然而得到独特而先进的智能用车体验&#xff0c;离不开持续而深入的汽车应用变革。那么怎样打造智能高效的自动化应用呢&#xff1…

JavaWeb后端——HTTP协议/Tomcat

HTTP HTTP协议&#xff1a;无状态&#xff0c;对事务处理没有记忆能力。每次请求-响应都是独立的。后一次请求不会记录前一次请求数据。缺点&#xff1a;多次请求之间不能共享数据&#xff0c;优点&#xff1a;速度快。 HTTP协议请求报文&#xff1a; HTTP协议响应报文&#x…

(MATLAB)第二十一章 Simulink仿真设计初步

Simulink是MATLAB的重要组成部分&#xff0c;可以非常容易地实现可视化建模&#xff0c;并把理论研究和工程实践有机地结合在一起&#xff0c;不需要书写大量程序&#xff0c;只需要使用鼠标和键盘对已有模块进行简单的操作和设置。 21.1 Simulink简介 Simulink是MATLAB软件的…

一、Java开发环境搭建-----系统类的简单使用

JavadocAPI文档练习&#xff1a; 1、Date类的使用——代码实战 Date类为日期类&#xff0c;是Java中和日期相关的一个类&#xff0c;如下将日期做一个简单的介绍。 package com.kangning.web.controller.common;import java.util.Date;public class DateDemo1 {public static…

SAP/ERP系统PP模块常用增强之二:报表COOIS增加字段

SAP/PP模块中的COOIS报表(订单信息系统)是最常用的标准报表之一,它可以查询有关生产订单的完整信息,但实际项目实施中也会经常遇到这个报表增强需求,一般要求增加一些产品相关的一些额外信息。 SAP系统为此类需求预留第三代BADI增强出口,可以非常方便的实现在COOIS报表中…

水泊梁山108小酒坛之小李广花荣

小李广花荣&#xff0c;是中国著名小说《水浒传》中的108将之一&#xff0c;有“百步穿杨”的功夫。在梁山泊英雄中排行第九&#xff0c;为马军八虎骑兼先锋使之首。原是清风寨副知寨&#xff0c;使一杆银枪&#xff0c;一张弓射遍天下无敌手&#xff0c;生得一双俊目&#xff…

谈谈消息队列

这篇文章我们来聊聊消息队列。我一直在想&#xff0c;能不能用一篇文章就把消息队列的所有内容给串联起来。然后&#xff0c;之后每次看到这篇文章的时候&#xff0c;我就能够立马回忆起来这个大知识的所有知识点。所以我想尝试一下用这种长文的方式&#xff0c;将我自己对于消…

财富池指标公式--通达信资金进场买入提示指标公式

1、“准备现金”信号出现&#xff0c;可开始关注该个股&#xff0c;等待合适价位介入&#xff0c;较为激进的投资者也可在此时介入&#xff0c;更稳健的做法是&#xff0c;等到“买入股票”信号出现后再介入。 2、“见顶清仓”信号出现&#xff0c;预示着即将见顶&#xff0c;是…

Matlab从入门到精通课程

教程介绍 MATLAB是美国MathWorks公司出品的商业数学软件&#xff0c;用于数据分析、无线通信、深度学习、图像处理与计算机视觉、信号处理、量化金融与风险管理、机器人&#xff0c;控制系统等领域。 学习地址 链接&#xff1a;https://pan.baidu.com/s/1PxGarBwQusMzwPVqcE…

【JavaScript】JavaScript 程序流程控制 ⑥ ( while 循环概念 | while 循环语法结构 )

文章目录 一、while 循环1、while 循环概念2、while 循环语法结构 二、while 循环 - 代码示例1、打印数字2、计算 1 - 10 之和 一、while 循环 1、while 循环概念 在 JavaScript 中 , while 循环 是一种 " 循环控制语句 " , 使用该语句就可以 重复执行一段代码块 , …

如何使用 ArcGIS Pro 制作三维建筑

三维地图已经逐渐成为未来地图的趋势&#xff0c;对于大范围应用&#xff0c;只需要普通的建筑体块就行&#xff0c;如果有高程数据&#xff0c;还可以结合地形进行显示&#xff0c;这里为大家介绍一下 ArcGIS Pro 制作三维建筑的方法&#xff0c;希望能对你有所帮助。 数据来…

Kimi是什么?免费Kimi chat介绍

1. Kimi是什么&#xff1f; Kimi是由月之暗面科技有限公司&#xff08;Moonshot AI&#xff09;开发的人工智能助手&#xff0c;专注于提供高质量的对话和信息处理服务。 月之暗面公司创立于2023年3月&#xff0c;创始团队核心成员参与了Google Gemini、Google Bard、盘古NLP、…

Java面试篇:Redis使用场景问题(缓存穿透,缓存击穿,缓存雪崩,双写一致性,Redis持久化,数据过期策略,数据淘汰策略)

目录 1.缓存穿透解决方案一:缓存空数据解决方案二&#xff1a;布隆过滤器 2.缓存击穿解决方案一:互斥锁解决方案二:设置当前key逻辑过期 3.缓存雪崩1.给不同的Key的TTL添加随机值2.利用Redis集群提高服务的可用性3.给缓存业务添加降级限流策略4.给业务添加多级缓存 4.双写一致性…

✮✮✮宁波CE认证,CE认证,CE产品检测✮✮✮

✮✮✮&#x1f308;宁波CE认证&#xff0c;&#x1f308;CE认证&#xff0c;&#x1f308;CE产品检测&#x1f308;✮✮✮ ❀热点&#xff1a;&#x1f618;CE认证什么意思 ❀优势&#xff1a;&#x1f61c;CE认证的目的 ✎&#x1f352;CE认证定义和目的 ✎&#x1f350;CE认…

李宏毅深度强化学习导论——演员-评论员

引言 本文主要介绍演员-评论员(Actor-Critic)算法。 Critic 给定Actor θ \theta θ&#xff0c;Critic评估当观测到 s s s(或进一步地采取行动 a a a)的好坏。 价值函数(Value function)&#xff0c;记为 V θ ( s ) V^\theta(s) Vθ(s)&#xff0c;就是一种Critic。 它的…

蓝桥杯刷题(十四)

1.小平方 代码 n int(input()) count0 def f(x)->bool: # 判断条件return True if x**2%n<n/2 else False for i in range(1,n): # 遍历[1,n-1]&#xff0c;符合题意计数加一if f(i):count1 print(count)2.3的倍数 代码 a int(input()) b int(input()) c int(input…

【python】flask各种版本的项目,终端命令运行方式的实现

✨✨ 欢迎大家来到景天科技苑✨✨ &#x1f388;&#x1f388; 养成好习惯&#xff0c;先赞后看哦~&#x1f388;&#x1f388; &#x1f3c6; 作者简介&#xff1a;景天科技苑 &#x1f3c6;《头衔》&#xff1a;大厂架构师&#xff0c;华为云开发者社区专家博主&#xff0c;…

Java:ArrayList与顺序表

一、线性表 线性表是n个具有相同特征的数据元素的有限序列&#xff0c;它是一种在实际中广泛使用的数据结构&#xff0c;常见的线性表有&#xff1a;顺序表、链表、栈、队列...... 如图&#xff1a;顺序表与链表的区别看了标题的伙伴就应该知道&#xff0c;我们这次要讲解的主…