Closed yangpu closed 7 years ago
Hello yangpu for further support it would be helpful to know what the model name your HIKVision is? Without knowing your camera model i guess that you need to add a video channel at the end of your rtsp link.
It should e.g. look like this: rtsp://admin:12345@192.168.0.25:554/Streaming/Channels/1
HIKVision has different syntaxes in depency what model you have, how old your model is or what firmware runs. You could find more proper working links for your model here:
Keep on streaming!
Sven
The video device parameters as: Device Name: IP CAMERA Device NO.: 88 Device Model: DS-2CD3310D-I Device Serial: DS-2CD3310D-I20150309AACH504451784 Major Version: V5.2.3 build 141024 Code Version: V1.0 build 140926 Channel Quntity: 1
and HIKVision IP Camera URL (https://www.ispyconnect.com/man.aspx?n=Hikvision) suggested as: DS-2CD3310D-I FFMPEG rtsp://IPADDRESS:554//Streaming/Channels/2 Yes None
However, no streaming yet for url rtsp://admin:12345@192.168.0.25:554//Streaming/Channels/2, but VLC can preview the video with the same url.
Hello yangpu, thank you for your patience.
We need some error code from FFmpeg to help you. The procedure is like this... At first you have to take a look at the docker container name you are running. Then you have to take the name of the docker container and do the docker exec with this container name. In the last step you speak with ffmpeg to geht the log we need to take a look at. You have to execute the following commands in your SSH command line to get the logs.
It is not that hard lets do it!
docker ps
to get the name of your running docker container. The output is:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
docker exec -it restreamer /bin/bash
change the name (in my line restreamer) to the name of the docker ps command from above if it is not restreamer!ffmpeg -i rtsp://admin:12345@192.168.0.25:554/Streaming/Channels/1 -c copy -f flv rtmp://127.0.0.1:1935/live/test.stream
Thats it. Keep on streaming!
Sven
Thanks Sven,
# ffmpeg -i rtsp://admin:12345@192.168.0.25:554/Streaming/Channels/1 -c copy -f flv rtmp://127.0.0.1:1935/live/test.stre
am
ffmpeg version 2.8.1 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.2 (Debian 4.9.2-10)
configuration: --prefix=/usr/local --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --bindir=/usr/
local/bin --extra-libs=-ldl --enable-version3 --enable-libmp3lame --enable-libx264 --enable-gpl --enable-postproc --enab
le-nonfree --enable-avresample --disable-debug --enable-small --enable-openssl
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
[rtsp @ 0x39224c0] UDP timeout, retrying with TCP
[rtsp @ 0x39224c0] method PAUSE failed: 551 Option not supported
[rtsp @ 0x39224c0] Could not find codec parameters for stream 0 (Video: h264, none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
rtsp://admin:12345@192.168.0.25:554/Streaming/Channels/1: could not find codec parameters
Input #0, rtsp, from 'rtsp://admin:12345@192.168.0.25:554/Streaming/Channels/1':
Metadata:
title : Media Presentation
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264, none, 90k tbr, 90k tbn, 180k tbc
Output #0, flv, to 'rtmp://127.0.0.1:1935/live/test.stream':
Output file #0 does not contain any stream
#
Thanks for your FFmpeg output. It says:
[rtsp @ 0x39224c0] method PAUSE failed: 551 Option not supported
[rtsp @ 0x39224c0] Could not find codec parameters for stream 0 (Video: h264, none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
"Could not find codec parameters for stream" und "Output file #0 does not contain any stream" = ffmpeg
Thats really weird...
I have another question: What video resolution are you using in that profile? Please try to use another Video resolution like 720 or 1080. Try to focus on 16:9 resolutions.
If that did not work try to add the -map 0
to the ffmpeg command.
Ok lets do it: Please do Step 1) 2) 3) as above explained (see https://github.com/datarhei/restreamer/issues/3#issuecomment-170857541). execute the following command and show me the output.
ffmpeg -rtsp_transport tcp -i rtsp://admin:12345@192.168.0.25:554//Streaming/Channels/1 -map 0 -c copy -f flv /tmp/test.flv
Thank you for your patience. Keep on streaming!
Sven
Hey ho yangpu, problems solved? I would like to close this case soon...
Stream me up, Scotty! :space_invader: Sven
Sorry Sven,
I'm unable to access this LAN video because of business trip for several days.
I have tried all pre-configurable resolutions of this video as 1280 * 720p, 1280 * 960, 704 * 576, 640 * 480. None of these works.
The output to execute -map 0 flag as:
# ffmpeg -rtsp_transport tcp -i rtsp://admin:12345@192.168.0.25:554//Streaming/Channels/1 -map 0 -c copy -f flv /tmp/tes
t.flv
ffmpeg version 2.8.1 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.2 (Debian 4.9.2-10)
configuration: --prefix=/usr/local --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --bindir=/usr/
local/bin --extra-libs=-ldl --enable-version3 --enable-libmp3lame --enable-libx264 --enable-gpl --enable-postproc --enab
le-nonfree --enable-avresample --disable-debug --enable-small --enable-openssl
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
Input #0, rtsp, from 'rtsp://admin:12345@192.168.0.25:554//Streaming/Channels/1':
Metadata:
title : Media Presentation
Duration: N/A, start: 0.081444, bitrate: N/A
Stream #0:0: Video: h264, yuv420p, 1280x720, 24.58 tbr, 90k tbn, 180k tbc
File '/tmp/test.flv' already exists. Overwrite ? [y/N] y
[flv @ 0x2c5d560] Codec for stream 0 does not use global headers but container format requires global headers
Output #0, flv, to '/tmp/test.flv':
Metadata:
title : Media Presentation
encoder : Lavf56.40.101
Stream #0:0: Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 1280x720, q=2-31, 24.58 tbr, 1k tbn, 90k tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 313 fps= 33 q=-1.0 size= 3102kB time=00:00:12.66 bitrate=2006.3kbits/s
Thanks for your patient.
Regards, Pu
Hello everyone!
The cause of the problem is the Hikvision stream - it's missing PPS.
NGINX-RTMP fails with error:
hls: error appenging SPS/PPS NALs, client: 127.0.0.1, server: 0.0.0.0:1935
If we turn HLS off, stream starts successfully, but it's impossible to play it. Decoder fails to decode the stream with error:
[ffmpeg/video] h264: missing picture in access unit with size 13022
[ffmpeg/video] h264: no frame!
I'm not sure if is is possible to inject PPS on the fly.
One of the possible solutions is to add transcoding support to Restreamer.
Best regards, Andrew
Hey yangpu.. First sorry @yangpu for our late response and thanks andrew for helping us!
Yangpu´s ffmpeg output had been "frame= 313 fps= 33" This looks quite normal, but we haven't a Hikvision hardware to check. So I can't say "it works" ;-) If it's the problem you mentioned, it's a really bad one because e.g. ARM (Pi1/2...) have definitely not enough power for realtime encoding with higer FPS. Perhaps we will think about different workflows for powerless plattforms after leaving rc to stable. We are still working at the application base.
@Yangpu: We did not forget you :) Our roadmap will be to find ways to support many cases with unique FFMpeg-configurations and we are working on it. I am looking how to get one of those HIKvision cameras.
@andrew-shulgin Do you have exact the same model or is there any information if this problem is at every HIKVision camera? I am thinking about buying HIKVISION DS-2CD2032-I to reproduce the error. If it is only yangpu´s unique model the 2CD2032-I will not help.
Stream me up, Scotty!
Sven
Hello!
@svenerbeck I emailed you some publicly accessible Hikvison streams.
Hey guys!
I found a dirty workaround with piping two FFmpegs.
ffmpeg -re -rtsp_transport tcp \
-i rtsp://admin:12345@192.88.99.1/h264/ch1/main/av_stream \
-codec copy -f h264 pipe:1 | \
ffmpeg -re -i pipe:0 \
-ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero \
-c:v copy -acodec aac -strict experimental -ab 128k \
-map_metadata -1 \
-metadata application=datarhei/Restreamer -metadata server=NGINX-RTMP \
-f flv rtmp://127.0.0.1/live/test.stream
Hey @andrew-shulgin That's ugly but nice work :-D Hard case for an implementation, but we will give our best. Thanks!
Hello again :smile:
I've spotted the problem - some HikVision cams send out not full sprop-parameter-sets (without PPS) in SDP.
For example, normal sprop-parameter-sets is
sprop-parameter-sets=Z0IAH5W4PASaEAAAcIAAFfkAQA==,aM48gA==
and the wrong is
sprop-parameter-sets=Z0IAH5WoPASaEAAAcIAAFfkIQA==,
Just to test if it's the only issue i hardcoed normal parameter-sets string in FFmpeg source and tested it out:
--- a/libavformat/rtpdec_h264.c
+++ b/libavformat/rtpdec_h264.c
@@ -101,6 +101,7 @@ int ff_h264_parse_sprop_parameter_sets(AVFormatContext *s,
uint8_t decoded_packet[1024];
int packet_size;
+ value = "Z0IAH5W4PASaEAAAcIAAFfkAQA==,aM48gA==";
while (*value) {
char *dst = base64packet;
The result was positive and NGINX successfully made a playable HLS stream. Now i'm thinking of making a normal patch with sprop-parameter-sets string validation to FFmpeg.
Made a patch to FFmpeg - ignoring invalid sprop-parameter-sets
--- a/libavformat/rtpdec_h264.c
+++ b/libavformat/rtpdec_h264.c
@@ -168,6 +168,10 @@ static int sdp_parse_fmtp_config_h264(AVFormatContext *s,
int ret;
+ if (value[strlen(value) - 1] == ',') {
+ av_log(s, AV_LOG_WARNING, "Missing PPS in sprop-parameter-sets, ignoring\n");
+ return 0;
+ }
codec->extradata_size = 0;
av_freep(&codec->extradata);
ret = ff_h264_parse_sprop_parameter_sets(s, &codec->extradata,
&codec->extradata_size, value);
av_log(s, AV_LOG_DEBUG, "Extradata set to %p (size: %d)\n",
Fantasic work! :+1:
Is the patch available now? I can have several video models for testing.
The patch is applied since RC6
Hey, @yangpu! Is the issue resolved?
Sorry for late responding. I could not download docker image because docker.io has been blocked in China in these days until I have buying a proxy.
Good news is your latest image works fine for my HikVision video :
rtsp://admin:admin123@192.168.0.27:554/Streaming/Channels/1
One additional issue is that no voice has been played by restreamer, but VLC does with the same url.
Hello, same issue here with another Hikvision ipcam model (DS-2CD3145F-I). Stream looks like the following: rtsp://admin:passwd@ip/Streaming/Channels/101 and works fine in VLC.
tried with port 554
rtsp://admin:passwd@ip:554/Streaming/Channels/101
worked fine in VLC too but it wont work with restreamer....
Piping ffmpeg from andrew-shulgin works in bash, and i can see the patch inside the configfile(v0.1.0-rc.7.1) but the patch won't work for us?
any new suggestions?
best regards
@andrew-shulgin I have testing two models of IPC, and DS-2DC2202I-DE3/W is working, the other DS-2CD3310D-I desn't work.
Could you help to identify the issue?
@yangpu Sorry, but I currently don't have resources for Open Source projects. Possibly, audio does not work because camera is streaming audio with PCM codec and Restreamer doesn't support reencoding. You could try to grab and push video with FFmpeg manually and see if there are any error messages.
I was facing the exact issue. I got it to work by adding -rtsp_transport tcp to my command, still not sure how? Maybe someone else here can explain this.
@zeeshancornelius FFmpeg first tries using UDP protocol, then if it fails it goes with TCP. But this switch make the stream analyzing process fail (very probably a FFmpeg bug). Instead, by forcing TCP from the start everything works as it should
@KodeKooker thanks for your detailed answer
hey I Have the same issue like yangpu...
can you give some ideas?
I also am experiencing weak HIKVision compliance with H264 data streams, the only workaround I found was not to analyze the header but the full frame.
@Zac610: Also got a Hikvision and the stream doesn't want to start in Restreamer. is this "not analyze the header but the full frame" thing a ffmpeg related option?
@pastelidis: They mention a ffmpeg patch, now is mid 2019, so the patch in latest Restreamer ffmpeg should be applied? Edit: ffmpeg version 4.1.3 used in latest Restreamer (0.4.0), the ffmpeg 4.1.3 source includes the patch: https://github.com/FFmpeg/FFmpeg/blob/n4.1.3/libavformat/rtpdec_h264.c#L170
@strarsis Still not fixed in 4.2.1 here
I believe this is because ffmpeg sends PAUSE
method which is not supported by my stream provider.
method PAUSE failed: 551 Option not supportedaout_close_audio() aout_set_volume() UDP timeout, retrying with TCP method PAUSE failed: 551 Option not supported CSeq: 8 Session: 1164688763 Date: Fri, Oct 09 2020 16:18:41 GMT
UDP timeout, retrying with TCP method PAUSE failed: 551 Option not supported CSeq: 9 Session: 1164688763 Date: Fri, Oct 09 2020 16:18:52 GMT
UDP timeout, retrying with TCP method PAUSE failed: 551 Option not supported
I am currently streaming from the webcam using ffmpeg directly (as a systemd unit so it is autostarted/restarted as proper service).
I have a IP video from HIKVision, and it can be accessed in VLC with url:
However restreamer doesn't work on this video source as output: