lisamelton / other_video_transcoding

Other tools to transcode videos.
MIT License
543 stars 24 forks source link

Invalid video output but source is OK (See screenshot). #134

Closed mpmc closed 2 years ago

mpmc commented 2 years ago

There appears to be something wrong with output from certain sources. for example, I get this (using software encoding)..

vlcsnap-2022-02-13-11h04m59s413

I doubled-checked & ran the encode again but the result is the same. The original source is perfect and plays back fine though. Handbrake & ffmpeg directly encode it fine. It's a weird one!

@donmelton I am more than willing to send the log & source privately to debug but cannot post it here.

lisamelton commented 2 years ago

@mpmc That is odd. What command line options to other-transcode are you using? And what is the output of that command if you add --dry-run, i.e. what is the ffmpeg command line that's displayed.

mpmc commented 2 years ago

Not adding anything unusual.

other-transcode --add-subtitle all --add-audio all ../BD/[REDACTED].mkv

Redacted log.

ffmpeg started on 2022-02-12 at 18:19:41
Report written to "_ffmpeg_56979_2356.mkv.log"
Log level: 40
Command line:
ffmpeg -loglevel error -stats -hwaccel auto -i "../BD/[REDACTED FOR SANITY]" -map 0:0 -c:v libx264 -b:v 6000k -maxrate:v 20000k -bufsize:v 20000k -mbtree:v 0 -profile:v high -color_primaries:v bt709 -color_trc:v bt709 -colorspace:v bt709 -metadata:s:v "title=" -disposition:v default -map 0:1 -c:a:0 copy -metadata:s:a:0 "title=" -disposition:a:0 default -map 0:2 -c:a:1 copy -metadata:s:a:1 "title=" -disposition:a:1 0 -map 0:3 -c:s:0 copy -disposition:s:0 0 -metadata:g "title=" -default_mode passthrough "[REDACTED FOR SANITY]"
ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 11 (Debian 11.2.0-12)
  configuration: --disable-decoder=amrnb --disable-decoder=libopenjpeg --disable-gnutls --disable-liblensfun --disable-libopencv --disable-podpages --disable-sndio --disable-stripping --enable-avfilter --enable-gcrypt --enable-gpl --enable-ladspa --enable-libaom --enable-libaribb24 --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libdavs2 --enable-libdc1394 --enable-libfdk-aac --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libkvazaar --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libtesseract --enable-l  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
Input #0, matroska,webm, from '../BD/[REDACTED FOR SANITY]':
  Metadata:
    title           : [REDACTED FOR SANITY]
    encoder         : libmakemkv v1.16.5 (1.3.10/1.5.2) x86_64-linux-gnu
    creation_time   : 2022-02-12T17:04:15.000000Z
  Duration: 00:21:01.39, start: 0.000000, bitrate: 2886 kb/s
  Stream #0:0(eng): Video: vc1 (Advanced) (WVC1 / 0x31435657), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc
    Metadata:
      BPS-eng         : 2499297
      DURATION-eng    : 00:21:01.385125000
      NUMBER_OF_FRAMES-eng: 30243
      NUMBER_OF_BYTES-eng: 394072112
      SOURCE_ID-eng   : 001011
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.16.5 linux(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2022-02-12 17:04:15
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
  Stream #0:1(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default)
    Metadata:
      title           : Stereo
      BPS-eng         : 192000
      DURATION-eng    : 00:21:01.376000000
      NUMBER_OF_FRAMES-eng: 39418
      NUMBER_OF_BYTES-eng: 30273024
      SOURCE_ID-eng   : 001100
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.16.5 linux(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2022-02-12 17:04:15
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
  Stream #0:2(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
    Metadata:
      title           : Stereo
      BPS-eng         : 192000
      DURATION-eng    : 00:21:01.376000000
      NUMBER_OF_FRAMES-eng: 39418
      NUMBER_OF_BYTES-eng: 30273024
      SOURCE_ID-eng   : 001101
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.16.5 linux(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2022-02-12 17:04:15
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
  Stream #0:3(eng): Subtitle: hdmv_pgs_subtitle, 1920x1080
    Metadata:
      BPS-eng         : 21
      DURATION-eng    : 00:21:00.738645833
      NUMBER_OF_FRAMES-eng: 4
      NUMBER_OF_BYTES-eng: 3434
      SOURCE_ID-eng   : 001200
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.16.5 linux(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2022-02-12 17:04:15
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
[AVHWDeviceContext @ 0x558ed68c0300] Cannot load libcuda.so.1
[AVHWDeviceContext @ 0x558ed68c0300] Could not dynamically load CUDA
Device creation failed: -1313558101.
[AVHWDeviceContext @ 0x558ed69553c0] Trying to use DRM render node for device 0.
[AVHWDeviceContext @ 0x558ed69553c0] libva: VA-API version 1.13.0
[AVHWDeviceContext @ 0x558ed69553c0] libva: Trying to open /usr/lib/x86_64-linux-gnu/dri/r600_drv_video.so
[AVHWDeviceContext @ 0x558ed69553c0] libva: Found init function __vaDriverInit_1_13
[AVHWDeviceContext @ 0x558ed69553c0] libva: va_openDriver() returns 0
[AVHWDeviceContext @ 0x558ed69553c0] Initialised VAAPI connection: version 1.13
[AVHWDeviceContext @ 0x558ed69553c0] VAAPI driver: Mesa Gallium driver 21.3.5 for AMD REDWOOD (DRM 2.50.0 / 5.16.0-1-amd64, LLVM 13.0.1).
[AVHWDeviceContext @ 0x558ed69553c0] Driver not found in known nonstandard list, using standard behaviour.
[vc1 @ 0x558ed68cc600] Using auto hwaccel type vaapi with new default device.
Stream mapping:
  Stream #0:0 -> #0:0 (vc1 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (copy)
  Stream #0:2 -> #0:2 (copy)
  Stream #0:3 -> #0:3 (copy)
Press [q] to stop, [?] for help
[graph 0 input from stream 0:0 @ 0x558ed6b04400] w:1920 h:1080 pixfmt:nv12 tb:1/1000 fr:24000/1001 sar:1/1
[libx264 @ 0x558ed6948700] using SAR=1/1
[libx264 @ 0x558ed6948700] using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2
[libx264 @ 0x558ed6948700] profile High, level 4.0, 4:2:0, 8-bit
[libx264 @ 0x558ed6948700] 264 - core 164 - H.264/MPEG-4 AVC codec - Copyleft 2003-2022 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=0 bitrate=6000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=20000 vbv_bufsize=20000 nal_hrd=none filler=0 ip_ratio=1.40 pb_ratio=1.30 aq=1:1.00
Output #0, matroska, to '[REDACTED FOR SANITY]':
  Metadata:
    encoder         : Lavf58.76.100
  Stream #0:0(eng): Video: h264 (H264 / 0x34363248), nv12(bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 6000 kb/s, 23.98 fps, 1k tbn (default)
    Metadata:
      BPS-eng         : 2499297
      DURATION-eng    : 00:21:01.385125000
      NUMBER_OF_FRAMES-eng: 30243
      NUMBER_OF_BYTES-eng: 394072112
      SOURCE_ID-eng   : 001011
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.16.5 linux(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2022-02-12 17:04:15
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
      encoder         : Lavc58.134.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 20000000/0/6000000 buffer size: 20000000 vbv_delay: N/A
  Stream #0:1(eng): Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, fltp, 192 kb/s (default)
    Metadata:
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
      BPS-eng         : 192000
      DURATION-eng    : 00:21:01.376000000
      NUMBER_OF_FRAMES-eng: 39418
      NUMBER_OF_BYTES-eng: 30273024
      SOURCE_ID-eng   : 001100
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.16.5 linux(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2022-02-12 17:04:15
  Stream #0:2(eng): Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, fltp, 192 kb/s
    Metadata:
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
      BPS-eng         : 192000
      DURATION-eng    : 00:21:01.376000000
      NUMBER_OF_FRAMES-eng: 39418
      NUMBER_OF_BYTES-eng: 30273024
      SOURCE_ID-eng   : 001101
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.16.5 linux(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2022-02-12 17:04:15
  Stream #0:3(eng): Subtitle: hdmv_pgs_subtitle ([255][255][255][255] / 0xFFFFFFFF), 1920x1080
    Metadata:
      BPS-eng         : 21
      DURATION-eng    : 00:21:00.738645833
      NUMBER_OF_FRAMES-eng: 4
      NUMBER_OF_BYTES-eng: 3434
      SOURCE_ID-eng   : 001200
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.16.5 linux(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2022-02-12 17:04:15
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
No more output streams to write to, finishing.
video:927353kB audio:59127kB subtitle:3kB other streams:0kB global headers:0kB muxing overhead: 0.081300%
Input file #0 (../BD/[REDACTED FOR SANITY]):
  Input stream #0:0 (video): 30243 packets read (394072112 bytes); 30243 frames decoded; 
  Input stream #0:1 (audio): 39418 packets read (30273024 bytes); 
  Input stream #0:2 (audio): 39418 packets read (30273024 bytes); 
  Input stream #0:3 (subtitle): 4 packets read (3434 bytes); 
  Total: 109083 packets (454621594 bytes) demuxed
Output file #0 ([REDACTED FOR SANITY]):
  Output stream #0:0 (video): 30243 frames encoded; 30243 packets muxed (949609600 bytes); 
  Output stream #0:1 (audio): 39418 packets muxed (30273024 bytes); 
  Output stream #0:2 (audio): 39418 packets muxed (30273024 bytes); 
  Output stream #0:3 (subtitle): 4 packets muxed (3434 bytes); 
  Total: 109083 packets (1010159082 bytes) muxed
[AVIOContext @ 0x558ed6946bc0] Statistics: 2 seeks, 3858 writeouts
[libx264 @ 0x558ed6948700] frame I:2339  Avg QP:19.29  size:104294
[libx264 @ 0x558ed6948700] frame P:13577 Avg QP:20.75  size: 27732
[libx264 @ 0x558ed6948700] frame B:14327 Avg QP:22.59  size: 22974
[libx264 @ 0x558ed6948700] consecutive B-frames: 24.4% 34.5%  8.0% 33.1%
[libx264 @ 0x558ed6948700] mb I  I16..4: 28.6% 60.2% 11.2%
[libx264 @ 0x558ed6948700] mb P  I16..4:  7.5% 22.2%  2.7%  P16..4: 28.2%  1.7%  1.4%  0.0%  0.0%    skip:36.3%
[libx264 @ 0x558ed6948700] mb B  I16..4:  2.9%  6.9%  2.1%  B16..8: 14.3%  2.4%  0.8%  direct: 1.7%  skip:68.8%  L0:50.7% L1:46.5% BI: 2.9%
[libx264 @ 0x558ed6948700] final ratefactor: 19.97
[libx264 @ 0x558ed6948700] 8x8 transform intra:64.0% inter:79.9%
[libx264 @ 0x558ed6948700] coded y,uvDC,uvAC intra: 31.4% 6.2% 4.8% inter: 5.1% 1.5% 0.9%
[libx264 @ 0x558ed6948700] i16 v,h,dc,p: 65% 32%  3%  0%
[libx264 @ 0x558ed6948700] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 18% 45%  3%  1%  1%  1%  2%  4%
[libx264 @ 0x558ed6948700] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 35% 35% 13%  3%  2%  3%  3%  3%  4%
[libx264 @ 0x558ed6948700] i8c dc,h,v,p: 92%  5%  2%  0%
[libx264 @ 0x558ed6948700] Weighted P-Frames: Y:3.4% UV:0.9%
[libx264 @ 0x558ed6948700] ref P L0: 14.0%  1.6% 30.6% 51.4%  2.3%
[libx264 @ 0x558ed6948700] ref B L0: 59.3% 31.2%  9.5%
[libx264 @ 0x558ed6948700] ref B L1: 94.8%  5.2%
[libx264 @ 0x558ed6948700] kb/s:6022.64
[AVIOContext @ 0x558ed68b5b00] Statistics: 455149706 bytes read, 2 seeks
Stats:
[AVHWDeviceContext @ 0x558ed68c0300] Cannot load libcuda.so.1
[AVHWDeviceContext @ 0x558ed68c0300] Could not dynamically load CUDA
Device creation failed: -1313558101.
frame=30243 fps= 15 q=-1.0 Lsize=  987285kB time=00:21:01.34 bitrate=6412.1kbits/s speed=0.629x    
lisamelton commented 2 years ago

@mpmc Thanks for the redacted .log file. 👍

OK, your input is VC-1 video so -hwaccel auto is automatically added to your ffmpeg command. But it looks like ffmpeg is somehow confused about your hardware and it keeps trying to load CUDA. So, please try disabling automatic hardware decoding by adding --decode none to your command line.

BTW, what kind of GPU do you have? Because you're using the software encoder.

mpmc commented 2 years ago
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Redwood PRO [Radeon HD 5550/5570/5630/6510/6610/7570] (prog-if 00 [VGA controller])
    Subsystem: PC Partner Limited / Sapphire Technology Radeon HD 5570
    Flags: bus master, fast devsel, latency 0, IRQ 30
    Memory at e0000000 (64-bit, prefetchable) [size=256M]
    Memory at f7e20000 (64-bit, non-prefetchable) [size=128K]
    I/O ports at e000 [size=256]
    Expansion ROM at 000c0000 [disabled] [size=128K]
    Capabilities: [50] Power Management version 3
    Capabilities: [58] Express Legacy Endpoint, MSI 00
    Capabilities: [a0] MSI: Enable+ Count=1/1 Maskable- 64bit+
    Capabilities: [100] Vendor Specific Information: ID=0001 Rev=1 Len=010 <?>
    Capabilities: [150] Advanced Error Reporting
    Kernel driver in use: radeon
    Kernel modules: radeon, amdgpu

and

00:02.0 Display controller: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller (rev 06)
    Subsystem: ASRock Incorporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller
    Flags: bus master, fast devsel, latency 0, IRQ 31
    Memory at f7800000 (64-bit, non-prefetchable) [size=4M]
    Memory at d0000000 (64-bit, prefetchable) [size=256M]
    I/O ports at f000 [size=64]
    Capabilities: [90] MSI: Enable+ Count=1/1 Maskable- 64bit-
    Capabilities: [d0] Power Management version 2
    Capabilities: [a4] PCI Advanced Features
    Kernel driver in use: i915
    Kernel modules: i915

Seems I got the wrong model for the AMD card 🤣

lisamelton commented 2 years ago

@mpmc Hmmmm, I'm not sure why other-transcode is not automatically detecting one of those. Probably because you're using Linux and that Radeon is the default.

Anyway, does --decode none work for you?

mpmc commented 2 years ago

@mpmc Hmmmm, I'm not sure why other-transcode is not automatically detecting one of those. Probably because you're using Linux and that Radeon is the default.

Anyway, does --decode none work for you?

Yep, adding --decode none fixes the issue. :)

lisamelton commented 2 years ago

@mpmc Excellent! OK, we can close this then but there's still the open issue of why automatic hardware decoding of VC-1 content would behave this way on your system. We can figure that out later, though. :)

martinpickett commented 2 years ago

I have not seen such severe artefact-ing before, but I have had issues with VAAPI decoding in the past. Just as Don suggested, I now always use --decode none.

mpmc commented 2 years ago

@martinpickett I think it's just the auto settings set by other_transcode causing ffmpeg confusion like @donmelton said.

I know the decode & encode via VAAPI/ffmpeg using my own command works fine (for me on my system) & creates good output (although the file sizes are quite large - hence wanting to use don's script instead).