title: ffmpeg, /dev/video0, -f decklink
body: <p>I'm trying to capture video from a PCI card, the Blackmagic DeckLink Mini Recorder, via ffmpeg, on a headless host running Ubuntu 18.04.2 LTS, hopefully with a command like</p>
  
  <pre><code>ffmpeg -f decklink -i /dev/video0 ...
  </code></pre>
  
  <p>How can I make that work?  I have two obstacles.</p>
  
  <h2>No /dev/video0</h2>
  
  <p><code>ffmpeg -i /dev/video0 ...</code> fails: <code>/dev/video0: No such device or address</code>.
  <code>v4l2-ctl --list-devices</code> fails with the same error message.</p>
  
  <p>I built /dev/video0, and it looks okay:</p>
  
  <pre><code>mknod /dev/video0 c 81 0
  chown root.video /dev/video0
  chmod g+rw /dev/video0
  </code></pre>
  
  <p>To compare this file with a working one, I ran <code>strace cat /dev/video0</code> on this host, and on another host (Ubuntu 14) with a working /dev/video0.  The outputs began to differ here (good, then bad):</p>
  
  <pre><code>fstat(1, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
  open("/dev/video0", O_RDONLY)           = 3  
  fstat(3, {st_mode=S_IFCHR|0660, st_rdev=makedev(81, 0), ...}) = 0
  fadvise64(3, 0, 0, POSIX_FADV_SEQUENTIAL) = 0
  ----
  
  fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
  openat(AT_FDCWD, "/dev/video0", O_RDONLY) = -1 ENXIO (No such device or address)
  </code></pre>
  
  <p>So /dev/video0 is broken at a level lower than ffmpeg or v4l2 or even cat.</p>
  
  <p>On Ubuntu 14, <code>man 8 MAKEDEV</code> suggests that the error message means that "the kernel does not have the driver configured or loaded."</p>
  
  <p>This Ubuntu 18 host lacks that manpage, but it does have a few <code>/snap/core/*/sbin/MAKEDEV</code>, all the same, so I tried</p>
  
  <pre><code>/snap/core/6350/sbin/MAKEDEV -n -v video
  </code></pre>
  
  <p>It would have created over a hundred devices videoXX, radioXX, vtxXX, vbiXX.  Those devices didn't exist yet, so it seemed harmless to try it.</p>
  
  <pre><code>rm /dev/video0; /snap/core/6350/sbin/MAKEDEV video
  </code></pre>
  
  <p>That rebuilt /dev/video0, but "No such device" remains, from cat or ffmpeg.</p>
  
  <h2>No decklink</h2>
  
  <p><code>ffmpeg -f decklink ...</code> fails with <code>Unknown input format: 'decklink'</code>.</p>
  
  <p>Neither black nor deck nor link is mentioned by <code>ffmpeg -devices</code> (fbdev, lavfi, oss, v4l2) and <code>ffmpeg -formats</code> (about 350), either for Ubuntu's own version 3.4.4-0ubuntu0.18.04.1, or for version N-93330-g7ff89574c7 compiled from source on 2019 Mar 13:</p>
  
  <pre><code>git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
  cd ffmpeg
  ./configure --enable-nonfree --disable-doc --disable-w32threads --enable-pthreads
  </code></pre>
  
  <p>(Although <code>./configure --help</code> mentions <code>--enable-decklink</code>, using that yielded "ERROR: DeckLinkAPI.h not found."  <code>updatedb &amp;&amp; locate DeckLinkAPI.h</code> finds no file with that name, either.)</p>
  
  <p>The DeckLink PCI card is recognized by <code>hwinfo</code> and <code>lspci</code>.</p>
  
  <p><code>lsmod</code> reports the loaded modules <code>blackmagic</code> and <code>blackmagic_io</code>.</p>
  
  <p>Maybe the PCI card is installed ok, but ffmpeg just can't reach it because I can't configure it for that.</p>
  
  <p><strong>Edit:</strong>  Rebooting didn't fix anything.</p>