ekisu / mpv-webm

Simple WebM maker for mpv, with no external dependencies.
MIT License
556 stars 33 forks source link

8:9 video outputs stretched 16:9 #65

Closed ghost closed 4 years ago

ghost commented 4 years ago

mpv version and platform

Windows 10 Enterprise v.1809

mpv 0.29.0-353-g65b1c2d065 Copyright © 2000-2019 mpv/MPlayer/mplayer2 projects
 built on Sun Jul 14 20:16:49 +08 2019
ffmpeg library versions:
   libavutil       56.30.100
   libavcodec      58.53.101
   libavformat     58.28.102
   libswscale      5.4.101
   libavfilter     7.56.101
   libswresample   3.4.100
ffmpeg version: git-2019-07-13-f86f213a

Description

Creating a webm using source material that is 8:9 make the webm output stretched widescreen video screenshot showing source on top, output webm on bottom screenshot

Log file

log file

ghost commented 4 years ago

I just updated the webm converter script and MPV just to be sure, and the problem persists.

ekisu commented 4 years ago

I can't reproduce it, at least not with this video (used youtube-dl to download it).

Could you run the encoding command:

.\mpv.com "I:\! TV\Trailer Park Boys\Season 06\Trailer Park Boys - S06E05 - Halloween 1977 - DVD - x264 AC3.mkv" --output=log-encode.txt --start=0:01:09.903 --end=0:01:20.714 --ovc=libvpx --oac=libvorbis --loop-file=no --vid=1 --aid=no --sid=no --sub-ass-override=yes --sub-auto=exact --sub-delay=0.000000 --video-rotate=0 --ovcopts-add=threads=12 "--oset-metadata=title=%60%Trailer Park Boys - S06E05 - Halloween 1977 - DVD - x264 AC3" --ovcopts-add=b=2212k --ovcopts-add=crf=10 --ovcopts-add=flags=+pass2 "-o=I:\Pictures\WebM/Trailer Park Boys - S06E05 - Halloween 1977 - DVD - x264 AC3.mkv-[01.09.903-01.20.714].webm"

in a cmd/PowerShell window and send me the "log-encode.txt", and the cmd window output?

ghost commented 4 years ago

I can't reproduce it, at least not with this video (used youtube-dl to download it).

Could you run the encoding command:

.\mpv.com "I:\! TV\Trailer Park Boys\Season 06\Trailer Park Boys - S06E05 - Halloween 1977 - DVD - x264 AC3.mkv" --output=log-encode.txt --start=0:01:09.903 --end=0:01:20.714 --ovc=libvpx --oac=libvorbis --loop-file=no --vid=1 --aid=no --sid=no --sub-ass-override=yes --sub-auto=exact --sub-delay=0.000000 --video-rotate=0 --ovcopts-add=threads=12 "--oset-metadata=title=%60%Trailer Park Boys - S06E05 - Halloween 1977 - DVD - x264 AC3" --ovcopts-add=b=2212k --ovcopts-add=crf=10 --ovcopts-add=flags=+pass2 "-o=I:\Pictures\WebM/Trailer Park Boys - S06E05 - Halloween 1977 - DVD - x264 AC3.mkv-[01.09.903-01.20.714].webm"

in a cmd/PowerShell window and send me the "log-encode.txt", and the cmd window output?

C:\Program Files\MPV>.\mpv.com "I:\! TV\Trailer Park Boys\Season 06\Trailer Park Boys - S06E05 - Halloween 1977 - DVD - x264 AC3.mkv" --output=log-encode.txt --start=0:01:09.903 --end=0:01:20.714 --ovc=libvpx --oac=libvorbis --loop-file=no --vid=1 --aid=no --sid=no --sub-ass-override=yes --sub-auto=exact --sub-delay=0.000000 --video-rotate=0 --ovcopts-add=threads=12 "--oset-metadata=title=%60%Trailer Park Boys - S06E05 - Halloween 1977 - DVD - x264 AC3" --ovcopts-add=b=2212k --ovcopts-add=crf=10 --ovcopts-add=flags=+pass2 "-o=I:\Pictures\WebM\1.webm"
Error parsing option output (option not found)
Setting commandline option --output=log-encode.txt failed.

Exiting... (Fatal error)

changing --output to log-file gives:

C:\Program Files\MPV>.\mpv.com "I:\! TV\Trailer Park Boys\Season 06\Trailer Park Boys - S06E05 - Halloween 1977 - DVD - x264 AC3.mkv" --log-file=log-encode.txt --start=0:01:09.903 --end=0:01:20.714 --ovc=libvpx --oac=libvorbis --loop-file=no --vid=1 --aid=no --sid=no --sub-ass-override=yes --sub-auto=exact --sub-delay=0.000000 --video-rotate=0 --ovcopts-add=threads=12 "--oset-metadata=title=%60%Trailer Park Boys - S06E05 - Halloween 1977 - DVD - x264 AC3" --ovcopts-add=b=2212k --ovcopts-add=crf=10 --ovcopts-add=flags=+pass2 "-o=I:\Pictures\WebM\1.webm"
Playing: I:\! TV\Trailer Park Boys\Season 06\Trailer Park Boys - S06E05 - Halloween 1977 - DVD - x264 AC3.mkv
 (+) Video --vid=1 (*) (h264 720x476 29.970fps)
     Audio --aid=1 --alang=eng (*) (ac3 6ch 48000Hz)
VO: [lavc] 720x476 => 720x535 yuv420p
[vo/lavc] Reading 2-pass log: I:\Pictures\WebM\1.webm-video-pass1.log
[file] Cannot open file 'I:\Pictures\WebM\1.webm-video-pass1.log': No such file or directory
Failed to open I:\Pictures\WebM\1.webm-video-pass1.log.
[vo/lavc] could not open 'I:\Pictures\WebM\1.webm-video-pass1.log', disabling 2-pass encoding at pass 2
[vo/lavc] Opening encoder: libvpx VP8 [libvpx]
[encode] Opening output file: I:\Pictures\WebM\1.webm
[encode] Opening muxer: WebM [webm]
V: 00:01:20 / 00:22:39 (5%) {0.0min 53.7fps 2.1MB}

[encode] video: encoded 2764143 bytes
[encode] audio: encoded 0 bytes
[encode] muxing overhead 2994 bytes

Exiting... (End of file)

log-encode.txt

ghost commented 4 years ago

another log, using the script like I normally do from withing MPV (shift-w) and this time having "run detached=false"

using --log-file in mpv.conf log.txt at webm (output) directory log.txt at source (mkv) directory

ghost commented 4 years ago

Apparently it doesn't happen when I use the same script to convert to MP4, the problem seems to only happen when using WEBM as output.

Top = source, bottom is output MP4.

screenshot

ekisu commented 4 years ago

Well, your video isn't 4:3, but actually 8:9. I don't know if VP8 specifically forces an aspect ratio, but as you said that using MP4 as the output format, I'd assume so.

ghost commented 4 years ago

Well, your video isn't 4:3, but actually 8:9. I don't know if VP8 specifically forces an aspect ratio, but as you said that using MP4 as the output format, I'd assume so.

yeah sorry, it's not 4:3, but is there a way to prevent VP8 from ruining the aspect ratio?

ekisu commented 4 years ago

I hope so. Could you upload the clip you made, in MP4? I want to see if ffmpeg also forces the aspect ratio when using VP8.

ghost commented 4 years ago

I hope so. Could you upload the clip you made, in MP4? I want to see if ffmpeg also forces the aspect ratio when using VP8.

MP4 output

ghost commented 4 years ago

Someone pointed out this might be the issue: libvpx vpxenc.c#L1037

ekisu commented 4 years ago

ffmpeg doesn't have this issue, apparently. Using:

ffmpeg.exe -i 89input.mp4 -c:v libvpx -c:a libvorbis 89output.webm

Results in a video with correct proportions.

ghost commented 4 years ago

ffmpeg doesn't have this issue, apparently. Using:

ffmpeg.exe -i 89input.mp4 -c:v libvpx -c:a libvorbis 89output.webm

Results in a video with correct proportions.

then how do I get this webm script for mpv to do the same?

ekisu commented 4 years ago

I don't know. Looking deeper on it, this seems more like a bug on ffmpeg/mpv itself. mpv passes the SAR (along with other codec parameters) in the codecpar field on the AVStream struct. Starting from the mpv code:

Now, we begin looking at the ffmpeg side of the things:

I will probably build mpv myself to test my theory, when I have some time...

edit: I've submitted this PR to mpv, which should fix this.

ekisu commented 4 years ago

Fixed in upstream.