In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to use Qt vlc video storage". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
I. Preface
Video recording function is a common feature of the video surveillance system, that is, the open video stream or video file is re-saved into a MP4 file, of course, it can also be saved into other formats, generally using MP4 by default is better, compared to the standard some, MP4 format compatibility is the best, basically did not say that the computer can not play MP4 files, so save into this most commonly used video file format is good.
The video recording function of vlc is encapsulated in built-in. You can set the corresponding command parameters before opening the file. If you only require the whole process to be saved as a video file, this is very easy. There are a lot of online methods. Just call the libvlc_media_add_option function to set: sout=#duplicate {dst=file {dst=d:/1.mp4}, dst=display}. At first, the parameter sout=#stream_out_duplicate {dst=display,dst=std {access=file,mux=%1,dst=%2}} is used. Later, it is found that it is not supported by vlc3. After consulting the relevant information, it is found that you need to use duplicate. Maybe vlc3 does not support stream_out_duplicate but only duplicate at the beginning.
Saving as a single video file does not have any problem or difficulty, but what is often needed in the field of video surveillance is to save it as a single file regularly, such as a video file in 30 minutes, which is easy to retrieve, and it does not look like a video file is very big. After all, video surveillance is run 24 hours a day, so you don't know how big this file is. Vlc needs to save multiple files dynamically. This needs to simulate the implementation of recording, stop recording function to achieve, the main process is through the var_CreateGetString function to get the video file storage path variable, and then var_SetString to set the variable, and finally call var_ToggleBool to simulate click on the video, stop recording only needs to be executed again, so to store multiple video files, just need to dynamically change the recording file storage path variable.
II. Functional features
Multithreading plays video streams and local videos in real time.
Support windows+linux+mac, support vlc2 and vlc3.
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 vlcwidget control to play.
Supports h365 video streams + rtmp and other common video streams.
Playback can be paused and resumed.
Callback mode and handle mode are supported.
Support thread reading progress and other information and event callback two processing modes.
Automatically signal whether the current playback position and volume are muted or not.
Provides the interface to set the playback position and volume and set mute.
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.
Third, effect picture
4. The core code void VlcThread::initSave () {if (! saveFile) {return;} if (saveInterval = = 0) {saveOne (fileName);}} void VlcThread::saveOne (const QString & fileName) {QString temp = url.toUpper (); QString mux = "ts"; if (temp.endsWith ("MP4") | temp.endsWith ("MOV")) {mux = "mp4" } / / Old format: sout=#stream_out_duplicate {dst=display,dst=std {access=file,mux=%1,dst=%2}} / / New format: sout=#duplicate {dst=file {dst=d:/1.mp4}, dst=display} / / vlc3 does not support stream_out_duplicate only duplicate QString option = QString (": sout=#duplicate {dst=display,dst=std {access=file,mux=%1,dst=%2}") .arg (mux) .arg (fileName); setOption (option) } void VlcThread::saveVideo () {/ / Save the file only if it is enabled. Do not add an extension here, the file will be automatically generated / / the file will be generated QMutexLocker locker (& mutex) after the interval; if (saveFile) {/ / reset the file name QString dirName = QString ("% 1gamma% 2") .arg (savePath) .arg (QDATE); newDir (dirName) FileName = QString ("% 1amp% 2 percent% 3") .arg (dirName) .arg (fileFlag) .arg (STRDATETIME); saveVideo (fileName);}} void VlcThread::saveVideo (const QString & fileName) {/ / execute except for the first time, because the first time you need to start storage if (! first) {stopSave (vlcPlayer);} first = false; startSave (vlcPlayer, fileName) } / / the video recording function static input_thread_t * libvlc_get_input_thread (libvlc_media_player_t * vlcPlayer) {input_thread_t * input = NULL; if (vlcPlayer! = NULL) {input = vlcPlayer- > input.p_thread; if (input) {vlc_object_hold (input);}} return input } / / start recording static void startSave (libvlc_media_player_t * vlcPlayer, const QString & fileName = "") {input_thread_t * input = libvlc_get_input_thread (vlcPlayer); if (input = = NULL) {return;} # ifdef vlc3 / / is the path with the file name, and you need to remove the following file name QStringList list = fileName.split ("/"); QStringList paths Int count = list.count ()-1; for (int I = 0; I < count; iTunes +) {paths
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.