Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement Qt mpv Reading and Control

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to achieve Qt mpv reading and control". In daily operation, I believe many people have doubts about how to achieve Qt mpv reading and control. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "how to achieve Qt mpv reading and control". Next, please follow the editor to study!

I. Preface

Use mpv to read the information of the file, and set the current playback progress, volume, mute, etc., just like the functions encapsulated by vlc at that time, except that vlc is handled by calling function interfaces, while mpv is processed by reading and setting properties. Vlc supports timers or thread function methods to read state, and event callbacks are also supported to get the corresponding state changes. Mpv also supports it, and it is more convenient. The main amount of work or time spent is how to know what attributes and what functions they are, which are listed officially (http://mpv.io/manual/master/#options, http://mpv.io/manual/master/#list-of-input-commands, http://mpv.io/manual/master/#properties), but they are all in English, so most programmers should have no difficulty. Just translate the right mouse button into Chinese, , I believe many people have done this, and many browsers support the translation of the right mouse button menu by default, which is very convenient. When I consult a lot of English documents, I use a lot of them, including Qt official documents and BUG report pages, but it is recommended to use English description as far as possible when searching for problems. So that the search can be more accurate.

Some commonly used attributes:

Video original width height width height

Video scaled width height dwidth dheight

Save the video file stream-record is empty, it means to stop recording

Video aspect ratio video-aspect

Pause pause yes: pause no: continue

Video file length duration

Mute mute yes means mute no means non-mute

Volume volume int value 0-100

Get playback progress time-pos

Set playback progress seek

Current track aid

Number of tracks track-list/count

Screenshot screenshot-to-file

II. Functional features

Multi-thread real-time playback video stream + local video and so on.

Windows+linux+mac is supported.

Multi-thread display image, do not card the main interface.

Automatically reconnect the webcam.

You can set whether to save to a file and the file name.

You can drag the file directly to the mpvwidget control to play.

Supports h365 video streams + rtmp and other common video streams.

Playback can be paused and resumed.

Support for storing individual video files and storing video files at regular intervals.

Customize the top suspension bar and send click signal notification, which can be set whether it is enabled or not.

Can set screen stretch fill or proportional fill.

You can take screenshots (original pictures) and screenshots of the video.

Video files store MP4 files.

Qsv, dxva2, d3d11va and other hard decoding are supported.

Third, effect picture

4. Core code void MpvThread::readMediaInfo () {if (mpvPlayer! = NULL) {QVariant width = getValue ("width"); QVariant height = getValue ("height"); videoWidth = width.toInt (); videoHeight = height.toInt (); qDebug () position = = position) {isPlay = false;} this- > position = position;} return isPlay } uint MpvThread::getLength () {uint length = 0; if (mpvPlayer! = NULL) {QVariant value = getValue ("duration"); length = value.toDouble () * 1000;} return length;} uint MpvThread::getPosition () {uint positon = 0; if (mpvPlayer! = NULL) {QVariant value = getValue ("time-pos"); positon = value.toDouble () * 1000;} return positon } void MpvThread::setPosition (int position) {if (mpvPlayer! = NULL & &! isRtsp) {command (QVariantList ())

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report