[Libav-user] Multithreading - not able to create threads - ffmpeg

Ierum Shanaya ierumshanaya85 at gmail.com
Mon Aug 4 20:36:20 CEST 2014


Hi All,

My aim is to decode video on sniper simulator using ffmpeg. For this I am
using the demuxing_decoding.c with few changes , like addition of
thread_count in function main,

/*sample snippet*/
in function main()
{
...........

if (open_codec_context
<https://ffmpeg.org/doxygen/trunk/demuxing__decoding_8c.html#a85e44b1a7e74c90b84b2298caefb5f73>
(&video_stream_idx
<https://ffmpeg.org/doxygen/trunk/demuxing__decoding_8c.html#af35f69f407b98b5244f837e25813bc11>,
fmt_ctx, AVMEDIA_TYPE_VIDEO
<https://ffmpeg.org/doxygen/trunk/group__lavu__misc.html#gga9a84bba4713dfced21a1a56163be1f48ac1a46f59be5c6c2d3412ab172d6b8cf5>)
>= 0) {
256  video_stream = fmt_ctx->streams
<https://ffmpeg.org/doxygen/trunk/structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348>
[video_stream_idx
<https://ffmpeg.org/doxygen/trunk/demuxing__decoding_8c.html#af35f69f407b98b5244f837e25813bc11>
];
 257  video_dec_ctx = video_stream->codec
<https://ffmpeg.org/doxygen/trunk/structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96>
;


*/*NEW ADDITION TO CREATE THREADS - set the thread count*/*

*video_dec_ctc->thread_count = 3;*

.............
}

This is to create 4 threads for decoding video.

I am compiling the program using the command
gcc -o demuxDecode demuxing_decoding.c -lavutil -lavformat -lavcodec -lz
-lavutil -lm -lpthread

Now comes the actual problem:

The threads are not getting created.. I am not able to understand the
problem, since on other machine ( 64 bit laptop's) its happening and not on
mine.

I have a 64 bit Ubuntu 12.04 installed on my system.
The sniper simulator is simulating 4 cores, but since ffmpeg is not
creating the threads, the 4 cores are not getting used. Only 1 thread is
getting created.

I have the gcc version 4,6,3 installed,

----------------------------------------------------------------------------------------------------------------
ierumshanaya at ubuntu:/usr/local/lib$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.6 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--enable-gnu-unique-object --enable-plugin --enable-objc-gc
--disable-werror --with-arch-32=i686 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)

----------------------------------------------------------------------------------------------------------------
*I have checked for the libpthread.a and libpthread.so library files also,
and they are present in the path*

---------------------------------------------------------------------------------------------------------------
ierumshanaya at ubuntu:/usr/local/lib$ locate libpthread
/home/ierumshanaya/.local/share/Trash/files/pin-2.13-65163-gcc.4.4.7-linux/source/tools/Probes/tpss_lin_libpthread.cpp
/home/ierumshanaya/sescutils/build-mipseb-linux/obj/glibc-build/linuxthreads/libpthread.a
/home/ierumshanaya/sescutils/install/mipseb-linux/lib/libpthread.a
/home/ierumshanaya/sniper-5.3/pin_kit/pin-2.13-61206-gcc.4.4.7-linux/source/tools/Probes/tpss_lin_libpthread.cpp
/home/ierumshanaya/sniper-5.3/pin_kit/source/tools/Probes/tpss_lin_libpthread.cpp
/lib/x86_64-linux-gnu/libpthread-2.15.so
/lib/x86_64-linux-gnu/libpthread.so.0
/lib32/libpthread-2.15.so
/lib32/libpthread.so.0
/usr/lib/x86_64-linux-gnu/libpthread.a
/usr/lib/x86_64-linux-gnu/libpthread.so
/usr/lib/x86_64-linux-gnu/libpthread_nonshared.a
/usr/lib32/libpthread.a
/usr/lib32/libpthread.so
/usr/lib32/libpthread_nonshared.a
/usr/share/doc/libpthread-stubs0
/usr/share/doc/libpthread-stubs0-dev
/usr/share/doc/libpthread-stubs0/changelog.Debian.gz
/usr/share/doc/libpthread-stubs0/copyright
/usr/share/doc/libpthread-stubs0-dev/README
/usr/share/doc/libpthread-stubs0-dev/changelog.Debian.gz
/usr/share/doc/libpthread-stubs0-dev/copyright
/var/lib/dpkg/info/libpthread-stubs0-dev:amd64.list
/var/lib/dpkg/info/libpthread-stubs0-dev:amd64.md5sums
/var/lib/dpkg/info/libpthread-stubs0:amd64.list
/var/lib/dpkg/info/libpthread-stubs0:amd64.md5sums

-----------------------------------------------------------------------------------------------------------------------

*My question now is -*

1) Is gcc not able to link the pthread library and hence not able to create
threads??
2) Or, is gcc linking it from the lib32 directory and not usr/local/lib and
since it is a 64bit machine, this is happening. Then how to solve this
issue???

3) Since the code is able to create threads on some systems of my friends,
it is for sure that adding thread_count is working. So, where is the
problem.

Can someone please give me some pointers.

Thanks,
Ierum
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20140805/ffa08a4a/attachment.html>


More information about the Libav-user mailing list