Yahweasel / libav.js

This is a compilation of the libraries associated with handling audio and video in ffmpeg—libavformat, libavcodec, libavfilter, libavutil, libswresample, and libswscale—for emscripten, and thus the web.
288 stars 18 forks source link

clang: error: unknown argument: '-nologo' during FFmpeg compilation with Emscripten #47

Closed PabloSergi closed 5 months ago

PabloSergi commented 5 months ago

Hello, any ideas how to fix?

WARNING: pkg-config not found, library detection may fail. mktemp -u XXXXXX qsAfnl WARNING: unknown architecture emscripten test_ld cc test_cc BEGIN /tmp/ffconf.RbU8oQTY/test.c 1 int main(void){ return 0; } END /tmp/ffconf.RbU8oQTY/test.c emcc -nologo -I/home/gm_user/ASP.Net/libav.js/build/inst/base/include -c -Fo/tmp/ffconf.RbU8oQTY/test.o /tmp/ffconf.RbU8oQTY/test.c clang: error: unknown argument: '-nologo' C compiler test failed.

Yahweasel commented 5 months ago

I believe this is not the error that you're looking for. The ffmpeg configure tries many ways of running the compiler, and only falls back to this one (Microsoft compiler garbage) if all else fails. Do you have Emscripten installed and in your path?

Yahweasel commented 5 months ago

(And, for that matter, do you have pkg-config in your path; it certainly doesn't look like you do ;) )

anishg-cn commented 5 months ago

@PabloSergi did you get it working? I am also getting this error when trying to run make all in ubuntu 22.04 (WSL).

Yahweasel commented 5 months ago

Can either of you post your complete config.log from build/ffmpeg-6.0.1/build-base-(whatever)/ffbuild/config.log?

anishg-cn commented 5 months ago

config.log

@Yahweasel here is the file

Yahweasel commented 5 months ago

I've never tried to build on WSL and don't have a WSL environment to test on. It looks like ffmpeg's configure is somehow busting through the fourth wall and detecting Microsoft odors. As a provisional test, delete your build/ffmpeg-6.0.1/build-* directories (to invalidate any caches), and in build/ffmpeg-6.0.1/configure, line 4839:

    elif $_cc -nologo- 2>&1 | grep -q Microsoft || { $_cc -v 2>&1 | grep -q clang && $_cc -? > /dev/null 2>&1; }; then

Change it to

    elif false; then

(i.e., stub it out) then try to build. If that "fixes" it, then that confirms that ffmpeg's configure is sniffing where it oughtn't.

anishg-cn commented 5 months ago

@Yahweasel now when I run make all it is giving this error:

( \
        cd patches/ffmpeg && \
        cat `cat series6` \
) | ( \
        cd build/ffmpeg-6.0.1 && \
        patch -p1 \
)
patching file libavformat/file.c
Reversed (or previously applied) patch detected!  Assume -R? [n]
Yahweasel commented 5 months ago

Not sure why the build would've deleted the file that indicates that it's already patched, but:

touch build/ffmpeg-6.0.1/PATCHED

and then build. (This of course won't happen if a proper fix is in)

Yahweasel commented 5 months ago

(Oh, I know exactly why it thought it was unpatched. Because configure is the very file that it uses to detect that, so changing it makes it think it's unpatched :rofl: )

anishg-cn commented 5 months ago

@Yahweasel now it is giving the following error, and the build is in loop, running again and again

nm: /tmp/ffconf.A330lEr1/test.o: file format not recognized

the following is the terminal output, after running make all

mkdir -p build/ffmpeg-6.0.1/build-base-default && \
cd build/ffmpeg-6.0.1/build-base-default && \
emconfigure env PKG_CONFIG_PATH="/root/libav.js/build/inst/base/lib/pkgconfig" \
        ../configure --prefix=/opt/ffmpeg --target-os=none --enable-cross-compile --disable-x86asm --disable-inline-asm --disable-runtime-cpudetect --cc=emcc --ranlib=emranlib --disable-doc --disable-stripping --disable-programs --disable-ffplay --disable-ffprobe --disable-network --disable-iconv --disable-xlib --disable-sdl2 --disable-zlib --disable-everything \
                --disable-pthreads --arch=emscripten \
        --optflags="-Oz" \
        --extra-cflags="-I/root/libav.js/build/inst/base/include " \
        --extra-ldflags="-L/root/libav.js/build/inst/base/lib " \
        `cat ../../../configs/default/ffmpeg-config.txt`
configure: env PKG_CONFIG_PATH=/root/libav.js/build/inst/base/lib/pkgconfig ../configure --prefix=/opt/ffmpeg --target-os=none --enable-cross-compile --disable-x86asm --disable-inline-asm --disable-runtime-cpudetect --cc=emcc --ranlib=emranlib --disable-doc --disable-stripping --disable-programs --disable-ffplay --disable-ffprobe --disable-network --disable-iconv --disable-xlib --disable-sdl2 --disable-zlib --disable-everything --disable-pthreads --arch=emscripten --optflags=-Oz "--extra-cflags=-I/root/libav.js/build/inst/base/include " "--extra-ldflags=-L/root/libav.js/build/inst/base/lib " --enable-protocol=data --enable-protocol=file --enable-filter=aresample --enable-demuxer=ogg --enable-muxer=ogg --enable-demuxer=matroska --enable-muxer=matroska --enable-muxer=webm --enable-parser=opus --enable-libopus --enable-decoder=libopus --enable-bsf=opus_metadata --enable-encoder=libopus --enable-demuxer=mov --enable-muxer=ipod --enable-muxer=mov --enable-muxer=mp4 --enable-parser=aac --enable-decoder=aac --enable-encoder=aac --enable-demuxer=flac --enable-muxer=flac --enable-parser=flac --enable-decoder=flac --enable-encoder=flac --enable-decoder=pcm_s16le --enable-decoder=pcm_s24le --enable-demuxer=wav --enable-encoder=pcm_s16le --enable-encoder=pcm_s24le --enable-muxer=wav --enable-filter=acompressor --enable-filter=adeclick --enable-filter=adeclip --enable-filter=aecho --enable-filter=afade --enable-filter=aformat --enable-filter=agate --enable-filter=alimiter --enable-filter=amix --enable-filter=apad --enable-filter=atempo --enable-filter=atrim --enable-filter=bandpass --enable-filter=bandreject --enable-filter=dynaudnorm --enable-filter=equalizer --enable-filter=loudnorm --enable-filter=pan --enable-filter=amix --enable-filter=volume --enable-filter=anull
nm: /tmp/ffconf.1k35oTgY/test.o: file format not recognized
install prefix            /opt/ffmpeg
source path               /root/libav.js/build/ffmpeg-6.0.1
C compiler                emcc
C library
host C compiler           gcc
host C library            glibc
ARCH                      emscripten (generic)
big-endian                no
runtime cpu detection     no
debug symbols             yes
strip symbols             no
optimize for size         no
optimizations             yes
static                    yes
shared                    no
postprocessing support    no
network support           no
threading support         no
safe bitstream reader     yes
texi2html enabled         no
perl enabled              yes
pod2man enabled           yes
makeinfo enabled          no
makeinfo supports HTML    no
xmllint enabled           no

External libraries:
libopus

External libraries providing hardware acceleration:

Libraries:
avcodec                 avfilter                avutil                  swscale
avdevice                avformat                swresample

Programs:

Enabled decoders:
aac                     libopus                 pcm_s24le
flac                    pcm_s16le

Enabled encoders:
aac                     libopus                 pcm_s24le
flac                    pcm_s16le

Enabled hwaccels:

Enabled parsers:
aac                     ac3                     flac                    opus

Enabled demuxers:
flac                    mov                     wav
matroska                ogg

Enabled muxers:
flac                    matroska                mp4                     wav
ipod                    mov                     ogg                     webm

Enabled protocols:
data                    file

Enabled filters:
acompressor             agate                   atempo                  loudnorm
adeclick                alimiter                atrim                   pan
adeclip                 amix                    bandpass                volume
aecho                   anull                   bandreject
afade                   apad                    dynaudnorm
aformat                 aresample               equalizer

Enabled bsfs:
aac_adtstoasc           opus_metadata           pgs_frame_merge         vp9_superframe

Enabled indevs:

Enabled outdevs:

License: LGPL version 2.1 or later

WARNING: Unknown C compiler emcc, unable to select optimal CFLAGS
WARNING: unknown architecture emscripten
Yahweasel commented 5 months ago

Nothing there looks like an error. The build does "loop", in that it builds four different versions of everything for four different featuresets (threads times simd).

anishg-cn commented 5 months ago

@Yahweasel oh I see, it is still running, I will let you know if there are any errors.

I want to make a libav.js build which has opus, aac, vp8, vp9 and h264 encoder support. Can you please let me know the steps that I can take after this make command to use it as an npm package?

anishg-cn commented 5 months ago

@Yahweasel I think this is possible using the mediarecorder-openh264 build. but it is not present in 4.8.6 version.

Yahweasel commented 5 months ago

The mediarecorder-openh264 variant is not present in any builds and won't be for at least a couple years. Provoking the ire of the Misanthropic Patent Extortion Gang (MPEG) is not high on my priority list, and H.264 is still under patent.

Regarding publishing to npm, make release then make publish is what I use. Unfortunately, npm publish doesn't work, because exactly which files should be released is a bit delicate between Emscripten and having four builds. You can adapt it to publish what you need by changing the list of variants under the release: target of the Makefile to include what you want (and exclude anything you don't want), and updating package.json to have a scoped package name (and maybe change the default entry point to whatever variant you want). Then make release and make publish yourself and theoretically it should do the right thing. YMMV.

All that being said, I would advise against this course of action for other reasons. If you want to encode H.264, doing it in software in libav.js will be pretty slow. You should be using WebCodecs.

Yahweasel commented 5 months ago

Looking through configure, I don't think this is due to emcc. Do you have a host compiler in your PATH (gcc or clang)?

Yahweasel commented 5 months ago

Closed for lack of response.