FFmpeg DeckLink capture doesn't work

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

FFmpeg DeckLink capture doesn't work

Rik Roukens
Hi all,

Apologies if i'm breaking any rules or do anything wrong, first time I've
joined and posted to a mailing list.

I've been spending the last 48 hours troubleshooting this problem, but am
getting a bit stuck.

Pre-info: I'm running an Ubuntu 18.04 server with a DeckLink Duo 2 card
inside.

Goal: Capture video from the DeckLink Duo 2 and write it to output.avi

What I've tried so far:

I've installed BMD DeckLink drivers 10.11.4 on my Ubuntu Server and
verified they server can see the card:

    redacted@redacted:~$ BlackmagicFirmwareUpdater status
    0: /dev/blackmagic/io0 [DeckLink Duo 2] 0xd5 OK
    1: /dev/blackmagic/io2 [DeckLink Duo 2] 0xd5 OK
    2: /dev/blackmagic/io1 [DeckLink Duo 2] 0xd5 OK
    3: /dev/blackmagic/io3 [DeckLink Duo 2] 0xd5 OK

I've compiled ffmpeg with decklink and the following configuration:

    ffmpeg version 4.1.3 Copyright (c) 2000-2019 the FFmpeg developers
    built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
    configuration:
    --prefix=/home/redacted/ffmpeg_build
    --pkg-config-flags=--static
    --extra-cflags='-I/home/redacted/ffmpeg_build/include
-I/home/redacted/ffmpeg_sources/BMD_SDK/include'
    --extra-ldflags=-L/home/redacted/ffmpeg_build/lib
    --extra-libs='-lpthread -lm'
    --bindir=/home/redacted/bin
    --enable-gpl
    --enable-libass
    --enable-libfdk-aac
    --enable-libfreetype
    --enable-libmp3lame
    --enable-libopus
    --enable-libvorbis
    --enable-libvpx
    --enable-libx264
    --enable-libx265
    --enable-nonfree
    --enable-decklink

Next I do a basic check to see if my DeckLink Duo 2 shows up in ffmpeg:

    [decklink @ 0x5574cc33ef00] Blackmagic DeckLink input devices:
    [decklink @ 0x5574cc33ef00] 'DeckLink Duo (1)'
    [decklink @ 0x5574cc33ef00] 'DeckLink Duo (2)'
    [decklink @ 0x5574cc33ef00] 'DeckLink Duo (3)'
    [decklink @ 0x5574cc33ef00] 'DeckLink Duo (4)'
    dummy: Immediate exit requested

This confirms the card is seen by ffmpeg.

So now I want to run a capture command, however, it does not matter what
command I run, FFmpeg does not start capturing. For example, running a very
basic:

    "ffmpeg -format_code Hi50 -f decklink -i 'DeckLink Duo (1)' out.avi"

returns:

    redacted@redacted:~$ ffmpeg -format_code Hi50 -f decklink -i 'DeckLink
    Duo (1)' out.avi
    ffmpeg version 4.1.3 Copyright (c) 2000-2019 the FFmpeg developers
    built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
    configuration: --prefix=/home/redacted/ffmpeg_build
--pkg-config-flags=--static -
    -extra-cflags='-I/home/redacted/ffmpeg_build/include -
    I/home/redacted/ffmpeg_sources/BMD_SDK/include' --extra-ldflags=-
    L/home/redacted/ffmpeg_build/lib --extra-libs='-lpthread -lm' --
    bindir=/home/redacted/bin --enable-gpl --enable-libass
--enable-libfdk-aac --
    enable-libfreetype --enable-libmp3lame --enable-libopus
--enable-libvorbis --
    enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
--enable-
    decklink
    libavutil      56. 22.100 / 56. 22.100
    libavcodec     58. 35.100 / 58. 35.100
    libavformat    58. 20.100 / 58. 20.100
    libavdevice    58.  5.100 / 58.  5.100
    libavfilter     7. 40.101 /  7. 40.101
    libswscale      5.  3.100 /  5.  3.100
    libswresample   3.  3.100 /  3.  3.100
    libpostproc    55.  3.100 / 55.  3.100
    [decklink @ 0x5638a755d000] Found Decklink mode 1920 x 1080 with rate
25.00(i)

running the command with -loglevel trace gives me the following output:

redacted@redacted:~$ ffmpeg -loglevel trace -raw_format yuv422p10 1 -an
    -
    format_code Hp25 -f decklink -i 'DeckLink Duo (2)' output.avi
    ffmpeg version 4.1.3 Copyright (c) 2000-2019 the FFmpeg developers
    built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
    configuration: --prefix=/home/redacted/ffmpeg_build
--pkg-config-flags=--static
    -
    -extra-cflags='-I/home/redacted/ffmpeg_build/include -
    I/home/redacted/ffmpeg_sources/BMD_SDK/include' --extra-ldflags=-
    L/home/redacted/ffmpeg_build/lib --extra-libs='-lpthread -lm' --
    bindir=/home/redacted/bin --enable-gpl --enable-libass
--enable-libfdk-aac --
    enable-libfreetype --enable-libmp3lame --enable-libopus
--enable-libvorbis --
    enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
--enable-
    decklink
    libavutil      56. 22.100 / 56. 22.100
    libavcodec     58. 35.100 / 58. 35.100
    libavformat    58. 20.100 / 58. 20.100
    libavdevice    58.  5.100 / 58.  5.100
    libavfilter     7. 40.101 /  7. 40.101
    libswscale      5.  3.100 /  5.  3.100
    libswresample   3.  3.100 /  3.  3.100
    libpostproc    55.  3.100 / 55.  3.100
    Splitting the commandline.
    Reading option '-loglevel' ... matched as option 'loglevel' (set
logging
    level) with argument 'trace'.
    Reading option '-raw_format' ... matched as AVOption 'raw_format' with
    argument 'yuv422p10'.
    Reading option '1' ... matched as output url.
    Reading option '-ac' ... matched as option 'ac' (set number of audio
    channels) with argument '2'.
    Reading option '-format_code' ... matched as AVOption 'format_code'
with
    argument 'Hp25'.
    Reading option '-f' ... matched as option 'f' (force format) with
argument
    'decklink'.
    Reading option '-i' ... matched as input url with argument 'DeckLink
Duo
    (2)'.
    Reading option 'output.avi' ... matched as output url.
    Finished splitting the commandline.
    Parsing a group of options: global .
    Applying option loglevel (set logging level) with argument trace.
    Successfully parsed a group of options.
    Parsing a group of options: input url DeckLink Duo (2).
    Applying option ac (set number of audio channels) with argument 2.
    Applying option f (force format) with argument decklink.
    Successfully parsed a group of options.
    Opening an input file: DeckLink Duo (2).
    [decklink @ 0x55cef7de7300] Trying to find mode for frame size 0x0,
frame
    timing 0/0, field order 0, direction 0, mode number 0, format code Hp25
    [decklink @ 0x55cef7de7300] Found Decklink mode 1920 x 1080 with rate
25.00
    [decklink @ 0x55cef7de7300] Using 2 input audio channels

It doesn't matter how complicated I make the initial command, with video
formats, audio formats, custom sizes, codecs, etc. It all returns the same.

It essentially stays stuck in this position, with the command still running
forever. To the best of my knowledge, FFmpeg is supposed to start the
encoding process straight after. It does not.

I can confirm that a normal re-encoding command such as:

    redacted@redacted:~$ ffmpeg -i video.mov out.avi

works just fine. So FFmpeg at a basic level works.

I can also confirm FFmpeg can 'talk to the DeckLink and set the right mode,
I can confirm a picture 'flows' through the card as I can see it showing up
on the output loop on my monitor(see image) as soon as I put any of the
FFmpeg commands in, however, FFmpeg does not start encoding/capturing.

I think I've done something wrong with the configuration/compiling of
FFmpeg, perhaps during compiling, but I cannot figure out what I've done
wrong.

Any suggestions are much appreciated.

Thanks,

Rik

--










The information in this email and in any attachments is
confidential and may be privileged. If you are not the intended recipient,
please destroy this message, delete any copies held on your systems and
notify the sender immediately. You should not retain, copy or use this
email for any purpose, nor disclose all or any part of its contents to any
other person. Atlant Ocean Racing Spain SL, a company registered in Spain.
B76239177.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: FFmpeg DeckLink capture doesn't work

Reto Kromer-2
Rik Roukens wrote:

>Goal: Capture video from the DeckLink Duo 2 and write it to
>output.avi

Have you considered using vrecord?

  https://github.com/amiaopensource/vrecord

Hope this helps! Reto

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: FFmpeg DeckLink capture doesn't work

Rik Roukens
Thanks Reto,

I'll look into it!

However, I have just found the reason of my problem I was having.
I appears the card had frozen because (i think) I killed one of the capture
processes rather than exiting using [q]. It didn't come to my mind to
reboot my device
which i just did and now it is working.

Thanks all who looked at my email. Problem solved (for now).

Rik

On Thu, 1 Aug 2019 at 12:44, Reto Kromer <[hidden email]> wrote:

> Rik Roukens wrote:
>
> >Goal: Capture video from the DeckLink Duo 2 and write it to
> >output.avi
>
> Have you considered using vrecord?
>
>   https://github.com/amiaopensource/vrecord
>
> Hope this helps! Reto
>
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".

--










The information in this email and in any attachments is
confidential and may be privileged. If you are not the intended recipient,
please destroy this message, delete any copies held on your systems and
notify the sender immediately. You should not retain, copy or use this
email for any purpose, nor disclose all or any part of its contents to any
other person. Atlant Ocean Racing Spain SL, a company registered in Spain.
B76239177.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: FFmpeg DeckLink capture doesn't work

kumowoon1025
In reply to this post by Rik Roukens
Hey there,

> Apologies if i'm breaking any rules or do anything wrong, first time I've
> joined and posted to a mailing list.

> The information in this email and in any attachments is
> confidential and may be privileged. If you are not the intended recipient,
> please destroy this message, delete any copies held on your systems and
> notify the sender immediately. You should not retain, copy or use this
> email for any purpose, nor disclose all or any part of its contents to any
> other person. Atlant Ocean Racing Spain SL, a company registered in Spain.
> B76239177.

For starters, you can leave it there if you’d like but on a public mailing list signatures like this have little significance.

> So now I want to run a capture command, however, it does not matter what
> command I run, FFmpeg does not start capturing. For example, running a very
> basic:
>
>    "ffmpeg -format_code Hi50 -f decklink -i 'DeckLink Duo (1)' out.avi"
>
> returns:
>
>    redacted@redacted:~$ ffmpeg -format_code Hi50 -f decklink -i 'DeckLink
>    Duo (1)' out.avi
>    ffmpeg version 4.1.3 Copyright (c) 2000-2019 the FFmpeg developers
>    built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
>    configuration: --prefix=/home/redacted/ffmpeg_build
> --pkg-config-flags=--static -
>    -extra-cflags='-I/home/redacted/ffmpeg_build/include -
>    I/home/redacted/ffmpeg_sources/BMD_SDK/include' --extra-ldflags=-
>    L/home/redacted/ffmpeg_build/lib --extra-libs='-lpthread -lm' --
>    bindir=/home/redacted/bin --enable-gpl --enable-libass
> --enable-libfdk-aac --
>    enable-libfreetype --enable-libmp3lame --enable-libopus
> --enable-libvorbis --
>    enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
> --enable-
>    decklink
>    libavutil      56. 22.100 / 56. 22.100
>    libavcodec     58. 35.100 / 58. 35.100
>    libavformat    58. 20.100 / 58. 20.100
>    libavdevice    58.  5.100 / 58.  5.100
>    libavfilter     7. 40.101 /  7. 40.101
>    libswscale      5.  3.100 /  5.  3.100
>    libswresample   3.  3.100 /  3.  3.100
>    libpostproc    55.  3.100 / 55.  3.100
>    [decklink @ 0x5638a755d000] Found Decklink mode 1920 x 1080 with rate
> 25.00(i)
><><>snip<><><><
>
> It doesn't matter how complicated I make the initial command, with video
> formats, audio formats, custom sizes, codecs, etc. It all returns the same.
>
> It essentially stays stuck in this position, with the command still running
> forever. To the best of my knowledge, FFmpeg is supposed to start the
> encoding process straight after. It does not.

Are you sure it’s “running" though? Is there like mad disk I/O from ffmpeg after it seemingly falls into zombie mode?

I assume what’s happening is it takes too long or too much memory (probably the time is the bigger factor) for that first full “frame” comes in with the format you specified, for reasons I can only guess at right now. Maybe PCIe lanes not being allocated right so low throughput, etc?

For now I’d try leaving out the logging lest it causes any more delay, and increasing the buffer size for sync and the mux pre delay length to see if you can get any kind of success at all.

> I can confirm that a normal re-encoding command such as:
>
>    redacted@redacted:~$ ffmpeg -i video.mov out.avi
>
> works just fine. So FFmpeg at a basic level works.
>
> I can also confirm FFmpeg can 'talk to the DeckLink and set the right mode,
> I can confirm a picture 'flows' through the card as I can see it showing up
> on the output loop on my monitor(see image) as soon as I put any of the
> FFmpeg commands in, however, FFmpeg does not start encoding/capturing.
>
> I think I've done something wrong with the configuration/compiling of
> FFmpeg, perhaps during compiling, but I cannot figure out what I've done
> wrong.


That sounds a bit contradictory to me :P But if you're thinking ffmpeg is gobbling up all those frames (or would it be slices for interlaced? Maybe deinterlacing has a lot to do with it) just because it shows up on the monitor you’d be very mistaken. I mean it’s a freaking monitor, it’s doing what it’s supposed to be doing, it doesn’t tell you anything about how ffmpeg is holding up on its end.

Also, I probably should have brought this up first, but try compiling a more recent build. I searched the some of the commits and it looks like there have been several enhancements made to mitigate this very issue. Also you could add avresample, make some adjustments to the compiler flags (leave some libs out, enable lto, etc) and have it optimized to take in multiple streams of high-bit-rate video without a hiccup.

P.S. Did you attach a link to an image because I didn't get that.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: FFmpeg DeckLink capture doesn't work

Devin Heitmueller
In reply to this post by Rik Roukens
Hi Rik,

On Thu, Aug 1, 2019 at 6:56 AM Rik Roukens <[hidden email]> wrote:
> However, I have just found the reason of my problem I was having.
> I appears the card had frozen because (i think) I killed one of the capture
> processes rather than exiting using [q]. It didn't come to my mind to
> reboot my device
> which i just did and now it is working.

So I've definitely seen a case where the driver can (sometimes) get
stuck on subsequent runs if you use SIGKILL rather than shutting down
gracefully.  I actually run the following patch in production to avoid
the issue.

https://github.com/LTNGlobal-opensource/FFmpeg-ltn/commit/5af8dc7d617202884cb0c1a96d2d5ca43e30c254#diff-2b6afd955c43e1b123013d2cff5fc9b5

Now in the above case I've fixed it on the decklink output side, but I
wouldn't be shocked at all if the same basic issue was present on
capture as well.  At some point I'll probably have to reproduce the
issue on the capture side and come up with a comparable patch.

Devin

--
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".