ekisu / mpv-webm

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

MP4 encode failing? #77

Open frozenpandaman opened 4 years ago

frozenpandaman commented 4 years ago

mpv version and platform

macOS 10.14.6

mpv 0.30.0 Copyright © 2000-2019 mpv/MPlayer/mplayer2 projects
 built on Sun Nov  3 20:28:56 CET 2019
ffmpeg library versions:
   libavutil       56.31.100
   libavcodec      58.54.100
   libavformat     58.29.100
   libswscale      5.5.100
   libavfilter     7.57.100
   libswresample   3.5.100
ffmpeg version: 4.2.1

Description

Any clue why I conversion to mp4 is failing for me? I tried uninstall & reinstalling both ffmpeg and libvpx via Homebrew, and still getting the error below…

Log file

[   7.746][v][webm] " (+) Video --vid=1 (*) (h264 1280x720 23.976fps)" 
[   7.746][v][webm] " (+) Audio --aid=1 --alang=jpn (*) (aac 2ch 48000Hz)" 
[   7.746][v][webm] "[vo/lavc] codec for video not found" 
[   7.746][v][webm] "Error opening/initializing the selected video_out (--vo) device." 
[   7.746][v][webm] "Video: no video" 
[   7.749][v][webm] "" 
[   7.749][v][webm] "[encode] no data written to target file" 

(let me know if you need the full thing)

Thanks!

frozenpandaman commented 4 years ago

Seems the problem is explicitly with the --ovc=libx264 option used with mpv. Can't seem to get that to work…

ekisu commented 4 years ago

Seems a bit similar to #13. I don't know if mpv on macOS uses the ffmpeg system libraries or is statically linked, but does using ffmpeg with libx264 works?

frozenpandaman commented 4 years ago

Sorry for the late reply here @ekisu! It doesn't seem to use/depend on ffmpeg; rather, it's just executing the mpv command which includes the ability to do this, apparently.

Here's the command it's trying to run (cleaned up for the sake of an example):

[  13.615][v][webm] Command line: mpv /path/to/my/video.mp4 --start=0:00:01.000 --end=0:00:02.000 --ovc=libx264 --oac=aac --loop-file=no --vid=1 --sid=no --aid=no --sub-ass-override=yes --sub-auto=exact --sub-delay=0.000000 --video-rotate=0 --ovcopts-add=b=132226k --ovcopts-add=crf=10 -o=/path/to/my/video-[00.01.000-00.02.000].mp4 

Then it's spitting out "[vo/lavc] codec for video not found" and failing. Encodes fail whether I launch mpv from command line or Finder, and when copy-pasting that command into the command line too. FYI, I've since upgraded mpv to 0.31.0, but same issue.

Re: https://trac.ffmpeg.org/wiki/CompilationGuide/macOS – seems to be a decision that everyone is chiding, but "Since v2.0, Homebrew does not offer options for its core formulae anymore. Users who want to build ffmpeg with additional libraries (including non-free ones) need to use so-called taps from third party repositories."

I had tried out using a custom tap, though, and here's my current output of ffmepeg -version:

ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with Apple clang version 11.0.0 (clang-1100.0.33.16)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2-with-options_1 --enable-shared --cc=clang --host-cflags=-fno-stack-check --host-ldflags= --enable-gpl --enable-libaom --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --disable-libjack --disable-indev=jack --enable-opencl --enable-videotoolbox --disable-htmlpages

So it'd seem I am using ffmpeg with libx264. Is there a way to force mpv-webm to use ffmpeg rather than the built-in functionality of mpv to do this which is, for some reason, failing?

ekisu commented 4 years ago

It's weird that you would need a external formula for using x264 with ffmpeg, given that the core one (and the one the core mpv formula depends on) already has it enabled.

Is there a way to force mpv-webm to use ffmpeg rather than the built-in functionality of mpv to do this

It already (should) use the same libavcodec libraries that ffmpeg uses, so I don't really know why one has support for x264 and the other doesn't.

Please post the output of mpv --ovc=help and ffmpeg -codecs, it might shed some light over this.

frozenpandaman commented 4 years ago

Oh, yeah, you're right, you don't need one as it now has it enabled by default.

Here ya go. Long outputs for both, so I've uploaded them as .txt files:

ekisu commented 4 years ago

From that, I think it's pretty safe to say they aren't sharing the same libraries, seeing that codecs with the EV flags from ffmpeg, that should appear in mpv's output, aren't appearing. I don't really know what could fix it though, maybe reinstalling would recompile mpv with the right libraries? Homebrew is a mystery to me.

frozenpandaman commented 4 years ago

Re/installing mpv via Homebrew doesn't seem to fix it for me, nor does using a pre-built binary which is what I did in the past actually rather than a Homebrew Cask (which install the .app along with the CLI utility)… hmm…

Is there any way to force mpv to use ffmpeg, do you know?

ekisu commented 4 years ago

Hmm, I don't think mpv can use the ffmpeg binary per se, but, as I said, it should use the same shared libraries ffmpeg exposes (libavcodec/libavformat), unless ffmpeg and/or mpv were linked statically against those libs. I know very little about the macOS ecosystem itself, but .app bundles are like Snap/Flatpak app images, right? If so, the only way out is getting Homebrew to build the linked ffmpeg with the correct flags.