You are not logged in.

#1 2016-08-04 00:28:11

thelongdivider
Member
Registered: 2013-11-09
Posts: 52

Using Nvidia to encode and decode video in FFMPEG simultaneously

Hi Everyone,

I was wondering if anyone knew how to use an Nvidia (1070) to decode and encode instead of relying on CPU to decode while encoding with nvenc.  My current code runs as

#!/bin/bash

for file in *
do
ffmpeg -i "$file" -c:v hevc_nvenc -preset slow -crf 18 -c:a copy hevc/"$file"

done

which is serving the purpose of encoding my h264 files in a directory to hevc.  I have tried using instead

ffmpeg -hwaccel cuvid -i "$file" -c:v hevc_nvenc -preset slow -crf 18 -c:a copy hevc/"$file"

which results in the error

CUVID hwaccel requested, but impossible to achive.

typos aside, anyone know why this would happen?  I also have an intel 3770k that I could try to use qsv to decode streams with... but that seems kind of dumb to get i915 running to only decode sometimes.  Also I don't know how to run both GPUs simultaneously.

Last edited by thelongdivider (2016-08-04 00:30:08)

Offline

#2 2016-08-07 16:48:03

Awebb
Member
Registered: 2010-05-06
Posts: 6,286

Re: Using Nvidia to encode and decode video in FFMPEG simultaneously

Let's have a look at the code! All I'll do is google for the error message and see where it takes me.

This is where it happens: https://ffmpeg.org/doxygen/trunk/ffmpeg … ource.html

  230 cancel:
  231     if (ist->hwaccel_id == HWACCEL_CUVID) {
  232         av_log(NULL, AV_LOG_ERROR, "CUVID hwaccel requested, but impossible to achive.\n");
  233         return AVERROR(EINVAL);
  234     }

If I get the code right, then this means if your device is listed as cuvid capable, but "cancel" has been called, then something else must have gone wrong.

This is, where the code craps its pants in your situation: (same source file)

  101     if (ist->hwaccel_id != HWACCEL_CUVID || !ist->dec || !ist->dec->pix_fmts)
  102         goto cancel;
             [...]
  106     if (*pix_fmt == AV_PIX_FMT_NONE)
  107         goto cancel;

Your hardware is listed as supported, otherwise hwaccel_id != (does not equal) HWACCEL_CUVID would call "cancel" right away and the error message you've got would not show up. Every cause for "cancel" before can also be ruled out, because this code still runs from top to bottom once the procedure is being called.

Now, if the "pixel format" is whatever "AV_PIX_FMT_NONE" describes, then "cancel" is being called.

AV_PIX_FMT_NONE seems to be documented here: https://ffmpeg.org/doxygen/2.7/pixfmt_8h.html with more details on the same page: https://ffmpeg.org/doxygen/2.7/pixfmt_8 … 0cf80cd4c5

AVPixelFormat {
  AV_PIX_FMT_NONE = -1, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUYV422, AV_PIX_FMT_RGB24, 
  ...
}

I'd say YUV420P, YUYV422 and RGB24 looks like something somebody working with video conversion might recognize. I don't have actual knowledge of video conversion, but I recognize a buzzword when I see one. It looks like cuvid simply doesn't like your input files.

Offline

Board footer

Powered by FluxBB