[FFmpeg-user] HW Acceleration 101? 2-Up Streaming from RTSP-->ffmpeg-->YouTube

Steven Kan steven at kan.org
Tue Jan 19 00:34:33 EET 2021


> On Jan 18, 2021, at 12:50 PM, Michael Koch <astroelectronic at t-online.de> wrote:
> 
> Am 18.01.2021 um 21:20 schrieb Steven Kan:
>>> On Jan 18, 2021, at 10:58 AM, Michael Koch <astroelectronic at t-online.de> wrote:
>>> 
>>> Am 18.01.2021 um 19:18 schrieb Steven Kan:
>>>> But now I want to do a “2-Up” live stream of two different cameras, side-by-side. Here’s an archive from last night (waiting for a mating pair of Barn Owls to move in):
>>>> 
>>>> https://www.youtube.com/watch?v=GDN2MjPwn0Q&feature=youtu.be <https://www.youtube.com/watch?v=GDN2MjPwn0Q&feature=youtu.be>
>>>> 
>>>> The cameras are each outputting 1920 x 1080 @ 25 fps.
>>>> 
>>>> Now that I’m actually encoding, I need a lot more CPU/GPU. I’m running this in Win10 Pro/64 on an HP Microserver with an AMD Opteron X3418 Quad-Core, and the CPU runs at about ~65-80% while the integrated GPU runs at about ~55%.
>>>> 
>>>> C:\Program Files\ffmpeg\bin> .\ffmpeg.exe -re -thread_queue_size 1024 -i rtsp://anonymous:password@192.168.1.47:554 <rtsp://anonymous:password@192.168.1.47:554> -i rtsp://anonymous:password@192.168.1.50:554 <rtsp://anonymous:password@192.168.1.50:554> -vcodec h264_amf -acodec copy -t 01:47:02 -filter_complex "nullsrc=size=3840x1080 [base]; [0:v] setpts=PTS-STARTPTS, scale=1920x1080 [upperleft]; [1:v] setpts=PTS-STARTPTS, scale=1920x1080 [upperright]; [base][upperleft] overlay=shortest=1 [tmp1]; [tmp1][upperright] overlay=shortest=1:x=1920" -f flv "rtmp://a.rtmp.youtube.com/live2/my-youtube-streaming-key <rtmp://a.rtmp.youtube.com/live2/my-youtube-streaming-key>”
>>> Wouldn't it be easier to use something like
>>> [upperleft][upperright] hstack
>> It might be. I didn’t know hstack existed :D. When I googled ‘ffmpeg 2-up” the nullsrc/overlay examples were the first ones I found :D
>> 
>> I tried hstack, and I’m not getting at all the results I expect. On my Windows machine I get "Conversion failed!” error, whereas the same command with '-filter_complex “nullsrc . . . .’ does not fail:
>> 
>> C:\Program Files\ffmpeg\bin> .\ffmpeg.exe -re -thread_queue_size 1024 -i rtsp://anonymous:password@192.168.1.47:554 -i rtsp://anonymous:password@192.168.1.50:554 -vcodec h264_amf -acodec copy -t 01:47:02 -filter_complex hstack=inputs=2 -f flv out.flv
>> 
>> [snip

>> Input #0, rtsp, from 'rtsp://anonymous:password@192.168.1.47:554':
>>  Metadata:
>>    title           : Media Server
>>  Duration: N/A, start: 0.080000, bitrate: N/A
>>    Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 1920x1080, 25 fps, 25 tbr, 90k tbn, 180k tbc
>> Input #1, rtsp, from 'rtsp://anonymous:password@192.168.1.50:554':
>>  Metadata:
>>    title           : Media Server
>>  Duration: N/A, start: 0.100000, bitrate: N/A
>>    Stream #1:0: Video: h264 (Main), yuv420p(progressive), 1920x1080, 100 tbr, 90k tbn, 180k tbc
> 
> I see that the two streams have different pixel formats yuvj420p and yuv420p. You could try to bring them to the same pixel format before using hstack.
> [0]format=yuv420p[a];[a][1]hstack
> 
> It's only a wild guess, I'm not sure.

Do I put this into the filter_complex argument, e.g. -filter_complex "[0]format=yuv420p[a];[a][1] hstack=inputs=2” 

That still results in the "Conversion failed!” error.

Curiouser and curiouser. 

If I change -vcodec h264_amf to -vcodec libx264 with hstack, then i don’t get a “Conversion failed!” error. But the CPU goes to 100% and the speed never exceeds 0.5x, so it’s not a useful solution. But it does show that the -vcodec argument might be a part of the problem.

But -vcodec h264_amf worked just fine with the  -filter_complex “nullsrc=. . . . method, and it fails with hstack.




More information about the ffmpeg-user mailing list