Skip to main content

DeckLink SDI and ST 2110 capture and playout

The decklink_sdk source and sink capture from and play out to Blackmagic DeckLink cards through the DeckLink SDK. Use the source to encode an SDI or HDMI feed and publish it, and the sink to play a stream out to SDI for a monitor, router or broadcast chain. On DeckLink IP cards, the same source and sink capture and play out SMPTE ST 2110; see ST 2110 on DeckLink IP cards.

Compared with the older FFmpeg-based decklink type, decklink_sdk:

  • detects the incoming video format and follows format changes;
  • keeps outputs connected through signal loss if you choose to;
  • plays out against the card's clock, with drift correction and a configurable pre-roll;
  • selects the device by name or index and the connector (SDI, HDMI, optical);
  • exports per-device metrics;
  • refuses unsuitable input with a message that says what to change.

Use decklink_sdk for new configurations. See FFmpeg decklink type for existing ones.

Prepare the host​

  1. Install Blackmagic Desktop Video 15.3 or later on the host. It provides the kernel driver and /usr/lib/libDeckLinkAPI.so.
  2. In Desktop Video Setup, set the card's profile (for example full or half duplex) so that each sub-device used for capture or playout has the right direction.
  3. Confirm that the host detects the card and, for capture, that the input has signal.

Packager loads libDeckLinkAPI.so at startup. The library is not included in the images, so mount it from the host together with the device nodes:

bash
docker run -d --name packager-sdi \
--device /dev/blackmagic:/dev/blackmagic \
-v /usr/lib/libDeckLinkAPI.so:/usr/lib/libDeckLinkAPI.so:ro \
-v /usr/lib/blackmagic/DesktopVideo:/usr/lib/blackmagic/DesktopVideo:ro \
-v "$PWD/config.toml:/etc/packager/config.toml:ro" \
-p 127.0.0.1:4040:4040 \
"${PACKAGER_IMAGE:?Set PACKAGER_IMAGE}" start

Without the library, the decklink_sdk types do not exist and their tasks fail to start. A capture sub-device can be used by one process at a time.

Select the device​

Both the source and the sink select the card in protocol_options:

OptionTypeDefaultMeaning
devicestringUnsetDevice display name, exactly as the SDK reports it, such as DeckLink Duo (1). Takes precedence over device_index.
device_indexu_intUnsetPosition of the sub-device, from 0. Used when device is not set.
connectionstringCard's current settingConnector: sdi, hdmi, optical_sdi, component, composite, svideo, ethernet, optical_ethernet. Combine with +, as in sdi+ethernet for IP/SDI cards.

One of device and device_index is required. If the name does not match, the task fails with an error that lists the names of the available devices. Copy the exact name from there or from Desktop Video Setup.

toml
[[sources]]
id = "sdi"
source_type = "decklink_sdk"
protocol_options = { device = "DeckLink Duo (1)", connection = "sdi" }

Capture​

The source delivers raw video (uyvy422 or bgra, 8-bit) and PCM audio at 48 kHz. Add a transcoder to encode them, as in SDI to SRT, SDI to Vindral and SDI language tracks.

Capture options go in demuxer_options:

OptionTypeDefaultMeaning
format_codestringDetectPin a display mode instead of detecting it, such as 1080p50, 1080i50, 720p59.94, 4k50 or the SDK's four-letter code (Hp50).
pixel_formatstringuyvy422uyvy422 (8-bit YUV) or bgra (8-bit RGB).
channelsu_int2Embedded audio channels: 2, 8 or 16.
audio_depthu_int1616 gives pcm_s16le; 32 gives pcm_s32le and keeps the card's 24-bit samples. Use 32 unless something downstream needs 16-bit audio.
signal_loss_actionstringdropWhat to send while the input has no signal: drop (nothing), black_frame (the card's black frames) or last_frame (repeat the last picture).
ancillaryboolfalseCapture the ancillary data (ANC) in the video signal, such as timecode and closed captions, and publish it as an SMPTE ST 2038 data track.
toml
[[sources]]
id = "sdi"
source_type = "decklink_sdk"
protocol_options = { device = "DeckLink Duo (1)" }

[sources.demuxer_options]
channels = { type = "u_int", value = 8 }
signal_loss_action = "last_frame"
audio_depth = { type = "u_int", value = 32 }

Format detection. Without format_code, the source starts at the mode the card detects (or 1080p50) and locks to the incoming signal. If the mode or field order changes later, the source ends its stream and Packager restarts the pipeline at the new format. Expect a short interruption. With format_code, detection is off.

UHD modes are named 4k… in this option (for example 4k50, not 2160p50), and progressive SD modes are ntsc-p and pal-p.

Signal loss. With the default drop, a pulled cable stops video, and a MoQ or RTMP destination may disconnect the publisher after a few seconds. Set black_frame or last_frame to keep outputs connected through an outage.

Colour. SDI does not signal colourimetry, so the source tags video by its size: BT.709 above 576 lines, BT.601 (PAL/NTSC) below, limited range. bgra is tagged as full-range RGB.

Audio to NDI. The NDI sink accepts only pcm_s16le or pcm_f32le audio. With audio_depth = 32, put a transcoder with a pcm_f32le audio rendition between the DeckLink source and an NDI sink; connected directly, the sink fails at start.

Ancillary data such as timecode and closed captions is captured only with ancillary = true, as an ST 2038 data track that a transcoder can pass through with a data track. 10-bit capture is not supported.

Playout​

The sink plays one raw video track, at most one audio track and at most one ST 2038 data track, which it plays out as ancillary data with the video. It does no scaling or format conversion, so the transcoder in front of it must produce exactly what the card plays:

Requirement
Videocodec = "rawvideo", format = "uyvy422" or "bgra". Size, frame rate and interlacing must match a display mode the card supports, such as 1920×1080 at 50 fps progressive.
Audiopcm_s16le or pcm_s32le, 48 kHz, 2, 8 or 16 channels. Other channel counts, including 5.1, are refused; set channels = 2 or 8 in the rendition. Without an audio track, the sink plays video only.

A track's processing.max_frame_rate can lower a frame rate but not raise it, so the source must already have the display mode's rate. A transcoder outputs progressive video: by default it deinterlaces an interlaced input to twice its frame rate, so 1080i50 plays out as 1080p50, and with deinterlace = "disabled" the woven fields play as half-rate progressive frames (1080p25). Interlaced modes such as 1080i50 can only be played out by passing an interlaced decklink_sdk source through without a transcode. A mismatch fails the sink at start, with an error that lists the modes the card accepts.

toml
[[transcoders]]
id = "to-raw"
source_ids = ["input"]

[[transcoders.tracks]]
id = "video"
type = "video"
track_selector = { type = "track-kind", kind = "video" }

[[transcoders.tracks.renditions]]
id = "video-raw"
codec = "rawvideo"
format = "uyvy422"
size = { width = 1920, height = 1080 }

[[transcoders.tracks]]
id = "audio"
type = "audio"
track_selector = { type = "track-kind", kind = "audio" }

[[transcoders.tracks.renditions]]
id = "audio-pcm"
codec = "pcm_s32le"
sample_rate = 48_000
channels = 2

[[sinks]]
id = "sdi-out"
sink_type = "decklink_sdk"
source_ids = ["to-raw"]
wait_for_all_sources = true
protocol_options = { device = "DeckLink Duo (2)" }

[sinks.muxer_options]
preroll_frames = { type = "u_int", value = 20 }

See SRT to SDI for a complete configuration.

Playout options:

OptionMapTypeDefaultMeaning
sdi_levelprotocol_optionsstringCard's setting3G-SDI mapping for 1080p above 30 fps: a (Level A) or b (Level B). Ignored for other modes.
preroll_framesmuxer_optionsu_int400 ms of framesFrames queued before playback starts, and the minimum output latency. At most 128.
audio_stream_typemuxer_optionsstringtimestampedtimestamped places audio on the video timeline and keeps sync over long runs. continuous queues audio and lets the card resample it; continuous_dont_resample queues it unresampled.

Timing. The card is the clock. The sink schedules each frame on the card's timeline and corrects slow drift between the input and the card by repeating or dropping one frame, typically every few hours. If frames arrive late repeatedly, the sink raises its lead (up to twice the pre-roll or 400 ms) and logs a warning to raise preroll_frames. The default 400 ms rides through the stalls of a live RTMP or SRT input; a source that delivers evenly, such as a DeckLink input, can run lower.

Live input. Feed the sink from a live source. To play a file to SDI, push it into a live input with ffmpeg -re, for example over SRT or RTMP. If the input arrives slower than real time, the sink logs a warning and audio drops out.

E_ACCESSDENIED when the sink starts usually means another process uses the sub-device, or the card's profile configures it for capture only.

DeckLink IP cards, such as the DeckLink IP/SDI HD, carry uncompressed video (ST 2110-20), audio (ST 2110-30) and ancillary data (ST 2110-40) over the network. The card handles RTP and PTP itself, so capture and playout work as over SDI: the same decklink_sdk source and sink, with the same demuxer and muxer options. What the configuration adds is which flows the card receives and where it sends.

Flows are routed in one of two ways:

  • NMOS: the card registers as an NMOS node, and an NMOS controller connects senders to its receivers. The configuration then names no flows: capture follows whatever the controller routes to the card, and playout sends to the multicast groups the card holds.
  • In the configuration: the source subscribes to senders by their SDP, and the sink sets where each flow goes and writes the SDPs for receivers.

The card's address, PTP and NMOS registry belong to the card rather than to one pipeline. Set them with the decklink tool included in the Packager image (/app/decklink): decklink ip shows the Ethernet link, PTP and every flow with its SDP, and decklink ip configure changes the settings, for example decklink ip configure 0 --nmos-registry REGISTRY_HOST:PORT.

Capture​

OptionDescription
video_sdp, audio_sdp, ancillary_sdpThe sender to receive for each essence: the SDP itself, or an http, https or file URL or absolute path to fetch it from. Setting one selects the Ethernet input.
video_sdp_index, audio_sdp_index, ancillary_sdp_indexPicks a media section, counted from 1, when the SDP describes several streams.

SDPs are fetched at every start, so a sender's changed SDP is followed on the next start. If a fetch fails, capture keeps the card's current subscription and logs a warning.

toml
[[sources]]
id = "st2110-in"
source_type = "decklink_sdk"

[sources.protocol_options]
device = "DeckLink IP/SDI HD (1)"
video_sdp = "http://SDP_HOST/camera-1-video.sdp"
audio_sdp = "http://SDP_HOST/camera-1-audio.sdp"

Playout​

OptionDescription
video_destination, audio_destination, ancillary_destinationWhere each flow is sent, such as a multicast group. Without them, playout sends to the groups the card holds.
sdp_directoryA directory where the sink writes each flow's SDP for receivers to fetch. The files are removed when playout stops.

Setting a destination or sdp_directory selects the Ethernet output. The sink takes raw video and PCM, as for SDI playout.

toml
[[sinks]]
id = "st2110-out"
sink_type = "decklink_sdk"
source_ids = ["to-raw"]

[sinks.protocol_options]
device = "DeckLink IP/SDI HD (2)"
video_destination = "239.20.0.1"
audio_destination = "239.20.0.2"
ancillary_destination = "239.20.0.3"
sdp_directory = "/sdp"

Pass the container every /dev/blackmagic device node of the card. Device names number the sub-devices the container sees, so with only some nodes mapped, the names shift.

Metrics​

All names carry the vindral_packager_ prefix and a device label (the configured name, or index N). See Monitoring.

MetricLabelsMeaning
decklink_input_locked1 while the input has signal.
decklink_input_frames_totalkindCaptured video, audio and no_signal frames.
decklink_input_queue_dropped_totalkindFrames dropped because the pipeline fell behind.
decklink_input_format_changes_totalactionFormat changes: relock, end_of_stream, continue.
decklink_input_anc_dropped_totalCaptured ANC packets left out of the ST 2038 track.
decklink_output_playing1 while playout runs.
decklink_output_frames_totalresultPlayed frames: completed, late, dropped, flushed.
decklink_output_lead_secondsCurrent output latency (lead ahead of the card's playhead).
decklink_output_lead_median_secondsMedian lead over the last minute.
decklink_output_preroll_secondsConfigured pre-roll.
decklink_output_target_lead_secondsLead the sink is holding, including increases for jitter.
decklink_output_buffered_video_framesFrames scheduled but not yet played.
decklink_output_buffered_audio_samplesAudio samples scheduled but not yet played.
decklink_output_corrections_totaldirectionDrift corrections: inserted or dropped frames.
decklink_output_slots_filled_totalFrame slots filled by repeating the next frame.
decklink_output_frames_discarded_totalInput frames discarded because their slot was taken.
decklink_output_reanchors_totalInput timestamp jumps the sink re-anchored to.
decklink_output_audio_samples_totalkindAudio samples offered, written, gap, trimmed, discarded, late.
decklink_output_anc_packets_totalresultST 2038 ANC packets: attached, late, orphaned, malformed, refused.

Alert on decklink_input_locked == 0 for signal loss, and on a rising decklink_output_frames_total{result="late"} or {result="dropped"} for playout problems.

The decklink source and sink type uses FFmpeg's DeckLink device and remains available where the image's FFmpeg includes it. Existing configurations keep working. It takes the device name as protocol_options.url and FFmpeg's DeckLink options, such as format_code and channels, in demuxer_options. See the FFmpeg DeckLink documentation.

To move a configuration to decklink_sdk, change the type, rename url to device, and check the options against the tables above. Capture pipelines that already encode the source need no other change. For playout, make the transcoder produce rawvideo with an exact display-mode size and 48 kHz PCM audio, as described in Playout.