I am using this below command to stream on multiple output it works fine till 2 outputs but when I added third output it's giving an error-
command for 2 output-
ffmpeg_stream = 'ffmpeg -thread_queue_size 1024 -f x11grab -draw_mouse 0 -s 1920x1080 -i :122 -f alsa -i pulse -ac 2 -c:a aac -b:a 64k -threads 0 -flags +global_header -c:v libx264 -pix_fmt yuv420p -s 1920x1080 -threads 0 -f tee -map 0:0 -map 1:0 "[f=flv]rtmps://live-api-s.facebook.com:443/rtmp/stream_key|[f=flv]rtmp://a.rtmp.youtube.com/live2/stream_key"'
command for 3 outputs-
ffmpeg_stream = 'ffmpeg -thread_queue_size 1024 -f x11grab -draw_mouse 0 -s 1920x1080 -i :122 -f alsa -i pulse -ac 2 -c:a aac -b:a 64k -threads 0 -flags +global_header -c:v libx264 -pix_fmt yuv420p -s 1920x1080 -threads 0 -f tee -map 0:0 -map 1:0 -map 2:0 "[f=flv]rtmps://live-api-s.facebook.com:443/rtmp/stream_key|[f=flv]rtmp://a.rtmp.youtube.com/live2/stream_key|[f=flv]rtmp://play.stream.some_domain/stream/i48b-rdq0-jwme-2yj0"'
error-
liveStreaming | Invalid input file index: 2.
error with custom rtmp url only-
liveStreaming | [rtmp # 0x55af7e7f8280] Server error: Already
publishing
liveStreaming | [tee # 0x55af7e12f540] Slave '[f=flv]rtmp://stream.domain/stream/i48b-rdq0-jwme-2yj0': error opening: Operation not permitted
liveStreaming | [tee # 0x55af7e12f540] Slave muxer #1 failed, aborting.
liveStreaming | [flv # 0x55af7e4d1880] Failed to update header with correct duration.
liveStreaming | [flv # 0x55af7e4d1880] Failed to update header with correct filesize.
liveStreaming | Could not write header for output file #0 (incorrect codec parameters ?): Operation not permitted
liveStreaming | Error initializing output stream 0:1 --
liveStreaming | [aac # 0x55af7e1346c0] Qavg: -nan
liveStreaming | [alsa # 0x55af7e111dc0] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
liveStreaming | Conversion failed!
Thank you
-map is used to add input streams for output. You have only 2 inputs. For the 3rd output using tee, you just need to add it inside the output URL like you already did. Remove -map 2:0
ffmpeg_stream = 'ffmpeg -thread_queue_size 1024 -f x11grab -draw_mouse 0 -s 1920x1080 -i :122 -f alsa -i pulse -ac 2 -c:a aac -b:a 64k -threads 0 -flags +global_header -c:v libx264 -pix_fmt yuv420p -s 1920x1080 -threads 0 -f tee -map 0:0 -map 1:0 "[f=flv]rtmps://live-api-s.facebook.com:443/rtmp/stream_key|[f=flv]rtmp://a.rtmp.youtube.com/live2/stream_key|[f=flv]rtmp://play.stream.some_domain/stream/i48b-rdq0-jwme-2yj0"'
Related
I have try stream with ffmpeg with output to differents rtmp servers like that
ffmpeg -re -i nameoffile.mp4 -vcodec libx264 -g 60 -c:a aac -b:a 160k -ar 44100 -strict -2 -f flv \
-f flv rtmp://rtmp.1.com/code \
-f flv rtmp://rtmp.2.com/code \
-f flv rtmp://rtmp.3.com/code \
-f flv rtmp://rtmp.4.com/code \
-f flv rtmp://rtmp.5.com/code \
The problem is... is working only the first one but not the others
You have to set the output options for each output: -vcodec libx264 -g 60 -c:a aac -b:a 160k -ar 44100
I have this ffmpeg script I'm running to automatically convert videos to instagram's accepted coded
The script looks like this:
ffmpeg -analyzeduration 20M -probesize 20M -y -re -f lavfi -i "movie=filename='file.mp4':loop=5, setpts=N/(FRAME_RATE*TB)" -vcodec libx264 -b:v 3500k -vsync 2 -t 59 -acodec aac -b:a 128k -pix_fmt yuv420p -vf "scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(ow-iw)/2:(oh-ih)/2:white" -crf 24 new_file.mp4
However that seems to cut out the audio, and I can't seem to find out how to prevent that? I didn't use any -an or anything, and when messing around the audio keeps being cut out? Any idea why?
The movie filter, by default, only reads one video stream from the input.
For looping, stream_loop is available without having to use filters.
ffmpeg -analyseduration 20M -probesize 20M -y -re -stream_loop 5 -i "file.mp4" -vcodec libx264 -b:v 3500k -vsync cfr -t 59 -acodec aac -b:a 128k -pix_fmt yuv420p -vf "scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(ow-iw)/2:(oh-ih)/2:white" -crf 24 new_file.mp4
I'm having a slight issue trying to sync my audio and video up with an acceptable margin of error. Here is my command:
ffmpeg -y -thread_queue_size 9999 -indexmem 9999 -guess_layout_max 0 -f dshow -video_size 3440x1440 -rtbufsize 2147.48M ^
-framerate 100 -pixel_format nv12 -i video="Video (00 Pro Capture HDMI 4K+)":audio="SPDIF/ADAT (1+2) (RME Fireface UC)" ^
-map 0:0,0:1 -map 0:1 -flags +cgop -force_key_frames expr:gte(t,n_forced*2) -c:v h264_nvenc -preset: llhp -pix_fmt nv12 ^
-b:v 250M -minrate 250M -maxrate 250M -bufsize 250M -c:a aac -ar 44100 -b:a 384k -ac 2 -r 100 -af "aresample=async=250" ^
-vsync 1 -max_muxing_queue_size 9999 -f segment -segment_time 600 -segment_wrap 9 -reset_timestamps 1 ^
C:\Users\djcim\Videos\PC\PC\PC%02d.ts
My problem is the video comes in slightly ahead of the audio, I can use -itsoffset but then I have to call the video and audio as separate inputs as -itsoffset offsets both audio and video. While this may seem the obvious solution it causes inconsistent audio synchronization if the audio isn't called with the video. Basically if both audio and video aren't called at the same time the video can now be ahead or behind with a 2-3 frame margin. When I call them at the same time the video consistently comes in 2 frames ahead of the audio, every time. I just need a way to delay only the video stream without delaying the audio while keeping both audio and video linked from the beginning. I've tried this with no luck:
ffmpeg -y -thread_queue_size 9999 -indexmem 9999 -guess_layout_max 0 -f dshow -video_size 3440x1440 -rtbufsize 2147.48M ^
-framerate 200 -pixel_format nv12 -i video="Video (00 Pro Capture HDMI 4K+)":audio="SPDIF/ADAT (1+2) (RME Fireface UC)" ^
-flags +cgop -force_key_frames expr:gte(t,n_forced*2) -c:v h264_nvenc -preset: llhp -pix_fmt nv12 -b:v 250M ^
-minrate 250M -maxrate 250M -bufsize 250M -c:a aac -ar 44100 -b:a 384k -ac 2 -r 100 ^
-filter_complex "[0:v] setpts=PTS-STARTPTS+.032/TB [v]; [0:a] asetpts=PTS-STARTPTS, aresample=async=250 [a]" -map [v] ^
-map [a] -vsync 1 -max_muxing_queue_size 9999 -f segment -segment_time 600 -segment_wrap 9 -reset_timestamps 1 ^
C:\Users\djcim\Videos\PC\PC\PC%02d.ts
Just like -itsoffset both video and audio are being delayed. You can delay solely audio with adelay, but there doesn't seem to be a video delaying equivalent.
Any help or advice would be greatly appreciated.
As stated by Gyan in the comments, atrim worked. While it isn't delaying the video it is still lining everything up by ditching part of the audio stream.
ffmpeg - y -thread_queue_size 9999 -indexmem 9999 -guess_layout_max 0 -f dshow -video_size 3440x1440 -rtbufsize 2147.48M ^
-framerate 200 -pixel_format nv12 -i video="Video (00 Pro Capture HDMI 4K+)":audio="SPDIF/ADAT (1+2) (RME Fireface UC)" ^
-map 0:0,0:1 -map 0:1 -flags +cgop -force_key_frames expr:gte(t,n_forced*2) -c:v h264_nvenc -preset: llhp -pix_fmt nv12 ^
-b:v 250M -minrate 250M -maxrate 250M -bufsize 250M -c:a aac -ar 44100 -b:a 384k -ac 2 -r 100 ^
-af "atrim=0.038, asetpts=PTS-STARTPTS, aresample=async=250" -vsync 1 -ss 00:00:01.096 -max_muxing_queue_size 9999 ^
-f segment -segment_time 600 -segment_wrap 9 -reset_timestamps 1 C:\Users\djcim\Videos\PC\PC\PC%02d.ts
I have two long audio files. I want to merge cut some part from each video
and merge both parts in one file.
In below command the problem there is no audio in the second audio part. It contain the first part and the second is empty.
What is the problem?
ffmpeg -f lavfi -i color=c=black
-ss 157.824 -t 99.818
-i "file1.mp4"
-ss 315.764 -t 50.308
-i "file2.mp4"
-s 854x480
-aspect 1.779167
-r 25
-c:v libx264
-b:v 800k
-c:a aac
-strict experimental
-b:a 128k
-f mp4
-t 150.126 -async 1
-y "output.mp4"
I need silent Opus audio files range of 1 second to 60 minutes.
I found this example for wav files:
60 seconds of silent audio in WAV:
ffmpeg -ar 48000 -t 60 -f s16le -acodec pcm_s16le -ac 2 -i /dev/zero
-acodec copy output.wav
60 seconds of silent audio in MP3:
ffmpeg -ar 48000 -t 60 -f s16le -acodec pcm_s16le -ac 2 -i /dev/zero
-acodec libmp3lame -aq 4 output.mp3
How can I do it for opus with using ffmpeg or similar tool?
Using a recent build of ffmpeg, run
ffmpeg -f lavfi -i anullsrc -ac 2 -ar 48000 -t 30 -c:a libopus file.opus
You can add -vbr 0 -b:a 128k for a CBR encode.