[Libav-user] Multithread decode and scaler
wolverin
wolverin82 at mail.ru
Fri Aug 19 08:36:37 EEST 2022
Неllo
Please help me figure out how multithreading works in ffmpeg. I wrote my own code that takes the video from v4l2 MJPEG and streams it to the rtsp server in H264.
Everything is fine as long as the incoming and outgoing stream resolution is 640x480, but if the incoming is 1920x1080 and I do sws_scale, then decoding and scaling are very slow.
If I run ffmpeg from the command line, I see swscale errors, which means that sws_getContext is called 20 times, which means a queue of 20 scaling threads is created
Input #0, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: mjpeg, none(bt470bg/unknown/unknown), 640x480, 30 fps, 30 tbr, 1000k tbn
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[swscaler @ 0x14b8160] [swscaler @ 0x14c18b0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x14b8160] [swscaler @ 0x14df9b0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x14b8160] [swscaler @ 0x14fd790] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x14b8160] [swscaler @ 0x151b570] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x14b8160] [swscaler @ 0x1539350] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x14b8160] [swscaler @ 0x14c18b0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x14b8160] [swscaler @ 0x14db1a0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x14b8160] [swscaler @ 0x14f8f80] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x14b8160] [swscaler @ 0x1516d60] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x14b8160] [swscaler @ 0x15396f0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x14b8160] [swscaler @ 0x152d3d0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x14b8160] [swscaler @ 0x14c2060] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x14b8160] [swscaler @ 0x14dfe40] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x14b8160] [swscaler @ 0x14fdc20] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x14b8160] [swscaler @ 0x151ba00] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x14b8160] [swscaler @ 0x152d3d0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x14b8160] [swscaler @ 0x14c2060] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x14b8160] [swscaler @ 0x14dfe40] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x14b8160] [swscaler @ 0x14fdc20] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x14b8160] [swscaler @ 0x151ba00] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x14a0950] using cpu capabilities: ARMv6 NEON
[libx264 @ 0x14a0950] profile High 4:2:2, level 3.0, 4:2:2 8-bit
[libx264 @ 0x14a0950] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc_lookahead=0 rc=cbr mbtree=0 bitrate=500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=500 vbv_bufsize=1000 nal_hrd=none filler=0 ip_ratio=1.40 aq=0
Output #0, rtsp, to 'rtsp://localhost:554/cam':
Metadata:
encoder : Lavf59.25.100
Stream #0:0: Video: h264, yuv422p(tv, bt470bg/unknown/unknown, progressive), 640x480, q=2-31, 500 kb/s, 30 fps, 90k tbn
Metadata:
encoder : Lavc59.33.100 libx264
Side data:
cpb: bitrate max/min/avg: 500000/0/500000 buffer size: 1000000 vbv_delay: N/A
1. How to create a multithreading ffmpeg for sws_scale?
2. Does internal multithreading work for mjpeg decoding, for example in AVCodecContext? If not, what is the best way to create multithreading for decoding?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20220819/3876a867/attachment.htm>
More information about the Libav-user
mailing list