ffmpeg only works 2 instances - ffmpeg

I have 3 usb web cameras. Im using Windows 7.
I have 3 usb web cameras
And I need to create 3 video streams:
ffmpeg -f dshow -i video="Full HD webcam" -vcodec libx264 -tune zerolatency -threads 0 -b 900k -f mpegts udp://localhost:1234
ffmpeg -f dshow -i video=”#device_pnp_\?\usb#vid_1908&pid_2311&mi_00#8&134fde2a&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global” -vcodec libx264 -tune zerolatency -threads 0 -b 900k -f mpegts udp://localhost:1233
ffmpeg -f dshow -i video="#device_pnp_\?\usb#vid_1908&pid_2311&mi_00#8&962d85&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global" -vcodec libx264 -tune zerolatency -threads 0 -b 900k -f mpegts udp://localhost:1232
But only works 2 any instances of video streams. When I try to create third video stream I get error:
I get error
Can anybody help me, please?
i tried to create 3 video streams, but could only create 2 instances of ffmpeg process.

Related

How to livestream a webcam to YouTube with FFmpeg?

I want to send the livestream of my webcam to YouTube. I can follow YouTube's guide up to step 8. "Stream Connection" tells me there is "No data" and the button "Go Live" remains unclickable. A screenshot of this situation can be seen at
As encoding software, I was planning on using FFmpeg because it can run from the target platform, a Raspberry Pi with Raspbian. A USB webcam supported by video4linux2 is used.
FFmpeg's wiki shows that streaming a file can be done with the following:
ffmpeg -re -i input.mkv \
-c:v libx264 -preset veryfast -maxrate 3000k \
-bufsize 6000k -pix_fmt yuv420p -g 50 -c:a aac -b:a 160k -ac 2 \
-ar 44100 -f flv rtmp://live.twitch.tv/app/<stream key>
I modified this command in the following ways:
1. It takes the video stream from the webcam with -f v4l2 -i /dev/video0.
2. It does not broadcast any audio with -an.
3. It broadcasts to YouTube's RTMP server, rtmp://a.rtmp.youtube.com/live2/<stream key>
The final version of the command is now:
RTMP_URL="rtmp://a.rtmp.youtube.com/live2"
STREAM_KEY="secr-etse-cret-secr"
OUTPUT=$RTMP_URL/$STREAM_KEY
ffmpeg -re -f v4l2 -i /dev/video0 \
-c:v libx264 -preset veryfast -maxrate 3000k \
-bufsize 6000k -pix_fmt yuv420p -g 50 -an \
-f flv $OUTPUT
When I run this command, I would expect that "Stream connection" would change to something else than "No data" after a few seconds, but that does not happen.
I have tried recording the stream to a local file with:
ffmpeg -re -f v4l2 -i /dev/video0 \
-c:v libx264 -preset veryfast -maxrate 3000k \
-bufsize 6000k -pix_fmt yuv420p -g 50 -an \
-f flv test.flv
This worked fine. That demonstrates to me that the issue is with getting the video stream accepted by YouTube.
The code below works very well using Windows, you may adjust to fit for your need
ffmpeg -loglevel debug -threads:v 2 -threads:a 8 -filter_threads 2 -thread_queue_size 512 -f dshow -i video="HP Wide Vision HD" -f dshow -i audio="Microphone Array (Realtek Audio)" -pix_fmt yuv420p -c:v libx264 -qp:v 19 -profile:v high -rc:v cbr_ld_hq -level:v 4.2 -r:v 60 -g:v 120 -bf:v 3 -refs:v 16 -f flv rtmp://youtube_stream_url/stream_key

FFmpeg - frame delays double after the audio was added

single video delays 49ms
ffmpeg -rtbufsize 100M -f dshow -i video="Logitech HD Webcam C270" -vcodec libx264 -r 30-g 5 -preset:v ultrafast -tune:v zerolatency -f rtsp rtsp://127.0.0.1:80/live/test
The delay was 100 ms after adding audio.
ffmpeg -rtbufsize 100M -f dshow -i video="Logitech HD Webcam C270":audio="麦克风 (HD Webcam C270)" -vcodec libx264 -g 5 -r 30 -acodec aac -preset:v ultrafast -tune:v zerolatency -f rtsp rtsp://127.0.0.1:80/live/tao
Is it normal? Is there any solution to reduce the delay?

Synchronization and concurrency for creating hls resolutions for Live Streaming

Is there a single command to transcode mp4 video + aac into HLS at multiple resolutions ?
I have a convert server, and I think to live stream multiple resolutions, I must create all resolutions at the same time and this process must be concurrent.
I raised this issue,because I do this process wtih running these below codes at 4 cmd seperately for creating 4 resolutions of a video examply at the same time:
1- 720p
ffmpeg -i 123.mp4 -c:a aac -strict experimental -c:v libx264 -s hd720 -aspect 16:9 -f hls -hls_list_size 0 -hls_time 2 720p/out.m3u8
2- 480p
ffmpeg -i 123.mp4 -c:a aac -strict experimental -c:v libx264 -s hd480 -aspect 16:9 -f hls -hls_list_size 0 -hls_time 2 480p/out.m3u8
3- 360p
ffmpeg -i 123.mp4 -c:a aac -strict experimental -c:v libx264 -s nhd -aspect 16:9 -f hls -hls_list_size 0 -hls_time 2 360p/out.m3u8
4- 200p
ffmpeg -i 123.mp4 -c:a aac -strict experimental -c:v libx264 -s cga -aspect 16:9 -f hls -hls_list_size 0 -hls_time 2 200p/out.m3u8
but doing in this way have some problems.
1- the .TS parts of each resolutions doesn't create with another resolutions part at the same time(this issue makes that in switching resolutions, player cannot seek to the continue of selected resolution,because that part doesn't create yet).
2- You have run some threads for each live streaming.
Here is the answer of mine,Note that you must be set -hls_time If you want the number part of each resolutions be same.
ffmpeg -re -i 123.mp4
-c:a aac -c:v libx264 -s hd480 -aspect 16:9 -f hls -hls_list_size 0 -hls_time 2 480p/out.m3u8
-c:a aac -c:v libx264 -s nhd -aspect 16:9 -f hls -hls_list_size 0 -hls_time 2 360p/out.m3u8
-c:a aac -c:v libx264 -s cga -aspect 16:9 -f hls -hls_list_size 0 -hls_time 2 200p/out.m3u8

FFMPEG HLS video speed is too fast

I am trying to make a .m3u8 hls playlist locally on my computer. I am using Windows 7, 32 bit.
I am a begginner of FFMPEG, and finally I combined some commands into this:
ffmpeg -re -rtbufsize 999999k -y -f dshow -video_size 640x360 -r 15 -i video="ManyCam Virtual Webcam" -c:v libx264 -crf 18 -profile:v main -maxrate 999999k -bufsize 99999k -pix_fmt yuv420p -flags -global_header -hls_time 10 -g 3 -hls_list_size 2 -hls_wrap 0 -start_number 1 D:\\stream\stream.m3u8 -tune zerolatency
The problem is that while playing the m3u8 playlist with VLC or a HLS player, the video speed is faster than normal.
If you need more info, please comment.
EDIT
If I play one of the .ts files, the problem is the same.
Thank you so much!

FFMpeg not printing SDP information to console

I was trying to create an FFMpeg stream and read it from VLC player, but I am getting an error saying SDP is required. However FFMpeg is not printing the SDP information to console as it is supposed to. How can I get the SDP file for the stream?
Here is the command I am using to stream
ffmpeg -f dshow -r 10000/1001 -i video="screen-capture-recorder" -vcodec libx264 -tune zerolatency -b 900k -f mpegts rtp://127.0.0.1:1234
I found out what I had done wrong. I was previously using this command:
ffmpeg -f dshow -r 10000/1001 -i video="screen-capture-recorder" -vcodec libx264 -tune zerolatency -b 900k -f mpegts rtp://127.0.0.1:1234
Which I changed to this:
ffmpeg -f dshow -r 10000/1001 -i video="screen-capture-recorder" -vcodec libx264 -tune zerolatency -b 900k -f rtp rtp://127.0.0.1:1234
I just changed "mpegts" to "rtp" since that is the protocol I was using.

Resources