ffmpegwasm / ffmpeg.wasm

FFmpeg for browser, powered by WebAssembly
https://ffmpegwasm.netlify.app
MIT License
14.08k stars 822 forks source link

ffmpeg.exec hangs forever without error when I try to resize a video, but only when using the multithreaded version, while using a Chromium based browser or Safari. No issues on Firefox. #772

Open Boux opened 1 month ago

Boux commented 1 month ago

Describe the bug If I try to resize a video, either with the -s param or something like -vf scale=-2:480, the execution will simply hang forever and never give an error, but only when using the core-mt version (umd). If I try with the single-threaded version (core), everything works fine

To Reproduce

Expected behavior ffmpeg.exec should not hang and successfully encode the video, or at the very least give an error.

Logs Here are the logs (directly from ffmpeg.on("log" ...)

[FFmpeg] ffmpeg version 5.1.4 Copyright (c) 2000-2023 the FFmpeg developers
[FFmpeg]   built with emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.40 (5c27e79dd0a9c4e27ef2326841698cdd4f6b5784)
[FFmpeg]   configuration: --target-os=none --arch=x86_32 --enable-cross-compile --disable-asm --disable-stripping --disable-programs --disable-doc --disable-debug --disable-runtime-cpudetect --disable-autodetect --nm=emnm --ar=emar --ranlib=emranlib --cc=emcc --cxx=em++ --objcc=emcc --dep-cc=emcc --extra-cflags='-I/opt/include -O3 -msimd128 -sUSE_PTHREADS -pthread' --extra-cxxflags='-I/opt/include -O3 -msimd128 -sUSE_PTHREADS -pthread' --enable-gpl --enable-libx264 --enable-libx265 --enable-libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libopus --enable-zlib --enable-libwebp --enable-libfreetype --enable-libfribidi --enable-libass --enable-libzimg
[FFmpeg]   libavutil      57. 28.100 / 57. 28.100
[FFmpeg]   libavcodec     59. 37.100 / 59. 37.100
[FFmpeg]   libavformat    59. 27.100 / 59. 27.100
[FFmpeg]   libavdevice    59.  7.100 / 59.  7.100
[FFmpeg]   libavfilter     8. 44.100 /  8. 44.100
[FFmpeg]   libswscale      6.  7.100 /  6.  7.100
[FFmpeg]   libswresample   4.  7.100 /  4.  7.100
[FFmpeg]   libpostproc    56.  6.100 / 56.  6.100
[FFmpeg] Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input_1503edd15afe4f709ee5c8c782ca25dd.mp4':
[FFmpeg]   Metadata:
[FFmpeg]     major_brand     : isom
[FFmpeg]     minor_version   : 512
[FFmpeg]     compatible_brands: isomiso2avc1mp41
[FFmpeg]     encoder         : Lavf59.16.100
[FFmpeg]   Duration: 00:02:19.10, start: 0.000000, bitrate: 1929 kb/s
[FFmpeg]   Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080, 1729 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
[FFmpeg]     Metadata:
[FFmpeg]       handler_name    : VideoHandler
[FFmpeg]       vendor_id       : [0][0][0][0]
[FFmpeg]   Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 191 kb/s (default)
[FFmpeg]     Metadata:
[FFmpeg]       handler_name    : SoundHandler
[FFmpeg]       vendor_id       : [0][0][0][0]
[FFmpeg] Stream mapping:
[FFmpeg]   Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
[FFmpeg]   Stream #0:1 -> #0:1 (aac (native) -> aac (native))
(this is where it hangs)

Desktop

Additional context If there are issues with reproducing the bug, I'm not against the idea of doing a video call and sharing my screen

Boux commented 1 month ago

Followup: for some crazy unexplained reason, after MUCH trial and error, if I add the params "-c:a", "copy", so something like await ffmpeg.exec(['-i', name, "-c:a", "copy", '-filter:v', 'scale=-2:480', 'output.mp4']);, everything works. No idea why, I'm just gonna do this, I'm glad it works and at this point I don't even care to know why, yes it's currently 4:30 am.

0xJacky commented 2 weeks ago

Same issue

vayron commented 2 weeks ago

0.12.5~0.12.10 same issue, the old version 0.11.5 work

yafkari commented 6 days ago

Hahahha the solution of @Boux really worked, I literally just added "-c:a", "copy" to the parameters and it started to process the input.

Before that I was just getting to the logging of the streams info like that:

image

(Using @ffmpeg/core-mt@0.12.6/dist/umd)

EDIT: Still have the issue when trying to do things like -i myfile.png myfile.webp though. (But jpg to webp worked)

EDIT2: While trying to convert an mp4 to avi without -c:v copy, it was still hanging forever even with the c:a copy trick. By setting manually c:v libx264 it started.