Don't kown how to make avdec_h264 working under multi-threads modes, seems not working with max-threads

wanted002 wanted002 at 163.com
Wed Mar 17 12:46:09 UTC 2021


Hi, all:
    I'm a newbie for gstreamer. I appreciate your wonderful work ! 
    My idea is reduce the video latency by optimizing the cost of CPU for
decoding . I'm now suffered with this problem and I need your help, thanks
very much~~. 
 
    This is my pipe line for receiving and decoding a remote rtp stream:
*====screen print start=====*
200390  200356 54 20:15 ?        00:01:05 /usr/bin/gst-launch-1.0 -v udpsrc
port=1991 caps="application/x-rtp, media=video" ! rtpjitterbuffer latency=20
! rtpmp2tdepay ! tsdemux name=demuxer demuxer. ! queue name=video_ch
max-size-buffers=0 max-size-time=0 ! h264parse ! queue name=dec0 !
avdec_h264 max-threads=2 skip-frame=1 ! videoconvert n-threads=4 !
xvimagesink display=:0 sync=false demuxer. ! queue name=audio_ch
max-size-buffers=0 max-size-time=0 ! aacparse ! avdec_aac ! audioconvert !
audioresample ! autoaudiosink
*====screen print end=====*

    But I found that avdec_h264 not woring under multi-threads, for which I
supposed 'max-threads' should be working. See the "top -H" print below, all
decoding work is loaded on the 200398 thread, named as "dec0". 
*====screen print start=====*
top -H | grep dec
 200398 root      20   0 1164484  69284  46408 S  57.9   0.9   0:42.92
dec0:src                                                                                                                                    
 200398 root      20   0 1161412  66248  43372 R  32.3   0.8   0:43.90
dec0:src                                                                                                                                    
 200398 root      20   0 1164484  69284  46408 S  82.6   0.9   0:46.41
dec0:src                                                                                                                                    
 200398 root      20   0 1161412  66248  43372 R  82.9   0.8   0:48.93
dec0:src                                                                                                                                    
 200398 root      20   0 1164484  69284  46408 S  59.0   0.9   0:50.73
dec0:src                                                                                                                                    
 200398 root      20   0 1164484  69284  46408 S  32.9   0.9   0:51.73
dec0:src                                                                                                                                    
 200398 root      20   0 1164484  69284  46408 S  24.4   0.9   0:52.47
dec0:src                                                                                                                                    
 200398 root      20   0 1164484  69284  46408 S  24.3   0.9   0:53.21
dec0:src                                                                                                                                    
 200398 root      20   0 1164484  69284  46408 S  24.0   0.9   0:53.94
dec0:src 
*====screen print end=====*

    This is the pstree print of the "parent PID" 200390, which is the
/usr/bin/gst-launch-1.0 program.

*====screen print start=====*
pstree -pt 200390
gst-launch-1.0(200390)─┬─{audio_ch:src}(200399)
                       ├─{audio_ch:src}(201471)
                       ├─{dec0:src}(200398)
                       ├─{dec0:src}(200405)
                       ├─{gmain}(200404)
                       ├─{gst-launch-1.0}(200397)
                       ├─{rtpjitterbuffer}(200402)
                       ├─{timer}(200401)
                       ├─{udpsrc0:src}(200403)
                       ├─{video_ch:src}(200400)
                       ├─{videoconvert}(200406)
                       ├─{videoconvert}(200407)
                       └─{videoconvert}(200408)
*====screen print end=====*

    And I debug thread 20045 , which is the sibling decoding thread of
200398, it seems to be blocked with : pthread_cond_wait since spawned.

Attaching to process 200390
[New LWP 200397]
[New LWP 200398]
[New LWP 200399]
[New LWP 200400]
[New LWP 200401]
[New LWP 200402]
[New LWP 200403]
[New LWP 200404]
[New LWP 200405]
[New LWP 200406]
[New LWP 200407]
[New LWP 200408]
[New LWP 201471]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
0x0000007f82ceedb8 in poll () from /lib/aarch64-linux-gnu/libc.so.6
(gdb) info threads
  Id   Target Id                                          Frame
* 1    Thread 0x7f83114790 (LWP 200390) "gst-launch-1.0"  0x0000007f82ceedb8
in poll () from /lib/aarch64-linux-gnu/libc.so.6
  2    Thread 0x7f7866e1e0 (LWP 200397) "gst-launch-1.0"  0x0000007f82cc541c
in clock_nanosleep () from /lib/aarch64-linux-gnu/libc.so.6
  3    Thread 0x7f77e6d1e0 (LWP 200398) "dec0:src"        0x0000007f82cf4760
in syscall () from /lib/aarch64-linux-gnu/libc.so.6
  4    Thread 0x7f776311e0 (LWP 200399) "audio_ch:src"    0x0000007f82cf4760
in syscall () from /lib/aarch64-linux-gnu/libc.so.6
  5    Thread 0x7f76e301e0 (LWP 200400) "video_ch:src"    0x0000007f82cf4760
in syscall () from /lib/aarch64-linux-gnu/libc.so.6
  6    Thread 0x7f7662f1e0 (LWP 200401) "timer"           0x0000007f82cf4760
in syscall () from /lib/aarch64-linux-gnu/libc.so.6
  7    Thread 0x7f75e2e1e0 (LWP 200402) "rtpjitterbuffer" 0x0000007f82cf4760
in syscall () from /lib/aarch64-linux-gnu/libc.so.6
  8    Thread 0x7f7562d1e0 (LWP 200403) "udpsrc0:src"     0x0000007f82ceedb8
in poll () from /lib/aarch64-linux-gnu/libc.so.6
  9    Thread 0x7f74e2c1e0 (LWP 200404) "gmain"           0x0000007f82ceedb8
in poll () from /lib/aarch64-linux-gnu/libc.so.6
  10   Thread 0x7f57fff1e0 (LWP 200405) "dec0:src"        0x0000007f82da6038
in pthread_cond_wait@@GLIBC_2.17 () from
/lib/aarch64-linux-gnu/libpthread.so.0
  11   Thread 0x7f574fe1e0 (LWP 200406) "videoconvert"    0x0000007f82cf4760
in syscall () from /lib/aarch64-linux-gnu/libc.so.6
  12   Thread 0x7f56cfd1e0 (LWP 200407) "videoconvert"    0x0000007f82cf4760
in syscall () from /lib/aarch64-linux-gnu/libc.so.6
  13   Thread 0x7f564fc1e0 (LWP 200408) "videoconvert"    0x0000007f82cf4760
in syscall () from /lib/aarch64-linux-gnu/libc.so.6
  14   Thread 0x7f554031e0 (LWP 201471) "audio_ch:src"    0x0000007f82ceedb8
in poll () from /lib/aarch64-linux-gnu/libc.so.6
(gdb) c
Continuing.


(gdb) bt
#0  0x0000007f83073038 in pthread_cond_wait@@GLIBC_2.17 () at
/lib/aarch64-linux-gnu/libpthread.so.0
#1  0x0000007f800c5cbc in  () at /lib/aarch64-linux-gnu/libavutil.so.56
#2  0x0000007f8306c4fc in start_thread () at
/lib/aarch64-linux-gnu/libpthread.so.0
#3  0x0000007f82fc530c in  () at /lib/aarch64-linux-gnu/libc.so.6



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/


More information about the gstreamer-devel mailing list