Kagami / ffmpeg.js

Port of FFmpeg with Emscripten
Other
3.24k stars 329 forks source link

MP4 to PNG: output%d.png: Invalid argument, How can I edit the Makefile to enable PNG output? #189

Closed FrankDiao closed 1 year ago

FrankDiao commented 1 year ago

I encountered an issue when converting an MP4 video to PNG frames (output%d.png: Invalid argument). How can I edit the Makefile to enable PNG output?

Here's my code:

const result = ffmpeg({
    MEMFS: [{name: "demo.mp4",  data: testData}],
    arguments: ['-i', 'demo.mp4', 'output%d.png'],
    printErr: function(data) { console.error(data); },
})

The specific error message is as follows:

ffmpeg version n4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with emcc (Emscripten gcc/clang-like replacement) 1.39.11
configuration: --cc=emcc --ranlib=emranlib --enable-cross-compile --target-os=none --arch=x86 --disable-runtime-cpudetect --disable-asm --disable-fast-unaligned --disable-pthreads --disable-w32threads --disable-os2threads --disable-debug --disable-stripping --disable-safe-bitstream-reader --disable-all --enable-ffmpeg --enable-avcodec --enable-avformat --enable-avfilter --enable-swresample --enable-swscale --disable-network --disable-d3d11va --disable-dxva2 --disable-vaapi --disable-vdpau --enable-decoder=vp8 --enable-decoder=h264 --enable-decoder=vorbis --enable-decoder=opus --enable-decoder=mp3 --enable-decoder=aac --enable-decoder=pcm_s16le --enable-decoder=mjpeg --enable-decoder=png --enable-demuxer=matroska --enable-demuxer=ogg --enable-demuxer=mov --enable-demuxer=mp3 --enable-demuxer=wav --enable-demuxer=image2 --enable-demuxer=concat --enable-protocol=file --enable-filter=aresample --enable-filter=scale --enable-filter=crop --enable-filter=overlay --enable-filter=hstack --enable-filter=vstack --disable-bzlib --disable-iconv --disable-libxcb --disable-lzma --disable-sdl2 --disable-securetransport --disable-xlib --enable-zlib --enable-encoder=libvpx_vp8 --enable-encoder=libopus --enable-muxer=webm --enable-muxer=ogg --enable-muxer=null --enable-libopus --enable-libvpx --extra-cflags='-s USE_ZLIB=1 -I../libvpx/dist/include' --extra-ldflags=-L../libvpx/dist/lib
libavutil      56. 31.100 / 56. 31.100
libavcodec     58. 54.100 / 58. 54.100
libavformat    58. 29.100 / 58. 29.100
libavfilter     7. 57.100 /  7. 57.100
libswscale      5.  5.100 /  5.  5.100
libswresample   3.  5.100 /  3.  5.100
[aac @ 0x6a9470] Warning: not compiled with thread support, using thread emulation
[h264 @ 0x6af390] Warning: not compiled with thread support, using thread emulation
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'demo.mp4':

Metadata:
major_brand     : isom
minor_version   : 512
compatible_brands: isomiso2avc1mp41
comment         : vid:v0300fg10000ci2umlrc77u6bl3ua4r0
encoder         : Lavf58.76.100
Duration: 00:01:02.93, start: 0.000000, bitrate: 2027 kb/s
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name    : SoundHandler
Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 720x1280 [SAR 1:1 DAR 9:16], 1891 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name    : VideoHandler

[NULL @ 0x6c4f40] Unable to find a suitable output format for 'output%d.png'
output%d.png: Invalid argument

I followed this issue and removed the --disable-alloption, which resolved the issue. However, the resulting .js file size increased to 30MB.

What modifications should I make to the Makefile configuration to reduce the compiled JS file size while still enabling PNG output?

FrankDiao commented 1 year ago

https://stackoverflow.com/questions/62950128/kagami-ffmpeg-js-webm-to-images-got-unable-to-find-a-suitable-output-format-for/63011469#63011469

this works for me