IP Cam Talk

Welcome to the new IPCT! If you are having an issue logging in, please clear your cookies / cache.

Hikvision NVR video conversion ffmpeg

astral

n3wb
Joined
Dec 11, 2017
Messages
8
Reaction score
1
I have a Hikvision NVR that stores security camera footage that I need to display on a website. I know that Hikvision uses proprietary H.264 codec that makes it impossible to play (coherently) in popular video players, like VLC, unless you install that codec everywhere you play it.

My plan was to transcode the video using ffmpeg to regular H.264 codec and AAC for audio but the produced file has the same issues as the original - no audio when playing and very disruptive video. So the question is, does ffmpeg support encoding from Hikvision video/audio codecs? Or perhaps should try to convert to different web-capable codecs using ffmpeg? My ffmpeg command looks like this:

Code:
ffmpeg -i C:\1.mp4  -c:v libx264 -preset fast -crf 30 -b:v 200k -c:a aac -strict experimental -movflags faststart -threads 0 C:\2.mp4
What's interesting is that ffplay.exe opens and plays the original video files with no problem whatsoever, even on a computer where Hikvision codecs are not isntalled, therefore I figured conversion should be possible as well?

Mediainfo output for the video file in question:

General
CompleteName : C:\DownLoad\1.mp4
Format : MPEG-PS
FileSize/String : 8.60 MiB
Duration/String : 2 h 7 min
OverallBitRate/String : 9 395 b/s
FileExtension_Invalid : mpeg mpg m2p vob pss evo

Video
ID/String : 224 (0xE0)
Format : AVC
Format/Info : Advanced Video Codec
Format_Profile : Baseline@L4
Format_Settings : 1 Ref Frames
Format_Settings_CABAC/String : No
Format_Settings_RefFrames/String : 1 frame
Format_Settings_GOP : M=1, N=30
Duration/String : 2 min 0 s
Width/String : 1 920 pixels
Height/String : 1 080 pixels
DisplayAspectRatio/String : 16:9
FrameRate_Mode/String : Variable
ColorSpace : YUV
ChromaSubsampling/String : 4:2:0
BitDepth/String : 8 bits
ScanType/String : Progressive

Audio
ID/String : 192 (0xC0)
Format : MPEG Audio
Duration/String : 2 h 7 min
Compression_Mode/String : Lossy
Video_Delay/String : -33 min 40 s

Note: the above video/audio duration is wrong, since the video is only 2 minutes in length. VLC shows the wrong duration as well

IP Camera settings on NVR:


Video sample: Dropbox - 1.zip
 
Last edited:

alastairstevenson

Staff member
Joined
Oct 28, 2014
Messages
11,388
Reaction score
3,648
Location
Scotland
I know that Hikvision uses proprietary H.264 codec
Are you sure you're not getting mixed up with the h.264+ choice?
What are the IP camera sources set to?
I can't say I've seen any problems playing h.264 files off a Hikvision NVR with VLC, various Linux video players, WMP.
 

astral

n3wb
Joined
Dec 11, 2017
Messages
8
Reaction score
1
Are you sure you're not getting mixed up with the h.264+ choice?
What are the IP camera sources set to?
I can't say I've seen any problems playing h.264 files off a Hikvision NVR with VLC, various Linux video players, WMP.
I have attached the camera settings to my original post. I should probably add that the software I am using to download video from NVR is part of Hikvision's Player SDK that can be found here: Hangzhou Hikvision Digital Technology Co. Ltd.
I am almost certain that iVMS uses the same libraries to convert the video
 

alastairstevenson

Staff member
Joined
Oct 28, 2014
Messages
11,388
Reaction score
3,648
Location
Scotland
FileSize/String : 8.60 MiB
Duration/String : 2 h 7 min
OverallBitRate/String : 9 395 b/s
That's looking a bit odd. For file size and bit rate.

I just downloaded a short sample video from a 7816N-E2 NVR that was stored from a Hikvision 2332 camera using h.264, using the 'Download' link of the Playback page of the web GUI. Maybe try this method and see what the result is.
It plays normally in Xplayer and VLC on Linux Mint.
And mediainfo shows this :
Code:
alastair@PC-I5 ~/Videos $ ll 00*.mp4
-rw-r--r-- 1 alastair alastair 20738348 Dec 11 19:54 00000000474004013.mp4
alastair@PC-I5 ~/Videos $ mediainfo 00*.mp4
General
Complete name                            : 00000000474004013.mp4
Format                                   : MPEG-PS
File size                                : 19.8 MiB
Duration                                 : 26s 767ms
Overall bit rate                         : 6 198 Kbps

Video
ID                                       : 224 (0xE0)
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L5
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 1 frame
Duration                                 : 26s 767ms
Bit rate                                 : 6 075 Kbps
Width                                    : 2 048 pixels
Height                                   : 1 536 pixels
Display aspect ratio                     : 4:3
Frame rate mode                          : Variable
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Stream size                              : 19.4 MiB (98%)
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

Text
ID                                       : 189 (0xBD)
Format                                   : RLE
Format/Info                              : Run-length encoding
Duration                                 : 26s 600ms


alastair@PC-I5 ~/Videos $
 

astral

n3wb
Joined
Dec 11, 2017
Messages
8
Reaction score
1
That's looking a bit odd. For file size and bit rate.

I just downloaded a short sample video from a 7816N-E2 NVR that was stored from a Hikvision 2332 camera using h.264, using the 'Download' link of the Playback page of the web GUI. Maybe try this method and see what the result is.
It plays normally in Xplayer and VLC on Linux Mint.
And mediainfo shows this :
Code:
alastair@PC-I5 ~/Videos $ ll 00*.mp4
-rw-r--r-- 1 alastair alastair 20738348 Dec 11 19:54 00000000474004013.mp4
alastair@PC-I5 ~/Videos $ mediainfo 00*.mp4
General
Complete name                            : 00000000474004013.mp4
Format                                   : MPEG-PS
File size                                : 19.8 MiB
Duration                                 : 26s 767ms
Overall bit rate                         : 6 198 Kbps

Video
ID                                       : 224 (0xE0)
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L5
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 1 frame
Duration                                 : 26s 767ms
Bit rate                                 : 6 075 Kbps
Width                                    : 2 048 pixels
Height                                   : 1 536 pixels
Display aspect ratio                     : 4:3
Frame rate mode                          : Variable
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Stream size                              : 19.4 MiB (98%)
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

Text
ID                                       : 189 (0xBD)
Format                                   : RLE
Format/Info                              : Run-length encoding
Duration                                 : 26s 600ms


alastair@PC-I5 ~/Videos $

Unfortunately I cannot use that way because it does not allow me to download a video from specific time and length, which is vital for the project that I am working on. Hikvision's Player SDK has a working software that allows you to specify the start time and end time of the video you want to download.
 

alastairstevenson

Staff member
Joined
Oct 28, 2014
Messages
11,388
Reaction score
3,648
Location
Scotland
Unfortunately I cannot use that way because it does not allow me to download a video from specific time and length, which is vital for the project that I am working on.
Understood.
But the suggestion was more to determine if the problems playing the video were changed by extracting it via another method.
Presumably it's essentially just a file transfer via the Playback route.
But via the SDK there must be some processing involved, perhaps flawed.
 

astral

n3wb
Joined
Dec 11, 2017
Messages
8
Reaction score
1
Understood.
But the suggestion was more to determine if the problems playing the video were changed by extracting it via another method.
Presumably it's essentially just a file transfer via the Playback route.
But via the SDK there must be some processing involved, perhaps flawed.
I have also attached a small video sample to better illustrate the problem. It is exactly 2 mintues long but VLC / Mediainfo will give you different numbers
 

alastairstevenson

Staff member
Joined
Oct 28, 2014
Messages
11,388
Reaction score
3,648
Location
Scotland
I know that Hikvision uses proprietary H.264 codec that makes it impossible to play (coherently) in popular video players, like VLC, unless you install that codec everywhere you play it.
I have not installed any Hikvision codecs to play the sample on VLC and Xplayer (Linux).

no audio when playing and very disruptive video.
Could you be more specific about the problems playing the video?
It does seem to play OK, within the constraints of the very low bitrate (512Kbps) for the 1080p resolution and 25fps frame rate..
And there are no audio frames.
My guess - without looking at the low level detail of the frames, is that the SDK is mis-labelling the frames and not transferring the audio stream.
 

astral

n3wb
Joined
Dec 11, 2017
Messages
8
Reaction score
1
I have not installed any Hikvision codecs to play the sample on VLC and Xplayer (Linux).


Could you be more specific about the problems playing the video?
It does seem to play OK, within the constraints of the very low bitrate (512Kbps) for the 1080p resolution and 25fps frame rate..
And there are no audio frames.
My guess - without looking at the low level detail of the frames, is that the SDK is mis-labelling the frames and not transferring the audio stream.
There is an audio stream since you can play it using ffmpeg's ffplay.exe or VSPlayer from Hikvision. Apart from that, the video length is wrong (1-2 hours instead of 2 mins)
 
Top