Opened 7 years ago

Closed 7 years ago

#6119 closed defect (invalid)

h264_nvenc encoder sets wrong DAR if image size is 720x576

Reported by: user20170202 Owned by:
Priority: normal Component: avcodec
Version: unspecified Keywords: nvenc aspect
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
Whenever encoding a video using the h264_nvenc encoder, and the output image size is 720x576, and the DAR is specified by the "-aspect" argument, the stream DAR is wrong whereas the container DAR is correct.

Tested with versions 3.2, 3.2.2 and build 20170130-cba4f0e-win64-shared (all downloaded from https://ffmpeg.zeranoe.com)

How to reproduce:

ffmpeg -i d:\in.mpg -vf scale=720x576 -aspect 16:9 -c:v h264_nvenc  d:\out.mp4

Using out.mp4 as the input file for ffprobe shows:

Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 720x576 [SAR 2816:2025 DAR 704:405], 1963 kb/s, SAR 64:45 DAR 16:9, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)

As you can see: The DAR in square brackets (704:405) is wrong. The latter DAR in the line is correct.

  • I do not provide a source video because this happens with any source video independent from image size and input DAR.
  • Replacing h264_nvenc by libx264 does not show this problem.
  • Using any other target video size does not show this problem. Only exactly 720x576.
  • Using the video filters "setdar" or "setsar" show the same problem as using the "-aspect" argument

My first report, hoping I provided all information required. Thanks for analyzing this issue.

Change History (6)

comment:1 by Carl Eugen Hoyos, 7 years ago

Please test current FFmpeg, provide command line and complete, uncut console output for the file creation and ffmpeg -i output for the output file. And please tell us the display driver version.

comment:2 by user20170202, 7 years ago

I was using version 3.2 when coming across the problem, then testet the latest release 3.2.2, then even the latest build. I do not have an even newer build.

Here's the console output:

>ffmpeg -i d:\in.mpg -vf scale=720x576 -aspect 16:9 -c:v h264_nvenc -t 15 d:\out.mp4
ffmpeg version N-83280-gcba4f0e Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 5.4.0 (GCC)
  configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 45.100 / 55. 45.100
  libavcodec     57. 75.100 / 57. 75.100
  libavformat    57. 65.100 / 57. 65.100
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 71.100 /  6. 71.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, mpeg, from 'd:\in.mpg':
  Duration: 00:15:00.04, start: 0.620000, bitrate: 3310 kb/s
    Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, top first), 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
File 'd:\out.mp4' already exists. Overwrite ? [y/N] y
Output #0, mp4, to 'd:\out.mp4':
  Metadata:
    encoder         : Lavf57.65.100
    Stream #0:0: Video: h264 (h264_nvenc) (Main) ([33][0][0][0] / 0x0021), yuv420p, 720x576 [SAR 64:45 DAR 16:9], q=-1--1, 2000 kb/s, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.75.100 h264_nvenc
    Side data:
      cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 4000000 vbv_delay: -1
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video (native) -> h264 (h264_nvenc))
Press [q] to stop, [?] for help
frame=  375 fps=0.0 q=25.0 Lsize=    3622kB time=00:00:14.96 bitrate=1983.1kbits/s speed=32.4x
video:3619kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.064272%

Dispaly driver version: nvidia 376.33

comment:3 by user20170202, 7 years ago

output file:

>ffmpeg -i d:\out.mp4
ffmpeg version N-83280-gcba4f0e Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 5.4.0 (GCC)
  configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 45.100 / 55. 45.100
  libavcodec     57. 75.100 / 57. 75.100
  libavformat    57. 65.100 / 57. 65.100
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 71.100 /  6. 71.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'd:\out.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.65.100
  Duration: 00:00:15.00, start: 0.000000, bitrate: 1977 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 720x576 [SAR 16:11 DAR 20:11], 1976 kb/s, SAR 64:45 DAR 16:9, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler

comment:4 by user20170202, 7 years ago

After your question regarding the driver, I've just intalled the latest, 378.49 for Windows 10, 64 bit, (and of course rebooted), but the result is the same. Sorry for not trying this before. I wasn't aware this could be an issue. Thx.

comment:5 by user20170202, 7 years ago

I've been trying a sample project from the NVENC SDK, directly feeding the encoder with DAR 16:9. The result is wrong, too. So it's not an FFmpeg but an nvidia problem.

comment:6 by Carl Eugen Hoyos, 7 years ago

Resolution: invalid
Status: newclosed

Thank you for confirming this!

Note: See TracTickets for help on using tickets.