I am considering using ffmpeg to realize the processing of live video.
Assume up to two rtmp inputs.The challenge is to encode the output video even if there is only one source.The output video is supposed to be 720x540, and 360x540 images are placed on the left and right sides.
Input is assumed to be upstream from a smartphone.If one input is received, the encoding will start, and if the second input is received, Overlay will be overwritten.
Please let me know if there is any way to encode even one source.
cam1rtmp [on--------------------------------------------- off]
cam2rtmp [offxxxxxxxon ------------------------------------------------------------------------------------------------------------------------------
We expect this kind of behavior.ffmpeg does not start encoding until the cam2 source comes in.The expected value is that cam2 is displayed as nullsrc.
To sum up the questions,
·I want to overlay using ffmpeg
·Up to two sources, but sometimes one
·The output will not start unless two sources are aligned, so I want to start Encode when one source is included.
·Expect nullsrc for one source
$ffmpeg-irtmp://localhost/live/1\
-irtmp://localhost/live/2\
-filter_complex"nullsrc=size=720x540[base];[0:v]scale=360x540[v1];[1:v]scale=360x540[v2];\
[base] [v1] overlay = 0:0 [tmp1]; [tmp1] [v2] overlay = 360:0"\
-preset fast-c:vlibx264-c:aac-strict-2-fflvrtmp://local host/live/livestream
If you know how to solve this problem, could you please let me know?
ffmpeg
I haven't tried the rtmp source yet, but
Skip it as nullsrc when it's turned off and overwrite it to the same output destination when it's turned on.
If you output it first, it will be switched with an error, so it might work.
Also, it's faster to arrange two items in overlay by hstack.(I don't know if there is a difference between live broadcasting.)
In some cases, you may need to reset (setpts=PTS-STARTPTS) with setpts.
$ffmpeg-flavfi-inullsrc=size=360x540-preset fast-c:vlibx264-c:aac-strict-2\
- fflv rtmp://local host/live2/livestream
$ ffmpeg-irtmp://localhost/live/1\
-irtmp://localhost/live/2\
-filter_complex[0:v][1:v]hstack, scale=720:540
-preset fast-c:vlibx264-c:aac-strict-2-fflvrtmp://local host/live/livestream
If you don't mind OBS, you can arrange it side by side with the VLC video source.
© 2024 OneMinuteCode. All rights reserved.