Stream RTSP from ONVIF general camera to Youtube - ffmpeg

I have a wifi camera that uses RTSP/ONVIF protocol and after reading FFMPEG docs and some threads at Google I am trying to broadcast the stream to Youtube. So I started a broadcast at youtube and in my computer in ffmpeg I executed this command:
ffmpeg -f lavfi -i anullsrc -rtsp_transport udp -i rtsp://200.193.21.176:6002/onvif1 -tune zerolatency -vcodec libx264 -t 12:00:00 -pix_fmt + -c:v copy -c:a aac -strict experimental -f flv rtmp://x.rtmp.youtube.com/live2/private_key
The command above looks like it's correct cause it ouputs constantly something like this:
The problem is that at YOUTUBE it still says I am offline. Why?

Try replace first part to: ffmpeg -re -i somefile.mp4, so you will to know, if here any problems with your camera or not.
ffmpeg and VLC very similar and even uses same code for codecs. But RTSP it handles differently. But try just ffmpeg -i rtsp://200.193.21.176:6002/onvif1 and nothing more as source.

Related

ffmpeg RTP audio multicast stream choppy

I'm trying to stream .wav audio files via RTP multicast. I'm using the following command:
ffmpeg -re -i Melody_file.wav -f rtp rtp://224.0.1.211:5001
It successfully initiates the stream. However, the audio comes out very choppy. Any ideas how I can make the audio stream clean? I do not need any video at all. Below is a screenshot of my output:
Here's some examples expanding upon the useful comments between #Ralf and #Ahmed about setting asetnsamples and aresample, and also those mentioned in the Snom wiki. Basically one can get smoother multicast transmission/playback using these approaches for G711/mulaw audio:
ffmpeg -re -i Melody_file.wav -filter_complex 'aresample=8000,asetnsamples=n=160' -acodec pcm_mulaw -ac 1 -f rtp rtp://224.0.1.211:5001
Or using higher quality G722 audio codec:
ffmpeg -re -i Melody_file.wav -filter_complex 'aresample=16000,asetnsamples=n=160' -acodec g722 -ac 1 -f rtp rtp://224.0.1.211:5001

FFMPEG udp stream to VLC

i've been trying to create a transport stream using FFMPEG, when i tried it in VLC it was working immediately, however when i stream from FFMPEG to VLC i can't get it to work, here's my string:
ffmpeg -re -i http://ip-of-shoutcast-stream:port?listen -c:a aac -b:a 128k -ar 44100 -ac 2 -vn -f mpegts udp://ip-of-destination-pc:1234?pkt_size=1316
In VLC i use the same network source i used when VLC was streaming in the main PC:
udp://ip-of-main-pc:1234
But it doesn't play or show any errors, the orange bar only goes back and forth endlessly.
What am i doing wrong in the FFMPEG and/or VLC side? It has to be FFMPEG since it's getting moved to a server.

Sending BlackMagic DeckLink Studio 4K over RTMP streams with FFmpeg

I'm trying to send a stream of video that's coming into a BlackMagic DeckLink Studio 4K capture card over a few different RTMP streams at once with FFmpeg. The command that I am doing it with is this:
ffmpeg -re -format_code Hi59 -f decklink -i 'DeckLink Studio 4K' -map 0 -flags +global_header -vcodec libx264 -crf 25 -preset medium -pix_fmt yuv422p -acodec aac -f tee "[f=flv]rtmp://ip1/live/test|[f=flv]rtmp://ip2/live/test.
However, whenever I send this video out, I just get color bars when looking at the stream. I tried using a different video source (the testsrc supplied by FFmpeg), and that sends out fine over RTMP to multiple stream destinations.
Is there something weird with how tee and the decklink stuff work in FFmpeg? Or is there an issue with my command?
If you see colors bars, that means that ffmpeg is connecting to the card and streaming fine but the card is giving the bars. Your command says that ffmpeg is expecting 1920X1080#29.97 interlaced, make sure that is the format into the Decklink. You can also try explicitly setting the connection type, example:
ffmpeg -re -format_code Hi59 -video_input sdi -f decklink -i 'DeckLink Studio 4K' -map 0 -flags +global_header -vcodec libx264 -crf 25 -preset medium -pix_fmt yuv422p -acodec aac -f tee "[f=flv]rtmp://ip1/live/test|[f=flv]rtmp://ip2/live/test
If you are still running into issues, make sure that the BlackMagic software can see the video signal, and it's the format you expect.
One last thing to check, if its an HDMI input make sure it is not HDCP; it's not supported.

ffmpeg how to record and preview at the same time

I want to capture video+audio from directshow device like webcam and stream it to RTMP server. This part no problem. But the problem is that I want to be able to see the preview of it. After a lot of search someone said pipe the input using tee muxer to ffplay. but I couldn't make it work. Here is my code for streaming to rtmp server. how should I change it?
ffmpeg -rtbufsize 8196k -framerate 25 -f dshow -i video="Microsoft® LifeCam Studio(TM)":audio="Desktop Microphone (Microsoft® LifeCam Studio(TM))" -vcodec libx264 -acodec aac -strict -2 -b:v 1024k -b:a 128k -ar 48000 -s 720x576 -f flv "rtmp://ip-address-of-my-server/live/out"
Here is the final code I used and it works.
ffmpeg -rtbufsize 8196k -framerate 25 -f dshow -i video="Microsoft® LifeCam Studio(TM)":audio="Desktop Microphone (Microsoft® LifeCam Studio(TM))" -vcodec libx264 -acodec aac -strict -2 -f tee -map 0:v -map 0:a "[f=flv]rtmp://ip-address-and-path|[f=nut]pipe:" | ffplay pipe:
The core command for those running ffmpeg on a Unix-compatible system (e.g. MacOS, BSD and GNU-Linux) is really quite simple. It's to redirect or to "pipe" one of the outputs of ffmpeg to ffplay. The main problem here is that ffmpeg cannot autodetect the media format (or container) if the output doesn't have a recognizable file extension such as .avi or .mkv.
Therefore you should specify the format with the option -f. You can list the available choices for option -f with the ffmpeg -formats command.
In the following GNU/Linux command example, we record from an input source named /dev/video0 (possibly a webcam). The input source can also be a regular file.
ffmpeg -i /dev/video0 -f matroska - filename.mkv | ffplay -i -
A less ambiguous way of writing this for non-Unix users would be to use the special output specifier pipe.
ffmpeg -i /dev/video0 -f matroska pipe:1 filename.mkv | ffplay -i pipe:0
The above commands should be enough to produce a preview. But to make sure that you get the video and audio quality you want, you also need to specify, among other things, the audio and video codecs.
ffmpeg -i /dev/video -c:v copy -c:a copy -f matroska - filename.mkv | ffplay -i -
If you choose a slow codec like Google's AV1, you'd still get a preview, but one that stutters.

Streaming interruption issue

I am trying to send audio/video streams to justin.tv using the following command:
ffmpeg -i Engl_01.avi -re -acodec copy -ar 22050 -vcodec libx264 -f flv rtmp://live.justin.tv/app/live_.....
It works well for Linux but doesn't work under MS Windows 7: the site (justin.tv) shows me a movie with interruptions, why is this? Is there any option allowing ffmpeg to fix this problem for Windows?

Resources