Playback Video stream in Decklink mini monitor using ffmpeg

Posted By : Sonu Kumar Rana | 30-Aug-2019

First of all, you all are wondering, what is transcoded stream or what is video transcoding? 

 

So here is the answer, Video transcoding sometimes called video encoding, is the conversion from one digital encoding format to another, such as for movie data files. This involves translating all three elements of a digital video at the same time — the file format, the video, and the audio.

                                                                                                                

 

Now you all are wondering what is decklink, mini-monitor?

So it is an SDI and HDMI video playback and monitoring from your PCIe(slot) computer. It supports Linux, mac, and windows operating system. This product is from Blackmagic which is very best in making these types of devices . The advantage of this device is that you can watch live tv on your computer system in high quality. It can also be used for monitoring streams coming from remote locations.You can optimize the stream quality by monitoring using decklink mini-monitor.

Let's talk about Some prerequisite

  1. Operating System (Linux)
  2. FFmpeg
  3. Decklink Mini Monitor

These are some of the software and tools requirements to play input as an SDI or HDMI output via decklink mini-monitor.

What should be our first step towards achieving this functionality that we are talking about?

So here it is:-

  1. Download Desktop Video (driver) & Desktop Video SDK from  https://www.blackmagicdesign.com/support/family/capture-and-playback Url 
  2. Install desktop video driver.
  3.  Unzip Desktop Video SDK and make a directory ffmpeg_sources.
  4.  Copy decklink SDK Linux version and put the file in ffmpeg_sources.
  5.  Now follow this link to configure FFmpeg --(https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu) with (--enable-decklink) 

Now if everything went well you will see something like this in command line after writing FFmpeg in the command line:-

FFmpeg version N-94455-g01994c9 Copyright (c) 2000-2019 the FFmpeg developers

  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.11) 20160609

  configuration: --prefix=/home/sonu/ffmpeg_build --pkg-config-flags=--static --extra-cflags='-I/home/sonu/ffmpeg_build/include -I/home/sonu/ffmpeg_sources/BMD_SDK/include' --extra-ldflags=-L/home/sonu/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/sonu/bin --enable-gpl --enable-libfdk-aac --enable-libmp3lame --enable-libx264 --enable-libsrt --enable-decklink --enable-libx265 --enable-nonfree

  libavutil 56. 33.100 / 56. 33.100

  libavcodec 58. 55.100 / 58. 55.100

  libavformat 58. 30.100 / 58. 30.100

  libavdevice 58. 9.100 / 58. 9.100

  libavfilter 7. 58.100 / 7. 58.100

  libswscale 5. 6.100 / 5. 6.100

  libswresample 3. 6.100 / 3. 6.100

  libpostproc 55. 6.100 / 55. 6.100

Hyper fast Audio and Video encoder

usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

 

Look closely you will find --enable-deckink option above.

 

What is the FFmpeg command for Streaming input with HDMI OR SDI output via the decklink mini monitor?

First, let's talk about what options you can use in the case of input/output devices

 list_devices: This option shows the devices for input and output.

          

 

 list_formats: This option shows what formats decklink mini monitor supports.

           

 

One of the most important things is that decklink mini monitor is very strict about the formats it supports for video size and framerates.

So using the above options we can determine what formats are supported by decklink mini monitor card. Now, look at the FFmpeg command which will give you supported formats for decklink mini monitor card.

FFmpeg -I test.avi -f decklink -list_formats 1 'DeckLink Mini Monitor'

 

You will see output like this :-

format_code description

ntsc 720x486 at 30000/1001 fps (interlaced, lower field first)

nt23 720x486 at 24000/1001 fps

pal 720x576 at 25000/1000 fps (interlaced, upper field first)

ntsp 720x486 at 60000/1001 fps

palp 720x576 at 50000/1000 fps

23ps 1920x1080 at 24000/1001 fps

24ps 1920x1080 at 24000/1000 fps

Hp25 1920x1080 at 25000/1000 fps

Hp29 1920x1080 at 30000/1001 fps

Hp30 1920x1080 at 30000/1000 fps

Hi50 1920x1080 at 25000/1000 fps (interlaced, upper field first)

Hi59 1920x1080 at 30000/1001 fps (interlaced, upper field first)

Hi60 1920x1080 at 30000/1000 fps (interlaced, upper field first)

hp50 1280x720 at 50000/1000 fps

hp59 1280x720 at 60000/1001 fps

hp60 1280x720 at 60000/1000 fps

Now its time to reveal the ffmpeg command:-

ffmpeg -i rtsp://173.236.10.10:1935/logica/logica -f decklink -ar 48000 -pix_fmt uyvy422 -s 720x486 -r 60000/1001 'DeckLink Mini Monitor'

let's explain each options.

  • -f decklink 
  • It is basically used to set format of stream in our case we have to decklink

 

  • -ar
  •  It is used to set the audio bitrate and for decklink mini monitor it is always 48k.

 

  • -pix_fmt
  • It is used to set pixel format and for decklink mini monitor it is always uyvy422.

 

  • -s
  • It is used to set resolution or video size for the stream.

 

  • -r
  •  It is used to set the frame rate per second.

 

Conclusion

  • We have learned how to stream input with an SDI and HDMI output with FFmpeg command you can also explore more options to apply in command.
  • You can build your application using Nodejs and stream input via SDI and HDMI output via decklink card.
  • You can use a fluent-FFmpeg library which is a great library for achieving these kinds of functionality.
  • Look in npm for this library follow this URL https://www.npmjs.com/package/fluent-ffmpeg.

 Reference

  •  Look at the documentation of FFmpeg you can explore much more things  https://ffmpeg.org/
  • [Compiling and installing `FFmpeg` with Decklink SDK on Ubuntu 18.04 Server · GitHub](https://gist.github.com/afriza/879fed4ede539a5a6501e0f046f71463)

 

Request for Proposal

Name is required

Comment is required

Sending message..