lisamelton / other_video_transcoding

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

Compressed aspect ratio coming out wrong #151

Closed muesic closed 2 years ago

muesic commented 2 years ago

I have several DVD movies and TV episodes that I'm compressing using the command: other-transcode --hevc --10-bit --crop auto --target 480p=1500 filename I'm seeing quite a few of my files come out with a very wrong aspect ratio. I have an example downloadable at: https://www.dropbox.com/sh/lrkiwc6p1rng4b4/AAC8i_asVfhXg_Y9XJfywqgla?dl=0 Would you mind please letting me know what I'm doing wrong. Thanks.

lisamelton commented 2 years ago

@muesic Thank you for including the sample and log file. I have no idea what's wrong because the aspect ratio is perfectly fine with my own transcoding of the original.

I suspect that there may be something odd about your version of ffmpeg since that's the only thing in the pipeline which could cause that.

How did you install it? With Homebrew? Have you tried using a statically built version?

muesic commented 2 years ago

I installed everything using Homebrew. I just did a "brew update" followed by a "brew upgrade" and reran the compression. However, I still get the same messed up aspect ratio. Regarding using a statically built version, I'm going to have to look into what that even means. I guess I'll get back to you. In the meantime, maybe the log file below (from a different show to the one I put for you on Dropbox earlier) holds some clues:

ffmpeg started on 2022-03-30 at 16:51:36 Report written to "_ffmpeg_11059_30445.mkv.log" Log level: 40 Command line: ffmpeg -loglevel error -stats -i "/Volumes/AV1_4TB/_Compress/_BoB/02 Day of Days.MKV" -vsync cfr -map 0:0 -filter:v "crop=712:480:4:0" -c:v hevc_videotoolbox -pix_fmt:v p010le -b:v 1500k -profile:v main10 -color_primaries:v smpte170m -color_trc:v bt709 -colorspace:v smpte170m -metadata:s:v "title=" -disposition:v default -map 0:1 -c:a:0 copy -metadata:s:a:0 "title=" -disposition:a:0 default -sn -metadata:g "title=" -default_mode passthrough "02 Day of Days.mkv" ffmpeg version 5.0 Copyright (c) 2000-2022 the FFmpeg developers built with Apple clang version 13.0.0 (clang-1300.0.29.30) configuration: --prefix=/usr/local/Cellar/ffmpeg/5.0 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox libavutil 57. 17.100 / 57. 17.100 libavcodec 59. 18.100 / 59. 18.100 libavformat 59. 16.100 / 59. 16.100 libavdevice 59. 4.100 / 59. 4.100 libavfilter 8. 24.100 / 8. 24.100 libswscale 6. 4.100 / 6. 4.100 libswresample 4. 3.100 / 4. 3.100 libpostproc 56. 3.100 / 56. 3.100 Input #0, matroska,webm, from '/Volumes/AV1_4TB/_Compress/_BoB/02 Day of Days.MKV': Metadata: encoder : libmakemkv v1.16.5 (1.3.10/1.5.2) darwin(x64-release) creation_time : 2022-02-14T06:59:59.000000Z Duration: 00:51:57.15, start: 0.000000, bitrate: 6717 kb/s Chapters: Chapter #0:0: start 0.066733, end 427.210117 Metadata: title : Chapter 01 Chapter #0:1: start 427.210117, end 865.147617 Metadata: title : Chapter 02 Chapter #0:2: start 865.147617, end 1190.973117 Metadata: title : Chapter 03 Chapter #0:3: start 1190.973117, end 1729.010617 Metadata: title : Chapter 04 Chapter #0:4: start 1729.010617, end 2593.874617 Metadata: title : Chapter 05 Chapter #0:5: start 2593.874617, end 3117.147367 Metadata: title : Chapter 06 Stream #0:0(eng): Video: mpeg2video (Main), yuv420p(tv, progressive), 720x480 [SAR 32:27 DAR 16:9], SAR 853:720 DAR 853:480, 29.97 fps, 29.97 tbr, 1k tbn Metadata: BPS-eng : 5573382 DURATION-eng : 00:51:57.147366666 NUMBER_OF_FRAMES-eng: 75907 NUMBER_OF_BYTES-eng: 2171631719 SOURCE_ID-eng : 0100E0 _STATISTICS_WRITING_APP-eng: MakeMKV v1.16.5 darwin(x64-release) _STATISTICS_WRITING_DATE_UTC-eng: 2022-02-14 06:59:59 _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID Side data: cpb: bitrate max/min/avg: 7931600/0/0 buffer size: 1835008 vbv_delay: N/A Stream #0:1(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s (default) Metadata: title : Surround 5.1 BPS-eng : 384000 DURATION-eng : 00:51:57.056000000 NUMBER_OF_FRAMES-eng: 97408 NUMBER_OF_BYTES-eng: 149618688 SOURCE_ID-eng : 0180BD _STATISTICS_WRITING_APP-eng: MakeMKV v1.16.5 darwin(x64-release) _STATISTICS_WRITING_DATE_UTC-eng: 2022-02-14 06:59:59 _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID Stream #0:2(eng): Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 768 kb/s Metadata: title : Surround 5.1 BPS-eng : 754500 DURATION-eng : 00:51:57.056000000 NUMBER_OF_FRAMES-eng: 292224 NUMBER_OF_BYTES-eng: 293977344 SOURCE_ID-eng : 0189BD _STATISTICS_WRITING_APP-eng: MakeMKV v1.16.5 darwin(x64-release) _STATISTICS_WRITING_DATE_UTC-eng: 2022-02-14 06:59:59 _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID Stream mapping: Stream #0:0 -> #0:0 (mpeg2video (native) -> hevc (hevc_videotoolbox)) Stream #0:1 -> #0:1 (copy) Press [q] to stop, [?] for help [graph 0 input from stream 0:0 @ 0x7fe33f617600] w:720 h:480 pixfmt:yuv420p tb:1/1000 fr:30000/1001 sar:853/720 [auto_scale_0 @ 0x7fe33f613c80] w:iw h:ih flags:'' interl:0 [format @ 0x7fe33f6138c0] auto-inserting filter 'auto_scale_0' between the filter 'Parsed_crop_0' and the filter 'format' [Parsed_crop_0 @ 0x7fe33f612200] w:720 h:480 sar:853/720 -> w:712 h:480 sar:853/720 [auto_scale_0 @ 0x7fe33f613c80] w:712 h:480 fmt:yuv420p sar:853/720 -> w:712 h:480 fmt:p010le sar:853/720 flags:0x0 Output #0, matroska, to '02 Day of Days.mkv': Metadata: encoder : Lavf59.16.100 Chapters: Chapter #0:0: start 0.066733, end 427.210117 Metadata: title : Chapter 01 Chapter #0:1: start 427.210117, end 865.147617 Metadata: title : Chapter 02 Chapter #0:2: start 865.147617, end 1190.973117 Metadata: title : Chapter 03 Chapter #0:3: start 1190.973117, end 1729.010617 Metadata: title : Chapter 04 Chapter #0:4: start 1729.010617, end 2593.874617 Metadata: title : Chapter 05 Chapter #0:5: start 2593.874617, end 3117.147367 Metadata: title : Chapter 06 Stream #0:0(eng): Video: hevc, p010le(tv, smpte170m/smpte170m/bt709, top coded first (swapped)), 712x480 [SAR 853:720 DAR 75917:43200], q=2-31, 1500 kb/s, 29.97 fps, 1k tbn (default) Metadata: BPS-eng : 5573382 DURATION-eng : 00:51:57.147366666 NUMBER_OF_FRAMES-eng: 75907 NUMBER_OF_BYTES-eng: 2171631719 SOURCE_ID-eng : 0100E0 _STATISTICS_WRITING_APP-eng: MakeMKV v1.16.5 darwin(x64-release) _STATISTICS_WRITING_DATE_UTC-eng: 2022-02-14 06:59:59 _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID encoder : Lavc59.18.100 hevc_videotoolbox Stream #0:1(eng): Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, 5.1(side), fltp, 384 kb/s (default) Metadata: _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID BPS-eng : 384000 DURATION-eng : 00:51:57.056000000 NUMBER_OF_FRAMES-eng: 97408 NUMBER_OF_BYTES-eng: 149618688 SOURCE_ID-eng : 0180BD _STATISTICS_WRITING_APP-eng: MakeMKV v1.16.5 darwin(x64-release) _STATISTICS_WRITING_DATE_UTC-eng: 2022-02-14 06:59:59 *** 1 dup!

lisamelton commented 2 years ago

@muesic OK, I missed this the first time, probably because I was eating lunch. :)

Cropping the input is giving you the, perhaps, unexpected display bounds. But technically there's nothing wrong with the aspect ratio. Your input is "pillar-boxed," meaning it has black bars on both sides.

TL;DR: there's nothing wrong.

muesic commented 2 years ago

I found my notes from when I installed everything from scratch. I'm not sure if this means I have static build or not.

Install Homebrew: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" Install Ruby: brew install ruby Install other required programs: ffprobe (part of ffmpeg), mkvpropedit (part of mkvtoolnix): brew install ffmpeg brew install mkvtoolnix brew install mpv Install/update other_video_transcoding: gem install other_video_transcoding gem update other_video_transcoding

lisamelton commented 2 years ago

@muesic Again, false alarm about ffmpeg. It's not a bug. That's the way cropping works.

I'll close this now.

muesic commented 2 years ago

Looks like we posted at just about the same time. I'm a little confused in that I thought you tried the same command and it was all good for you. I took that to mean our worlds were behaving differently. Now you're saying everything is working as expected :-/. Should I just remove the crop aspect from the command line? My intention using auto cropping was to remove any black bars (horizontal or vertical) present in the source material from making it's way to the compressed result. I thought I read somewhere on your website that HandBrake did a poor job of auto-cropping and that your method was much better, hence my usage of the "--crop auto". Please don't misinterpret this as anger, but what's the point of "--crop auto" if it yields so much disastrous output? Here's an example image of what happened to a TV episode:

image

muesic commented 2 years ago

Just for completeness sake, this is the same spot in the episode that corresponds to my picture in the previous post: image

lisamelton commented 2 years ago

@muesic OK, I think the problem might the program you're using to view your transcoding. I'm using mpv and I'm not having a problem at all. Are you using VLC?

lisamelton commented 2 years ago

@muesic BTW, you shouldn't have to remove --crop auto from your command line. That also works fine for me.

muesic commented 2 years ago

Yes - I'm using VLC. Aside from it's awful handling of subtitles, it's always been very good for the video side of things. This is the first time (in easily over a decade) I've ever seen an issue such as this. I'll look into mpv (which I've never heard of till just now).

lisamelton commented 2 years ago

@muesic Ah. Yeah, VLC is... hmmm... awful, really. :) You can install mpv via Homebrew. It's a command line tool but there's also an "app" version if you need it.

Please try it and then we can close this.

lisamelton commented 2 years ago

@muesic BTW, your transcoded version of "Spencer" looks fine to me with mpv. So, I'm almost certain the issue is with VLC.

lisamelton commented 2 years ago

@muesic I just confirmed that the problem is definitely VLC by trying it myself.

OK, I'm closing this now then.

muesic commented 2 years ago

Well I'll be darned - it is a VLC issue... I tried viewing the video using IINA and mpv and they were both good. Really appreciate your (precious) time and help! I'm going to definitely look into migrating across to mpv given that you're a strong advocate. As a closing question, I noticed when I was compressing these mkv files using the command in my original post that my CPU meters (I run an app called MenuMeters) weren't particularly stressed out and my laptop fans didn't even come on. When I run a HandBrake compression all 8 cores are maxxed out. Is there a setting somewhere that I can instruct other-transcode to use more resources?

lisamelton commented 2 years ago

@muesic No, there's no setting for that with other-transcode. Your fans don't come on because you're using the GPU, not the CPU. Your cores are maxed out with HandBrake because it's using a software encoder by default, not a hardware encoder.