FFmpeg to YouTube via RTSP

boyessen

n3wb
Joined
Jan 14, 2020
Messages
3
Reaction score
0
Location
17930
I've searched and can't find this simple answer, I even posted this as a job on freelancer.com with no successful proposals.

I'm trying to stream my hikvision DS-2CD2347G1 to YouTube with FFmpeg.
I'm able to stream to YouTube, but the command line I'm using inserts a blank audio stream.
My camera has audio, and I would like to modify the FFmpeg CMD line to include the audio.

My current CMD line is: ffmpeg -f lavfi -i anullsrc -rtsp_transport udp -i rtsp:/username:password@192.168.0.63:554/Streaming/channels/101 -tune zerolatency -vcodec libx264 -t 12:00:00 -pix_fmt + -c:v copy -c:a aac -ar 44100 -strict experimental -f flv rtmp:/a.rtmp.youtube.com/live2/YouTube Stream Code

according to IP Camera RTSP Stream to Youtube Live
the line I'm using inserts a blank audio with the filter anullsrc, but I can't figure out how to remove that filter and still have the code function correctly.
also according to that site, if I need audio they recommend:
ffmpeg -i rtsp:/IPaddress -vcodec copy -acodec copy -f flv rtmp:/a.rtmp.youtube.com/live2/your stream name
but YouTube doesn't accept that stream at all

My target result:
 

bp2008

Staff member
Joined
Mar 10, 2014
Messages
12,676
Reaction score
14,024
Location
USA
I'm not familiar with a lot of those ffmpeg options.

But the first one you have is a mess. It is saying to copy the video stream, and also providing video encoding parameters. It doesn't know what it wants to be.

Try the second shorter command with -acodec aac instead of -acodec copy
 

boyessen

n3wb
Joined
Jan 14, 2020
Messages
3
Reaction score
0
Location
17930
I appreciate your reply.
I think you nailed it! That seems too simple. . The command you suggested below works great. It even cut my bit rate from 1100 down to 450kbits/s

ffmpeg -i rtsp:/user:password@192.168.0.63:554/Streaming/channels/101 -vcodec copy -acodec aac -f flv rtmp:/a.rtmp.youtube.com/live2/YouTube Stream

My only concern is YouTube now displays the error:
"Please use a keyframe frequency of four seconds or less. Currently, keyframes are not being sent often enough, which will cause buffering. The current keyframe frequency is 16.7 seconds. Note that ingestion errors can cause incorrect GOP (group of pictures) sizes"


bp2008: I see you also use Blue Iris, I tried the webcast on BlueIris, which worked well with audio, but the video was very pixelated/blurred even when I tried "Quality 100 %" and increased the Max Bitrate
 

bp2008

Staff member
Joined
Mar 10, 2014
Messages
12,676
Reaction score
14,024
Location
USA
I'm guessing your i-frame interval configured in the camera is much shorter than that? Make sure no "smart codec" or "+" version of the codec is enabled in the camera's settings.

I've never tried youtube casting from Blue Iris, but if increased quality and bit rate didn't fix it then I don't know what will. BTW, quality 100% is extremely excessive.
 

SamM

Pulling my weight
Joined
Mar 29, 2020
Messages
245
Reaction score
109
Location
SA
Hi

Is there a way to stream via the Hik NVR instead of directly from the camera?
 
Top