ekisu / mpv-webm

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

Webm encodes fail on macOS. #13

Closed NuclearNegro closed 6 years ago

NuclearNegro commented 6 years ago

Similar to #2, I'm on macOS High Sierra. Unlike #2, neither webm-vp8 nor webm-vp9 can create a file. However, raw works as intended.

I started by building ffmpeg from Homebrew. Here is the formula used: https://github.com/Homebrew/homebrew-core/blob/master/Formula/ffmpeg.rb

My ffmpeg build options:

brew install ffmpeg --with-vpx --with-vorbis --with-libvorbis --with-vpx --with-vorbis --with-theora --with-libogg --with-libvorbis --with-gpl --with-version3 --with-nonfree --with-postproc --with-libaacplus --with-libass --with-libcelt --with-libfaac --with-libfdk-aac --with-libfreetype --with-libmp3lame --with-libopencore-amrnb --with-libopencore-amrwb --with-libopenjpeg --with-openssl --with-libopus --with-libschroedinger --with-libspeex --with-libtheora --with-libvo-aacenc --with-libvpx --with-libx264 --with-libxvid --with-cuvid --with-nvenc --with-cuda --with-opencl --with-vdpau --with-lavc

My ffmpeg configuration shows both libvorbis and libvpx enabled, and I can make webms just fine:

configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --disable-jack --enable-gpl --enable-libass --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --enable-openssl --disable-lzma --enable-nonfree

ffmpeg is in my PATH and works perfectly fine with the encode.lua mpv script.

I also built mpv from Homebrew. Here is the formula used: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mpv.rb

My mpv build options:

brew install mpv --with-bundle --with-jack --with-libaacs --with-libarchive --with-libbluray --with-libcaca --with-libdvdnav --with-libdvdread --with-pulseaudio --with-rubberband --with-uchardet --with-vapoursynth 

mpv's brew formula does not offer --enable-libvpx or --enable-libvorbis as options. Manually adding them to the formula causes the build to fail, as neither are valid options.

mpv --ovc=help doesn't list --ovc=libvpx. Likewise, mpv --oac=help doesn't list --oac=libvorbis.

Neither webm-vp8 nor webm-vp9 can create a file:

mpv /Users/test/Desktop/testfile.mkv --start=0:00:00.000 --end=0:00:43.585 --ovc=libvpx-vp9 --oac=libvorbis --loop-file=no --vid=1 --aid=1 --sid=1 --sub-ass-override=yes --sub-ass-force-style=Kerning=yes --sub-auto=fuzzy --ovcopts-add=threads=4 --ovcopts-add=b=458k --ovcopts-add=crf=10 -o=/Users/test/.vlc/testfile-[00.00.000-00.43.585]-audio.webm 

[13.022][v][webm] Command failed! Reason:  nil  Killed by us?  no 
[13.022][v][webm] Command stdout:  
[13.022][v][webm] [encode-lavc] neither audio nor video codec was found
[13.022][v][webm] [encode-lavc] vo-lavc: encoded 0 bytes
[13.022][v][webm] [encode-lavc] ao-lavc: encoded 0 bytes
[13.022][v][webm] Encoding initialization failed.
[13.022][v][webm] 
[13.022][v][webm] Exiting... (Fatal error)
[13.022][v][webm]  

Raw video works perfectly fine.

mpv --ovc=help lists --ovc=rawvideo, which is why I believe it succeeds. mpv --ovc=help does not include --ovc=libvpx or --oac=libvorbis

I believe the solution is to somehow build mpv with libvpx and libvorbis, but I'm not sure if that's possible, or if that's even the correct solution. Any advice would be appreciated.

ekisu commented 6 years ago

Please post the output of ffmpeg -version and mpv --version. Also, the homebrew install command for ffmpeg should have --with-libvpx as a flag. Some users tried running brew install libvpx as well (see the comments).

I suspect either mpv is using an static build of ffmpeg, or the ffmpeg build you are using isn't the one you installed with homebrew. I really don't know how these things work on macOS (.app bundling, static/dynamic linkage etc), so I can't help much on this.

Also, at the time #2 was opened, there was a bug that when libvpx-vp9 was used as a codec, the threads flag wouldn't be set (fixed in 1f1245c). That might be why using it worked, as there's was an issue with VP8 and threads > 1.

NuclearNegro commented 6 years ago

~ $ffmpeg -version ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers built with Apple LLVM version 9.0.0 (clang-900.0.39.2) configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --disable-jack --enable-gpl --enable-libass --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --enable-openssl --disable-lzma --enable-nonfree libavutil 55. 78.100 / 55. 78.100 libavcodec 57.107.100 / 57.107.100 libavformat 57. 83.100 / 57. 83.100 libavdevice 57. 10.100 / 57. 10.100 libavfilter 6.107.100 / 6.107.100 libavresample 3. 7. 0 / 3. 7. 0 libswscale 4. 8.100 / 4. 8.100 libswresample 2. 9.100 / 2. 9.100 libpostproc 54. 7.100 / 54. 7.100

~ $mpv --version mpv 0.28.1 (C) 2000-2017 mpv/MPlayer/mplayer2 projects built on Wed Feb 14 02:09:51 CET 2018 ffmpeg library versions: libavutil 56.7.101 libavcodec 58.11.101 libavformat 58.9.100 libswscale 5.0.101 libavfilter 7.12.100 libswresample 3.0.101 ffmpeg version: git-2018-02-14-dc77e64

Also, the homebrew install command for ffmpeg should have --with-libvpx

It does. I installed ffmpeg with --with-libvpx

Some users tried running brew install libvpx as well (see the comments)

libvpx is already installed.

~ $brew install libvpx Warning: libvpx 1.7.0 is already installed

ffmpeg can use it just fine.

ekisu commented 6 years ago

See how the libav* versions differ from the ffmpeg and mpv binaries. mpv isn't using your system ffmpeg libs.

Also, your mpv version reports 0.28.1, but the brew recipe you linked is on 0.27.2.

I don't have any specific insights on this, maybe mpv is using a static ffmpeg build (that ffmpeg version: git-2018-02-14-dc77e64 is really suspicious).

NuclearNegro commented 6 years ago

Also, your mpv version reports 0.28.1, but the brew recipe you linked is on 0.27.2.

Thank you for pointing that out. I was indeed running two versions of mpv - one built within Homebrew & a precompiled binary in /Applications. My solution was to do a complete uninstall of all versions of mpv & re-build it with the same Brew command mentioned above. After the install, brew linkapps mpv placed a binary alias in /Applications.

Thanks for your patience.

ekisu commented 6 years ago

Glad it worked out. Just for the record, can you reproduce #2? As in, when you launch mpv via Finder, does the encode fail?

NuclearNegro commented 6 years ago

Encodes work fine when launched from Finder, and they also work when launched from the command line.