How to stream Hik 2032 to Youtube Live

Ardith

n3wb
Joined
Dec 15, 2015
Messages
5
Reaction score
7
Location
Rome
I have the 2042 version, I think it's the same thing...

(Windows system)
Enable youtube live: https://www.youtube.com/live_dashboard
Download (and then extract) ffmpeg: https://ffmpeg.org/
Go to bin folder, then create a .bat file with this line:
ffmpeg -f lavfi -i anullsrc -rtsp_transport tcp -i rtsp://admin:password@CAMIP:554 -tune zerolatency -vcodec libx264 -pix_fmt + -c:v copy -c:a aac -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/YOUTUBELIVEKEY
You can get the key from the dashboard (reveal):

600-YouTube-EncoderSetUp.png

If you have problems after a few minutes you have to reduce the cam bitrate.

Of course, youtube bitrate will be limited by the upload speed of your internet connection if cam bitrate > upload speed.
 
Last edited by a moderator:

sparc

n3wb
Joined
Jan 30, 2016
Messages
6
Reaction score
1
Thank you Ardith. This works beautifully on a Hikvision 2DE7184-A, you can send it the Main Stream or Sub Stream (if your camera allows) using this slight modification to the URL.

rtsp://admin:password@CAMIP:554/Streaming/Channels/101 - Main Stream
rtsp://admin:password@CAMIP:554/Streaming/Channels/102 - Sub Stream

My feed is online @
http://www.youtube.com/user/sparc500/live if anyone wants to see the quality produced. Sending a 1080p stream @ 2048Kbps Bitrate with 20Fps.
 
Last edited by a moderator:

sparc

n3wb
Joined
Jan 30, 2016
Messages
6
Reaction score
1
Thanks Ardith and sparc - this works perfectly with my 2432 and 2332 cameras.
You are welcome. I could never get mine totally stable streaming for more than a week, but I may have been doing something wrong or there were some instabilities in the WiFi link between the camera & the house. Glad it worked for you.

-sparc
 

Ardith

n3wb
Joined
Dec 15, 2015
Messages
5
Reaction score
7
Location
Rome
You are welcome. I could never get mine totally stable streaming for more than a week, but I may have been doing something wrong or there were some instabilities in the WiFi link between the camera & the house. Glad it worked for you.

-sparc
I have the same problem... we need to find a way to restart the stream/.bat file when the the communication between camera and PC is interrupted.
 

sparc

n3wb
Joined
Jan 30, 2016
Messages
6
Reaction score
1
I have the same problem... we need to find a way to restart the stream/.bat file when the the communication between camera and PC is interrupted.
I tried so many things over the course of two months. I ran it in Windows, ran it Ubuntu.. I had mine set to reboot daily, it would still hang at some point. I analyzed the ffmpeg logs, and it appears it was having problems with the keyframe I think? Like it never received it. I tried increasing the buffer, decreasing FPS, increasing FPS, decreasing resolution, adjusting audio rate, all sorts of buffer settings in ffmpeg. I ended up subscribing to IPCamLive with a $15/mo subscription, because it "just worked" and it was an important stream for me. They are able to pull my RTSP stream 24/7 for 2 months without so much as a single disconnection. I wish I knew their secret! YouTube Live has so much potential. I would recommend trying out https://obsproject.com/ for your YouTube Live streams instead of just plain ffmpeg. I did not get the chance to extensively test it, but it has potential.
 

sparc

n3wb
Joined
Jan 30, 2016
Messages
6
Reaction score
1
I tried so many things over the course of two months. I ran it in Windows, ran it Ubuntu.. I had mine set to reboot daily, it would still hang at some point. I analyzed the ffmpeg logs, and it appears it was having problems with the keyframe I think? Like it never received it. I tried increasing the buffer, decreasing FPS, increasing FPS, decreasing resolution, adjusting audio rate, all sorts of buffer settings in ffmpeg. I ended up subscribing to IPCamLive with a $15/mo subscription, because it "just worked" and it was an important stream for me. They are able to pull my RTSP stream 24/7 for 2 months without so much as a single disconnection. I wish I knew their secret! YouTube Live has so much potential. I would recommend trying out https://obsproject.com/ for your YouTube Live streams instead of just plain ffmpeg. I did not get the chance to extensively test it, but it has potential.
Also, I wish ffmpeg would just crash when the stream has issues.. that way I could have an automated process restart it.. but it just hangs with high CPU in Linux. I kill the task & my monitor restarts it.. Sometimes it lasts 6 hours, 6 days or 2 weeks.. Crazy.
 

Speed666

Getting the hang of it
Joined
Sep 19, 2015
Messages
167
Reaction score
91
Also, I wish ffmpeg would just crash when the stream has issues.. that way I could have an automated process restart it.. but it just hangs with high CPU in Linux. I kill the task & my monitor restarts it.. Sometimes it lasts 6 hours, 6 days or 2 weeks.. Crazy.
I got it straight from camera. Works now at 720p@25 @2Mbps on E-Series.
Proof:
hikstream.jpg
 

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,329
Reaction score
5,325
Location
Denver, CO
try adding -rtsp_transport tcp to your ffmpeg options, see if that helps.. udp is notorious for dropping frames on you and ffmpeg defaults to udp by default.
 

wxman

Pulling my weight
Joined
Feb 15, 2015
Messages
631
Reaction score
163
Location
Southern United States
I got it straight from camera. Works now at 720p@25 @2Mbps on E-Series.
Proof:
View attachment 10424
Not sure what all this means, but are you saying that you're streaming directly from the camera to youtube, without a computer in between? (ie. using the camera's operating system to encode the video in a youtube-readable format)?

If so, I'd love some instructions on how to do it...That's really my ultimate goal because if I have to keep a dedicated computer running 24/7, then may as well just keep the camera's video on-screen and use a free screen capture software to send it to Youtube...A way to send directly from the cam to Youtube and cutting out the extra dedicated computer would be ideal, as it would save on electricity costs, etc...
 

wxman

Pulling my weight
Joined
Feb 15, 2015
Messages
631
Reaction score
163
Location
Southern United States
As a second note, I can't even get it the FFMPEG script to work at all with my computer...It gives me this error message:


ffmpeg version N-71346-gdf4fca2 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l
ibilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enab
le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --en
able-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --ena
ble-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc
--enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enabl
e-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --ena
ble-decklink --enable-zlib
libavutil 54. 22.101 / 54. 22.101
libavcodec 56. 34.100 / 56. 34.100
libavformat 56. 30.100 / 56. 30.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 13.101 / 5. 13.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
[NULL @ 0000000002d1aca0] Unable to find a suitable output format for 'C:\Docume
nts and Settings\Administrator\My Documents\FFMPEG\bin\webcam.sh'
C:\Documents and Settings\Administrator\My Documents\FFMPEG\bin\webcam.sh: Inva
lid argument
 

Speed666

Getting the hang of it
Joined
Sep 19, 2015
Messages
167
Reaction score
91
What is the camra model? And Yes, i stream directly from camera.
 

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,329
Reaction score
5,325
Location
Denver, CO
Unable to find a suitable output format for 'C:\Docume
nts and Settings\Administrator\My Documents\FFMPEG\bin\webcam.sh'
C:\Documents and Settings\Administrator\My Documents\FFMPEG\bin\webcam.sh: Inva
lid argument

your trying to run a bash shell in windows, good luck w/that.
 

wxman

Pulling my weight
Joined
Feb 15, 2015
Messages
631
Reaction score
163
Location
Southern United States
Unable to find a suitable output format for 'C:\Docume
nts and Settings\Administrator\My Documents\FFMPEG\bin\webcam.sh'
C:\Documents and Settings\Administrator\My Documents\FFMPEG\bin\webcam.sh: Inva
lid argument

your trying to run a bash shell in windows, good luck w/that.
I've got the Git for Windows installed and it was working fine with other .ss bash scripts in the past...Including this particular script given on this thread. While I never could get it to work with Youtube, it would save the live stream to my computer as a file if I changed the youtube address in that script to a local directory......Now it's just giving me that "no suitable output format" error.
 

wxman

Pulling my weight
Joined
Feb 15, 2015
Messages
631
Reaction score
163
Location
Southern United States
Paste this script here.
ffmpeg -f lavfi -i anullsrc -rtsp_transport tcp -i rtsp://admin:password@CAMIP:554 -tune zerolatency -vcodec libx264 -pix_fmt + -c:v copy -c:a aac -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/YOUTUBELIVEKEY



 

wxman

Pulling my weight
Joined
Feb 15, 2015
Messages
631
Reaction score
163
Location
Southern United States
but would much rather go directly from the cam to youtube without the need for a computer...

Would it be possible to install FFMPEG to the cameras built in drive using Telnet?
 
Top