eckirchn
n3wb
- Jun 20, 2016
- 7
- 1
Here is my bash script that works with my camera. You will need to modify it to enter your camera's username, password, and IP address. Also specify what channel you want. I am using the 704x480 stream to pipe to youtube.
ffmpeg version 2.8.7 on Fedora 23 (4.5.6-200.fc23.x86_64)
The output should look something like this:
In windows, you will need to figure out the blank audio source (replacing "/dev/zero") and likely changing the audio encoder (you could try removing it, as ACC or mp3 is supported). Note, as I found out tonight, you NEED an audio channel, youtube will just tell you something like this:
I get this warning message, but i don't want to transcode the stream besides adding the blank audio stream, so I don't care:
Hope that helps everyone. The only issues here should be changing a couple things here to work for your Operating System, but that should be the easy part.
ffmpeg version 2.8.7 on Fedora 23 (4.5.6-200.fc23.x86_64)
#! /bin/bash
YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2" # Server URL
KEY="[ENTER YOUR KEY HERE]" # Stream name/key
ffmpeg \
-hide_banner \
-ar 44100 -acodec pcm_s16le -f s16le -ac 2 -channel_layout 2.1 -i /dev/zero \
-i rtsp://[ENTER YOUR CAMERA USER HERE]:[ENTER YOUR CAMERA PASSWORD HERE]@[ENTER YOUR CAMERA IP HERE]:554/Streaming/Channels/2?tcp \
-rtsp_transport tcp \
-ss 2 \
-c:v copy \
-c:a libmp3lame \
-shortest \
-f flv "$YOUTUBE_URL/$KEY"
The output should look something like this:
Input #0, s16le, from '/dev/zero': Duration: N/A, bitrate: 2116 kb/s
Stream #0:0: Audio: pcm_s16le, 44100 Hz, 2.1, s16, 2116 kb/s
Input #1, rtsp, from 'rtsp://user : password@192.168.1.10:554/Streaming/Channels/2?tcp':
Metadata:
title : Media Presentation
Duration: N/A, start: 0.191200, bitrate: N/A
Stream #1:0: Video: h264 (Main), yuv420p(tv, smpte170m), 704x480, 30 fps, 30 tbr, 90k tbn, 60 tbc
[flv @ 0xab33a0] Codec for stream 0 does not use global headers but container format requires global headers
Output #0, flv, to 'rtmp://a.rtmp.youtube.com/live2/-----------------------':
Metadata:
encoder : Lavf56.40.101
Stream #0:0: Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 704x480, q=2-31, 30 fps, 30 tbr, 1k tbn, 90k tbc
Stream #0:1: Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002), 44100 Hz, stereo, s16p
Metadata:
encoder : Lavc56.60.100 libmp3lame
Stream mapping:
Stream #1:0 -> #0:0 (copy)
Stream #0:0 -> #0:1 (pcm_s16le (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
frame=45584 fps= 30 q=-1.0 size= 189979kB time=00:25:21.19 bitrate=1023.1kbits/s
Stream #0:0: Audio: pcm_s16le, 44100 Hz, 2.1, s16, 2116 kb/s
Input #1, rtsp, from 'rtsp://user : password@192.168.1.10:554/Streaming/Channels/2?tcp':
Metadata:
title : Media Presentation
Duration: N/A, start: 0.191200, bitrate: N/A
Stream #1:0: Video: h264 (Main), yuv420p(tv, smpte170m), 704x480, 30 fps, 30 tbr, 90k tbn, 60 tbc
[flv @ 0xab33a0] Codec for stream 0 does not use global headers but container format requires global headers
Output #0, flv, to 'rtmp://a.rtmp.youtube.com/live2/-----------------------':
Metadata:
encoder : Lavf56.40.101
Stream #0:0: Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 704x480, q=2-31, 30 fps, 30 tbr, 1k tbn, 90k tbc
Stream #0:1: Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002), 44100 Hz, stereo, s16p
Metadata:
encoder : Lavc56.60.100 libmp3lame
Stream mapping:
Stream #1:0 -> #0:0 (copy)
Stream #0:0 -> #0:1 (pcm_s16le (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
frame=45584 fps= 30 q=-1.0 size= 189979kB time=00:25:21.19 bitrate=1023.1kbits/s
In windows, you will need to figure out the blank audio source (replacing "/dev/zero") and likely changing the audio encoder (you could try removing it, as ACC or mp3 is supported). Note, as I found out tonight, you NEED an audio channel, youtube will just tell you something like this:
8:46 PM No data No active stream
YouTube is not currently receiving data for this stream. If you believe this is incorrect, ensure you're sending a stream and that it is configured with the correct stream key.
YouTube is not currently receiving data for this stream. If you believe this is incorrect, ensure you're sending a stream and that it is configured with the correct stream key.
8:46 PM Good Stream is healthy
Stream health is excellent.
Stream health is excellent.
8:57 PM OK Check resolution
Please check the video resolution. The current resolution is (704x480), which is not optimal.
Please check the video resolution. The current resolution is (704x480), which is not optimal.
8:53 PM Good Stream is healthy
Stream health is excellent.
Stream health is excellent.
Hope that helps everyone. The only issues here should be changing a couple things here to work for your Operating System, but that should be the easy part.