Corrupted output when resizing with scale_npp filter
Hello everyone, I've been struggling with this and unfortunately I'm not getting any further. I'm trying to transcode a single video file into multiple variants with different resolutions/bitrates using GPU acceleration - in one command. The idea seems simple, and is even covered by NVIDIA as well as ffmpeg on their respective websites, which is what I've been following: https://trac.ffmpeg.org/wiki/HWAccelIntro#CUDACUVIDNvDecode https://developer.nvidia.com/ffmpeg The encoding/decoding part is working great and produces results as expected. However when I try to resize using the scale_npp filter things start to turn green. The resulting output from ffmpeg is just a green image with very low bit rate/filesize, but correct resolution. I considered using the NVDEC decoder's resizing function, while that does work it makes things a bit more complicated, since I have to launch a separate ffmpeg job for each and every encoding. This is the command I've been using: ffmpeg -y \ -hwaccel cuvid -c:v h264_cuvid -i input.mp4 \ -vf scale_npp=-1:480 \ -c:v h264_nvenc -preset slow -ss 0 -t 90 output.mp4 I've tried this on Ubuntu 16.04/17.10 as well as Cent OS 7. CentOS and Ubuntu 17.10 were on the same machine, Ubuntu 16.04 was on another one. The output is at the end of this Message and it's from the Ubuntu 17.10 machine. I only used self-compiled ffmpeg binaries. The result stays the same. I appreciate your help. Best Regards, Christian ffmpeg version N-89672-g41e51fb Copyright (c) 2000-2018 the FFmpeg developers built with gcc 7 (Ubuntu 7.2.0-8ubuntu3) configuration: --prefix=/home/user/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/user/ffmpeg_build/include --extra-ldflags=-L/home/user/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/user/bin --enable-gpl --enable-libfdk-aac --enable-libmp3lame --enable-libx264 --extra-libs=-lpthread --enable-nvenc --enable-cuda-sdk --enable-cuvid --enable-libnpp --extra-cflags=-I../nv_sdk --extra-ldflags=-L../nv_sdk --extra-cflags=-I/usr/local/cuda/include/ --extra-ldflags=-L/usr/local/cuda/lib64/ --nvccflags='-gencode arch=compute_61,code=sm_61 -O2' --enable-nonfree libavutil 56. 7.100 / 56. 7.100 libavcodec 58. 9.100 / 58. 9.100 libavformat 58. 3.100 / 58. 3.100 libavdevice 58. 0.100 / 58. 0.100 libavfilter 7. 8.100 / 7. 8.100 libswscale 5. 0.101 / 5. 0.101 libswresample 3. 0.101 / 3. 0.101 libpostproc 55. 0.100 / 55. 0.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.3.100 Duration: 01:24:24.36, start: 0.000000, bitrate: 19773 kb/s Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 19772 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default) Metadata: handler_name : VideoHandler timecode : 01:00:00:00 Stream #0:1(eng): Data: none (tmcd / 0x64636D74) Metadata: handler_name : TimeCodeHandler timecode : 01:00:00:00 Stream mapping: Stream #0:0 -> #0:0 (h264 (h264_cuvid) -> h264 (h264_nvenc)) Press [q] to stop, [?] for help Output #0, mp4, to 'output.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.3.100 Stream #0:0(eng): Video: h264 (h264_nvenc) (Main) (avc1 / 0x31637661), cuda, 853x480 [SAR 2560:2559 DAR 16:9], q=-1--1, 2000 kb/s, 0.04 fps, 12800 tbn, 25 tbc (default) Metadata: handler_name : VideoHandler timecode : 01:00:00:00 encoder : Lavc58.9.100 h264_nvenc Side data: cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 4000000 vbv_delay: -1 frame= 2250 fps=563 q=8.0 Lsize= 93kB time=00:01:29.96 bitrate= 8.5kbits/s speed=22.5x video:83kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 12.122848%
Follow-up on this in case anyone is interested. I've been using the latest version of the NVENC SDK (8.0.14) as well as the CUDA Toolkit (9.1). I tried downgrading the CUDA Toolkit version to the latest 8.0 patch. The scale_npp filter is working as expected now. For testing purposes I've been transcoding the Tears of Steel short film available here: https://mango.blender.org/download/ (using the 4K rendered mov as input) There seems to be something odd about this file - or my transcoding, I'm not sure. When I downscale this to 2K using scale_npp I get a few pixel wide horizontal green bar at the bottom of the video. ffmpeg -y \ -hwaccel cuvid -c:v h264_cuvid -i tears_of_steel/tearsofsteel_4k.mov \ -filter_complex scale_npp=1920:-1 -c:v h264_nvenc tears.of.steel.1080p.mp4 This does NOT happen with other resolutions I've tested with scale_npp: * 1280:-1 * 960:-1 * 768:-1 * 640:-1 * 480:-1 Here's the output from the above command (limited to 30s): ffmpeg version N-89748-g2050464 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.5) 20160609 configuration: --prefix=/home/user/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/user/ffmpeg_build/include --extra-ldflags=-L/home/user/ffmpeg_build/lib --bindir=/home/user/bin --enable-cuda-sdk --enable-cuvid --enable-libnpp --extra-cflags=-I../nv_sdk --extra-ldflags=-L../nv_sdk --extra-cflags=-I/usr/local/cuda/include/ --extra-ldflags=-L/usr/local/cuda/lib64/ --enable-libass --enable-libfdk-aac --enable-nvenc --enable-nonfree libavutil 56. 7.100 / 56. 7.100 libavcodec 58. 9.100 / 58. 9.100 libavformat 58. 3.100 / 58. 3.100 libavdevice 58. 0.100 / 58. 0.100 libavfilter 7. 11.101 / 7. 11.101 libswscale 5. 0.101 / 5. 0.101 libswresample 3. 0.101 / 3. 0.101 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'tears_of_steel/tearsofsteel_4k.mov': Metadata: major_brand : qt minor_version : 512 compatible_brands: qt encoder : Lavf54.29.104 Duration: 00:12:14.00, start: 0.000000, bitrate: 73434 kb/s Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 3840x1714 [SAR 1:1 DAR 1920:857], 73244 kb/s, 24 fps, 24 tbr, 24 tbn, 48 tbc (default) Metadata: handler_name : DataHandler encoder : libx264 Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 182 kb/s (default) Metadata: handler_name : DataHandler Stream mapping: Stream #0:0 (h264_cuvid) -> scale_npp (graph 0) scale_npp (graph 0) -> Stream #0:0 (h264_nvenc) Stream #0:1 -> #0:1 (aac (native) -> aac (native)) Press [q] to stop, [?] for help Output #0, mp4, to 'tears.of.steel.1080p.mp4': Metadata: major_brand : qt minor_version : 512 compatible_brands: qt encoder : Lavf58.3.100 Stream #0:0: Video: h264 (h264_nvenc) (Main) (avc1 / 0x31637661), cuda, 1920x857 [SAR 1:1 DAR 1920:857], q=-1--1, 2000 kb/s, 24 fps, 12288 tbn, 24 tbc (default) Metadata: encoder : Lavc58.9.100 h264_nvenc Side data: cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 4000000 vbv_delay: -1 Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default) Metadata: handler_name : DataHandler encoder : Lavc58.9.100 aac frame= 720 fps=204 q=27.0 Lsize= 7377kB time=00:00:30.00 bitrate=2014.5kbits/s speed=8.51x video:6885kB audio:474kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.248955%
participants (1)
-
Christian Kaik