Trying to use decklink output from ffmpeg's libavdevice in a C++ app

364 views Asked by At

I'm trying to add support for decklink devices in an video streaming app that my company is developing. We're using C++ and FFMpeg as a processing library. Other types of inputs and outputs are working. Adding support for decklink inputs was really easy, it just worked (at least with the device we tested it on - DeckLink SDI Quad). But for outputs... I'm fighting this for 3 days as of now with no results. I cannot find any docs for this, neither I can find any code example, how should I initialize AVFormatContext and other parts that are needed.

By reading FFMpeg's decklink avdevice code, I managed to get to the point that AVFormatContext doesn't complain about incorrect data format anymore. I'm using wrapped_avframe and pcm_s16le as a codecs, I'm setting (converting) video and audio params to values accepted by device, I'm sending AVPackets with av_interleaved_write_frame, and it doesn't work. Couple of packets are being accepted, couple of libDeckLinkAPI.so threads are spawned, and it just locks - my output thread locks on some 80-ish call to av_interleaved_write_frame. And it is a deadlock, it never goes any further. Debugger shows only that it is waiting for something:

#0  futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x7fe34c0402c8) at ../sysdeps/nptl/futex-internal.h:183
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x7fe34c040178, cond=0x7fe34c0402a0) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x7fe34c0402a0, mutex=0x7fe34c040178) at pthread_cond_wait.c:638
#3  0x00007fe35c69bd04 in ?? () from /lib/libDeckLinkAPI.so
#4  0x00007fe371394ac7 in ?? () from /lib/libavdevice.so.58
#5  0x00007fe370f249ad in ?? () from /lib/libavformat.so.58
#6  0x00007fe370f26615 in av_interleaved_write_frame () from /lib/libavformat.so.58

I'm obviously doing something wrong, but I can't find what... Can anyone point me to some documentation or (working) code example how it should be done?

Thanks in advance :)

0

There are 0 answers