1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

少し古い環境向けにNVDEC/NVENCを有効にしたffmpeg をビルドする

Last updated at Posted at 2020-04-07

わけあって少し古い環境でNVDEC/NVENCを有効にしたffmpegを使いたくなったのですが、ビルドで一苦労あったのでメモを残します。
ubuntu 16.04 でNvidia のVideo Codec SDKが8.0.14 です。

NVDEC/NVENCを有効にしたffmpegのビルド

このページを参考にビルドします。
NVENCを使ったHWEncode環境

ffmpeg は n4.2.2 を使いました。
古い環境でもビルドできました。

実行時にエラー

しかし、ハードウェアデコーダを使用しようとするとエラーになります。

[h264_cuvid @ 0x556348eb94c0] Cannot load cuvidGetDecodeStatus
[h264_cuvid @ 0x556348eb94c0] Failed loading nvcuvid.

このエラーメッセージでググるとこのページがヒットしました。全く同じ症状。
compiling ffmpeg with nvidia/cuda failed loading nvcuvid

Linux needed a "396.24 or newer driver". And only CUDA toolkit 9.2 at least, supports this driver version.

と書いてあり、ドライバをアップデートする方法が紹介されています。
ぐぬぬ。ubuntu 16.04 のままでは新しいドライバが入らない。これまでか ...

まだあきらめるのは早い

cuvidGetDecodeStatus がどこで使われいるのかを探すと、これはビルド時にインストールしたnv-codec-headersの中のインクルードファイルにつきあたります。
nv-codec-headersはgitリポジトリで提供されているので、変更履歴をさかのぼることができます。
そうすると、Video Codec SDKがまだ8.0.x の頃のものもあるじゃないですか!
履歴を見るとcuvidGetDecodeStatusというのはSDK8.1から追加されたこともわかります。

SDK8.0のブランチをcheckout してインクルードヘッダをインストールしなおして、ffmpeg を再度ビルドしました。
すると実行時エラーは解消して、NVDEC/NVENCを有効にしたffmpeg を無事使えるようになりました。
めでたしめでたし。 w

使い方
NVIDIA FFmpeg Transcoding Guide

1
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?