


How to push the video stream of Hikvision camera SDK to the front-end Vue project for real-time playback?
Apr 19, 2025 pm 07:42 PMHikvision Camera SDK Video Streaming Live Playback in Vue Project
This article introduces how to stream the video obtained by Hikvision camera SDK through the streaming media server (zlmediakit) and finally play in the Vue front-end project in real time. The entire process does not rely on cloud video services, and the camera is directly connected to the local computer.
System architecture and implementation ideas
The system adopts a three-layer architecture:
- Hikvision camera and backend (Spring Boot): Use Hikvision SDK to obtain camera video streaming.
- Streaming Media Server (ZLMediaKit): As a middleware, it receives video streams pushed by the backend and forwards them.
- Front-end (Vue): Pull RTSP stream from ZLMediaKit for playback.
Backend (Java) implementation details
The backend uses the Spring Boot framework, and the core logic is to push the video data of the Hikvision SDK callback to ZLMediaKit. The code snippet is as follows:
@Service public class HikvisionServiceImpl implements HikvisionService { // ... Other codes... @PostConstruct public void register() { // Initialize HikvisionClient client = new HikvisionClient(); client.initPipedStream(); client.clientInit(); client.action(); // Start preview and get video stream data through callback} // Hikvision SDK callback function class RealDataCallback implements HCNetSDK.FRealDataCallBack_V30 { @Override public void invoke(int lRealHandle, int dwDataType, ByteByReference pBuffer, int dwBufSize, Pointer pUser) { if (dwDataType == HCNetSDK.NET_DVR_STREAMDATA) { if (dwBufSize > 0) { ByteBuffer buffer = pBuffer.getPointer().getByteBuffer(0, dwBufSize); byte[] bytes = new byte[dwBufSize]; buffer.rewind(); buffer.get(bytes); executor.execute(() -> pushToZLMediaKit(bytes)); // Push to ZLMediaKit } } } } private void pushToZLMediaKit(byte[] data) { // Push data to ZLMediaKit, this part needs to be implemented according to ZLMediaKit's API. // The data may need to be encoded (e.g. H.264) and sent over the network to the ZLMediaKit server. // ... ZLMediaKit push code... } }
The pushToZLMediaKit
method is key, and the received video data needs to be pushed to the specified streaming server address according to the ZLMediaKit API document. This may involve data format conversion (e.g., converting raw data to H.264 streams).
Front-end (Vue) implementation details
The front-end uses the Vue framework and combines a suitable video player library such as flv.js or hls.js to play RTSP streams obtained from ZLMediaKit.
// Vue component code snippet<template> <video ref="videoPlayer" autoplay></video> </template> <script> import flvjs from 'flv.js'; // 或hls.js export default { mounted() { this.initPlayer(); }, methods: { initPlayer() { const rtspUrl = '/api/rtspStream'; // 后端提供的RTSP流地址接口 fetch(rtspUrl) .then(response => response.json()) .then(data => { const flvPlayer = flvjs.createPlayer({ type: 'flv', url: data.rtspUrl // 獲取到的RTSP流地址 }); flvPlayer.attachMediaElement(this.$refs.videoPlayer); flvPlayer.load(); flvPlayer.play(); }) .catch(error => console.error('Error fetching RTSP URL:', error)); } } }; </script>
/api/rtspStream
is a backend interface that returns the RTSP stream address generated in ZLMediaKit.
Complete solution supplement
In order to achieve stable video streaming, the backend may need to use FFmpeg for transcoding to convert the original video stream output by Hikvision SDK to a format supported by ZLMediaKit (such as FLV). The backend needs to continuously write data to the response stream, while the frontend parses and plays through libraries such as flv.js. This requires careful processing of network transmission and data buffering to ensure smooth video playback. Error handling and resource release are also crucial.
The above is the detailed content of How to push the video stream of Hikvision camera SDK to the front-end Vue project for real-time playback?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Google Chrome is a free and fast multi-platform web browser developed by Google. It is known for its speed, stability and reliability. Chrome is based on the open source Chromium project and is widely used on devices such as desktops, laptops, tablets and smartphones. The browser has a clean interface and a wide range of customizable options, allowing users to personalize it according to their preferences. In addition, Chrome has a huge library of extensions that provide additional features such as ad blocking, password management and language translation, further enhancing the browsing experience.

The acquisition and management of digital assets can be achieved through the official Solana platform and secure storage solutions. 1. Solana's official application platform (solana.com/ecosystem) provides project browsing, official application downloads and developer resources; 2. Its trading platform address is a designated link to facilitate user transactions; 3. Hardware storage devices such as Ledger can ensure private key security offline; 4. Desktop or mobile applications such as Phantom support convenient management; 5. Multi-signature technology improves authorization security; in addition, you can also participate in the digital asset ecosystem by participating in community governance, using decentralized applications, content creation, etc.

This article provides the download and installation steps of Ouyi computer version client. 1. Visit the official website; 2. Find the download portal; 3. Select the corresponding version; 4. Download and install; 5. Log in to use to ensure that users can quickly complete transaction operations on the PC side.

You can download and install Ouyi OKX official App through the following steps: 1. Visit Ouyi OKX official registration page to complete registration; 2. Enter your email or mobile phone number and set your password; 3. Perform identity authentication (KYC) to improve account security and permissions; 4. Submit real and valid identity information; 5. Wait for review and pass; 6. Click the official link to download the App; 7. Find the downloaded installation file and start the installation, pay attention to allowing application permissions from unknown sources; 8. Open the App and log in to the account after the installation is completed; 9. The first login requires the mobile phone or email verification code verification code verification; 10. Enable secondary verification and properly keep the account information. After completing the above steps, you can use the App to recharge, trade, and withdraw operations.

Building a Vue component library requires designing the structure around the business scenario and following the complete process of development, testing and release. 1. The structural design should be classified according to functional modules, including basic components, layout components and business components; 2. Use SCSS or CSS variables to unify the theme and style; 3. Unify the naming specifications and introduce ESLint and Prettier to ensure the consistent code style; 4. Display the usage of components on the supporting document site; 5. Use Vite and other tools to package as NPM packages and configure rollupOptions; 6. Follow the semver specification to manage versions and changelogs when publishing.

1. The first choice for the Laravel MySQL Vue/React combination in the PHP development question and answer community is the first choice for Laravel MySQL Vue/React combination, due to its maturity in the ecosystem and high development efficiency; 2. High performance requires dependence on cache (Redis), database optimization, CDN and asynchronous queues; 3. Security must be done with input filtering, CSRF protection, HTTPS, password encryption and permission control; 4. Money optional advertising, member subscription, rewards, commissions, knowledge payment and other models, the core is to match community tone and user needs.

To retrieve Bitcoins purchased years ago, you must first determine its storage location and retrieve the access key. The specific steps are as follows: 1. Recall and check the exchange accounts you may have used, such as Binance, Ouyi, Huobi, Gate.io, Coinbase, Kraken, etc., and try to log in or retrieve your password through email; 2. If Bitcoin has been withdrawn to your personal wallet, you must find the mnemonic, private key or wallet file. This information may exist in physical backup, electronic device or password manager; 3. After finding the key information, use the mainstream wallet app to select the "Recover Wallet" function and accurately enter the mnemonic or private key to synchronize the assets; Important tips: Do not disclose mnemonic or private keys to ensure the safe operation environment, and patiently and systematically check all

When the trading platform is not accessible, you should remain calm and respond according to the steps: the first step is to check the network, replace the device or ask others to confirm the root cause of the problem; the second step is to obtain accurate information through official social media, status pages and in-app announcements; the third step is to refer to community feedback but be careful to distinguish the authenticity; the fourth step is to evaluate your own position and formulate a response strategy; the fifth step is to disperse the platform to use, set stop loss and profit, and be familiar with backup tools to establish multiple guarantees.
