


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

The reliable and safe currency spot trading platforms in 2025 include: 1. Binance, rich trading pairs, low fees, and advanced trading functions; 2. HTX Huobi, multiple trading pairs, low transaction fees, and friendly user interface; 3. OKX, multiple trading pairs, low transaction fees, and multiple trading tools; 4. Coinbase; 5. Kraken...

Entering CSGO HD blockbuster mode requires four steps: 1. Update the game client to the latest version; 2. Adjust the video settings to the highest parameters; 3. Start the game and enter high-definition mode; 4. Optimize performance and test adjustments. Through these steps, you can improve the gaming experience of CSGO and enjoy a clearer picture and a more immersive gaming environment.

Here are the top 10 well-known memory stick brands on the market: Samsung: Excellent performance and stability Kingston: Durability and reliability Zhiqi: High speed and overclocking capabilities Corsair: High performance, cooling and aesthetics Inruida: High cost performance and reliability Viagra: Wide product line Shadow: Performance and appearance for gamers Avatar: High cost performance Kintech: Innovative design and RGB lighting Bainaohui: Low price and reliable performance

The reliable and safe currency spot trading platforms in 2025 include: 1. Binance, rich trading pairs, low fees, and advanced trading functions; 2. HTX Huobi, multiple trading pairs, low transaction fees, and friendly user interface; 3. OKX, multiple trading pairs, low transaction fees, and multiple trading tools; 4. Coinbase; 5. Kraken...

Official download guide for Ouyi Exchange app: Android users can download it through the Google Play Store, and iOS users can download it through the Apple App Store. Visit the official website www.ouyiex.com to register and log in. Both the application and the official website provide rich transaction and management functions.

If the iPhone cannot be turned on, you can solve the following methods: 1. Forced restart: For iPhone 8 and later models, quickly press and release the volume up key, then quickly press and release the volume down key, and finally press and hold the side button until you see the Apple logo. 2. Check the battery level: Connect the phone to the charger for at least 15 minutes, and then try to turn it on. 3. Contact Apple customer service or go to Apple's authorized service center for repairs. 4. Use recovery mode: Connect your computer, use iTunes or Finder, press and hold the side button until the logo connected to iTunes appears, and select "Recover". 5. Check for physical damage: Check for cracks, depressions or other damage to the phone. If so, it is recommended to go to the maintenance center for treatment as soon as possible.

To solve the problem that the app cannot be installed after the iOS system is updated, you can use the following steps: 1. Clean the system cache: Go to "Settings" > "General" > "IPhone Storage", uninstall infrequently used apps and restart the device. 2. Solve through downgrade: Download the previous version of iOS firmware and use iTunes or Finder to downgrade. 3. Contact Apple customer service: provide serial number, seek professional help and backup data.

Binance, as the world's leading cryptocurrency trading platform, has attracted the favor of millions of users around the world with its powerful trading functions, rich digital asset types and excellent security performance. To meet the needs of different users, Binance provides a variety of access methods, including Android mobile apps and web versions.
