Error trying to decode 4K video using NVDEC - ffmpeg

I am trying to convert a 4K HEVC MKV file of 70GB into another HECV file but with less size. I am using FFmpeg with Nvidia acceleration but when I execute the following command an error appears:
ffmpeg -y -vsync 0 -hwaccel_device 0 -hwaccel cuvid -c:v hevc_cuvid -i input.mkv -c:a copy -c:v hevc_nvenc -preset slow -b:v 10M -bufsize 10M -maxrate 15M -qmin 0 -g 250 -bf 2 -temporal-aq 1 -rc-lookahead 20 -i_qfactor 0.75 -b_qfactor 1.1 output.mkv
The error is:
[hevc_nvenc # 0000021036b0d000] Provided device doesn't support required NVENC features
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
The video file has these details:
It seems that FFmpeg cannot recognize my GPU as a supported device to decode but I have read that Nvidia has support for my card with NVDEC.
I am running Windows 10 64 bits with i7 4790 and GTX 1080

NVENC doesn't support encoding B-frames, so
-bf 0 and drop -b_qfactor 1.1.

Related

ffmpeg process has GPU usage limit

i'm using ffmpeg and an NVIDIA for my video transcode process.
so i have one problem.
look at below image :
one process just use 263MiB of my second GPU. not completly use that !!
that is not good. i think there should be a way to remove this limitation for gpu process.
my ffmpeg command that i run is:
ffmpeg -y -loglevel info -hwaccel cuda -hwaccel_output_format cuda -hwaccel_device 1 -i "MYVIDEO" -vf scale_npp=w=426:h=240 -c:v h264_nvenc -profile:v main -b:v 400k -sc_threshold 0 -g 25 -keyint_min 25 -bf 2 -c:a aac -b:a 64k -ar 48000 -f hls -hls_time 6 -hls_playlist_type vod -hls_allow_cache 1 -hls_segment_filename f-0-seg-%d.ts f-0.m3u8
There is no limitation going on here, At least not related to memory.
You are scaling the video to 426x240 Assuming 4:2:0 subsampling, That is 153K per frame. The encoder needs 16 frames at most. Which is a little over 2MB. The GPU is using over 100 times that.

Mpeg1, vp9, theora and h264 intra lossless encoding strange results

I tried lossless intra coding of a few sequences including this one from xiph.org:
https://media.xiph.org/video/derf/y4m/foreman_qcif.y4m
and strangely mpeg1video wins by a great margin sizewise. I used FFmpeg with these settings:
ffmpeg -i foreman_qcif.y4m -c:v mpeg1video -qscale:v 0 -intra foreman.mpeg
ffmpeg -i foreman_qcif.y4m -c:v libx264 -crf 0 -intra foreman.mp4
ffmpeg -i foreman_qcif.y4m -c:v libvpx-vp9 -crf 0 -intra foreman.webm
ffmpeg -i foreman_qcif.y4m -c:v libtheora -qscale:v 10 -intra foreman.ogg
And the sizes I've got: mpeg1video - 2643968; theora - 2949677; vp9 - 5636841; h264 - 5743014;
So the question is: does mpeg1video really beats them all by such a margin in this mode ?
Apparently even on the max quality settings mpeg1video is far from being lossless. From ISO-IEC-11172-2_1991_MPEG1_Video:"algorithm is not lossless" and "The "quantizer size for the DC coefficients of the luminance and chrominance components is fixed at eight"

FFmpeg: Get better encoding out of my function

I needed some assistance on my task.
I am using FFmpeg to burn time and the channel name onto the video.
My goal is to record a stream that is html5 compatible with the following settings:
Video wrapper MP4
Video codec H.264
Bitrate 1Mbps
Audio codec AAC
Audio bitrate 128Kbps
And GPU encoding.
This is what I am using:
ffmpeg -hwaccel cuvid -y -i {udp} -vf "drawtext=fontfile=calibrib.tff:fontsize=25:text='{ChannelName} %{localtime}': x=10: y=10: fontcolor=white: box=1: boxcolor=0x000000" -pix_fmt yuv420p -vsync 1 -c:v h264_nvenc -r 25 -threads 0 -b:v 1M -profile:v main -minrate 1M -maxrate 1M -bufsize 10M -sc_threshold 0 -c:a aac -b:a 128k -ac 2 -ar 44100 -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" -bsf:v h264_mp4toannexb -t 00:30:00 {output}\{ChannelName}\{ChannelName}_{year}_{monthno}_{day}__{Hours}_{Minutes}_{Seconds}.mp4
{ChannelName}_{year}_{monthno}_{day}__{Hours}_{Minutes}_{Seconds} are all variable holding information.
{udp} holds the UDP stream link.
I have done it this way as I have multiple UDP stream recording.
Although this works, is there a better way for me to do this keeping in the -vf as I need the time and channel name.
Currently, this uses between 0.8% to 1.9% GPU on my Quadro P4000. I don't want to use more than this as I have more than 30 streams.
Here are some of the suggestion
-profile:v use Constrained Baseline Profile or Baseline Profile - as most of the Browser or HTML will support.
Check How many parallel instances of the Encoder you can run on GPU - Quadro P4000, remaining you can run on cpu.
Based on the resolution & fps you can decide the video bitrate of encoding range min & max bitrate. (-b:v 1M -minrate 1M -maxrate 1M) - refer : https://trac.ffmpeg.org/wiki/Limiting%20the%20output%20bitrate
-sc_threshold (FFmpeg)
Adjusts the sensitivity of x264's scenecut detection. Rarely needs to be adjusted. Recommended default: 40

ffmpeg 1080p50 50fps unsupported on some samsung models, resulting in Error

So I use FFMPEG for live transcoding using nvenc gpu acceleration. I recently did some minor improvements by upping the framerate to 1080p50 instead of 1080p25.
I noticed that this caused "error" messages on some samsung models. I was wondering if it is due to my code, can we up the compatibility or are the tv's just unable to playback 1080p50 which I think is really strange.
This is the command I use:
ffmpeg -hwaccel cuvid -vcodec h264_cuvid -vcodec h264_cuvid -i 'rtmp://127.0.0.1:8001/input/bla' -max_muxing_queue_size 1024 -map 0:v -map 0:a -vf yadif_cuda=1 -acodec libfdk_aac -b:a 128k -c:v h264_nvenc -preset llhq -vprofile high -level 4.2 -rc:v vbr -qmin:v 18 -qmax:v 42 -b:v 6M -maxrate 6M -bufsize 12M -threads 0 -r 50 -g 200 -f flv 'rtmp://127.0.0.1:8001/input/test'
Like 80% of the models, samsung/lg/sony are able to play it but some small amount of samsung tv's give stream error. I have a feeling it is just the high framerate where the tv/app is unable to play it back resulting in "streaming error". Because on even older lg models the stream plays back just perfectly. It does not seem to be a format or something...
1080p25 Requires the decoder to support level 4.1. 1080p50 requires 4.2. Check the manufacturers specifications of each devices to the max level it supports.

ffmpeg : 4K BluRay to 1080p x264

I'm trying to encode a 1080p x264 from a 4K BluRay. The problem is that source has bit-depth : 10 bits and i want output bit-depth 8 bits ...
3840x2160 (input) ==> 3840x1600 (cropped to delete black bars) ==> 1920x800 (resized)
If i use x264 0.155.2901 7d0ff22 compiled with bit-depth=all
ffmpeg -y -i input4K.m2ts -c:v libx264 -preset slow -crf 18 -x264-params me=umh:merange=24:trellis=1:level=4.1:ref=5 -filter:v "crop=3840:1600:0:280, scale=1920:800" -an "1080_"$output.mkv
it works but the output file is not 8bit, Format profile : High 10#L4.1
how to get format profile = High #L4.1 ? (force 8 bits output)
If i usex264 compiled with bit-depth=8, it tells me it can't read source.
This should work:
ffmpeg -y -i input4K.m2ts -c:v libx264 -pix_fmt yuv420p -preset slow -crf 18 -x264-params me=umh:merange=24:trellis=1:level=4.1:ref=5 -filter:v "crop=3840:1600:0:280, scale=1920:800" -an "1080_"$output.mkv

Resources