In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use Qt ffmpeg player". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use the Qt ffmpeg player.
I. Preface
It has always been a goal to use ffmpeg to achieve your own player. The previous difficulties are audio and video synchronization and how to play sound. (although many attempts and explorations have been made before, there are still many problems, such as audio and video synchronization is not perfect, some files are normal and some files are not accurate, and the sdl used for sound playback always feels weird. And many beginners also reflect that they want to use Qt's own class to play), which has just overcome these two difficulties one by one recently. Audio and video synchronization uses the external clock synchronization, sound playback uses the QAudioOutput of Qt (sdl is not used, saving the cost of learning sdl open source library), and the demo of the player is carried out as scheduled. Sometimes to do a project, if the various difficulties are broken, the next is a matter of course, the speed will be very fast, this is also a strategy I often use.
The functions of the simplest basic player:
Play, close, pause, continue.
Volume adjustment, mute setting.
Schedule adjustment, positioning and playback.
Total time, time that has been played.
Audio, video, local files, video streams.
The previous articles have written about audio and video synchronization, audio playback, volume setting and mute setting. The only thing missing here is the processing of schedule adjustment and positioning playback. Ffmpeg has a built-in av_seek_frame function to locate the playback frame, with a total of four parameters. The meanings are as follows:
Parameter 1 AVFormatContext * s indicates the context in which the media object is processed.
Parameter 2 int stream_index indicates the index of the stream, and-1 indicates the automatic default stream index.
Parameter 3 int64_t timestamp indicates the time to be located in subtle units. If you pass in seconds, you need * AV_TIME_BASE.
Parameter 4 int flags indicates how to locate and find the policy used. It is recommended to select AVSEEK_FLAG_BACKWARD. The rest of the parameters are easy to blur.
The returned value > = 0 indicates success.
II. Functional features
Multi-thread real-time playback video stream + local video + USB camera and so on.
Support windows+linux+mac, support ffmpeg3 and ffmpeg4, support 32-bit and 64-bit.
Multi-thread display image, do not card the main interface.
Automatically reconnect the webcam.
The border size can be set, that is, the offset and the border color.
You can set whether to draw OSD tags, that is, label text or pictures and label locations.
There are two OSD locations and styles that can be set.
You can set whether to save to a file and the file name.
You can drag the file directly to the ffmpegwidget 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.
Programmable decoding is speed priority, quality priority and balanced processing.
You can take screenshots (original pictures) and screenshots of the video.
Video file storage supports naked streaming and MP4 files.
Perfect audio and video synchronization, using external clock synchronization strategy.
Seek is supported to locate the playback position.
Qsv, dxva2, d3d11va and other hard decoding are supported.
Support opengl to draw video data with very low CPU usage.
Support Android and embedded linux, just cross-compile.
Third, effect picture
The core code uint FFmpegThread::getLength () {return duration * 1000;} uint FFmpegThread::getPosition () {return 0;} void FFmpegThread::setPosition (int position) {if (this- > isRunning () & &! isRtsp & &! isUsbCamera) {pause (); QThread::msleep (100); videoSync- > clear (); audioSync- > clear () Int64_t timestamp = (double) position / 1000.0) * AV_TIME_BASE; av_seek_frame (formatCtx,-1, timestamp, AVSEEK_FLAG_BACKWARD); next ();} void FFmpegThread::play () {/ / Let the thread perform initialization through the flag bit isPlay = true; isPause = false;} void FFmpegThread::pause () {/ / works only on local files playAudio = false If (! isRtsp & &! isUsbCamera & &! isPause) {isPause = true;}} void FFmpegThread::next () {/ / works only on local files playAudio = true; if (! isRtsp & &! isUsbCamera & & isPause) {isPause = false; videoSync- > reset (); audioSync- > reset () }} void FFmpegThread::stop () {/ / stop thread stopped = true;} void FFmpegThread::snap () {/ / screenshot handle mode only needs if (! callback) {isSnap = true;}} through flag bit. I believe everyone has a deeper understanding of "how to use Qt ffmpeg player". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.