I've been trying to use ffmpeg to stream my webcam's video to YouTube and so far all I've managed was an "acknowledgement" from YouTube saying 'Starting' in green. However it quickly goes gray and the actual stream never actually changes from offline.
I'm using this command to try to stream it:
ffmpeg -rtbufsize 1500M -r 25 -f dshow -s 1280x720 -i video="USB2.0 HD UVC WebCam" -vcodec h264 -b:a 600k -acodec libfaac -ab 128k -f flv "rtmp://a.rtmp.youtube.com/live2/user.useruser.codecodecode"
CMD
I've managed to stream videos to YouTube with ffmpeg, its just the camera that won't work. Any idea what I might be doing wrong?
This is the command I'm using now
ffmpeg -r 18 -f dshow -s 1280x720 -i video="USB2.0 HD UVC WebCam":audio="Microphone (Realtek High Definition Audio)" -vcodec h264 -b:v 1800k -acodec aac -strict experimental -f flv "rtmp://a.rtmp.youtube.com/live2/useruser.useruser.codecodecodecode"
I'm now using -acodec aac
instead of libfaac or libfdk_aac since I was getting "Unknown encoder" errors
It is streaming a few seconds however, now I'm getting these errors: WriteN, RTMP send error 10053
Any idea what these mean, or how to fix them?
If you have a webcamera with IP address with full HD x264 video source, without audio and you want to stream your direct camera screen to YouTube, you do not need to transcode/reencode video to a lower resolution always. YouTube can accept some camera's direct video stream. The only thing is that you must do it add an extra empty/silent audio track. If you have enough bandwith at your network it should be work.
I am using this CLI command on a Pine64+ with Ubuntu 16.04 and it is working:
ffmpeg -re -rtsp_transport tcp -i "rtsp://<user>:<pass>@<camera_ip>:<port>" /
-f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 /
-c:a libmp3lame -ab 128k -ar 44100 /
-c:v copy -threads 2 -bufsize 512k /
-f flv "rtmp://a.rtmp.youtube.com/live2/<your-live-stream-key>"
(Here is some info about Libavfilter input virtual device: https://www.ffmpeg.org/ffmpeg-devices.html#lavfi)
With this, you can forward the direct camera screen with silent audio to YouTube with minimal CPU usage.
Some restrictions:
In both case ffpmeg could not detect the network or streams issue. So if you would like to stream a neverending stream it is hard to automatize correctly.
Temporarily I am using a small cron job at the moment which restarting ffmpeg in every hours.
There are a few things wrong with your command:
You don't have an audio stream. When using dshow
you also need to specify audio
as explained here.
ffmpeg -f dshow -i video="Integrated Camera":audio="Microphone name here"
If you don't intend to capture audio then put a silent audio track.
-b:a
is the same thing as -ab
- the audio bitrate. You must use -b:v
to specify the video bitrate. 600k
is too low for a 1280x720px @ 25fps H.264
video stream.
YouTube recommends:
720p
Video Bitrate Range: 1,500 - 4,000 Kbps
You should put at least 1800k
.
Concerning the audio you're using libfaac
. For the best results when encoding AAC
it's recommended to use libfdk_aac
Live streaming an IP Camera to Youtube using FFmpeg. - For Ubuntu users (what I did)
Install latest ffmpeg on ubuntu 12.04 or 14.04 https://gist.github.com/xdamman/e4f713c8cd1a389a5917 and
Compile FFmpeg on Ubuntu https://gist.github.com/faleev/3435377
Open Youtube. Login. Click on My Channel > Video Manager > LIVE STREAMING . Note “Stream name/key” .
For static video file:
ffmpeg -re -i "(input-file)" -acodec libmp3lame -ar 44100 -b:a 128k -pix_fmt yuv420p -profile:v baseline -s 426x240 -bufsize 2048k -vb 400k -maxrate 800k -deinterlace -vcodec libx264 -preset medium -g 30 -r 30 -f flv "rtmp://a.rtmp.youtube.com/live2/(Stream name/key)"
For streaming video from IP camera with rtsp video only output:
ffmpeg -re -i input-file -rtsp_transport tcp -i "rtsp://password@(streamaddress with local IP)" -acodec libmp3lame -ar 44100 -b:a 128k -pix_fmt yuv420p -profile:v baseline -s 426x240 -bufsize 2048k -vb 400k -maxrate 800k -deinterlace -vcodec libx264 -preset medium -g 30 -r 30 -f flv "rtmp://a.rtmp.youtube.com/live2/(Stream name/key)"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With