ffmpegwasm / ffmpeg.wasm

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

Scaling down a mov file just hangs #644

Open ijt opened 9 months ago

ijt commented 9 months ago

Describe the bug The React/Vite demo was working until I changed it to take a .mov file and scale it down to 480p. Then it failed to do the transcoding.

To Reproduce

git clone git@github.com:ijt/ffmpeg.wasm.git
cd ffmpeg.wasm/apps/react-vite-app/
npm i
npm run dev

Expected behavior After maybe 10s I expected to see the scaled down video in the player.

Instead, I waited 2 minutes with no result. The following output appeared in the console:

running ffmpeg.exec
App.tsx?t=1702404116709:33 message:  ffmpeg version 5.1.3 Copyright (c) 2000-2022 the FFmpeg developers
App.tsx?t=1702404116709:33 message:    built with emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.40 (5c27e79dd0a9c4e27ef2326841698cdd4f6b5784)
App.tsx?t=1702404116709:33 message:    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
App.tsx?t=1702404116709:33 message:    libavutil      57. 28.100 / 57. 28.100
App.tsx?t=1702404116709:33 message:    libavcodec     59. 37.100 / 59. 37.100
App.tsx?t=1702404116709:33 message:    libavformat    59. 27.100 / 59. 27.100
App.tsx?t=1702404116709:33 message:    libavdevice    59.  7.100 / 59.  7.100
App.tsx?t=1702404116709:33 message:    libavfilter     8. 44.100 /  8. 44.100
App.tsx?t=1702404116709:33 message:    libswscale      6.  7.100 /  6.  7.100
App.tsx?t=1702404116709:33 message:    libswresample   4.  7.100 /  4.  7.100
App.tsx?t=1702404116709:33 message:    libpostproc    56.  6.100 / 56.  6.100
App.tsx?t=1702404116709:33 message:  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mov':
App.tsx?t=1702404116709:33 message:    Metadata:
App.tsx?t=1702404116709:33 message:      major_brand     : qt  
App.tsx?t=1702404116709:33 message:      minor_version   : 0
App.tsx?t=1702404116709:33 message:      compatible_brands: qt  
App.tsx?t=1702404116709:33 message:      creation_time   : 2023-12-12T17:52:47.000000Z
App.tsx?t=1702404116709:33 message:      com.apple.quicktime.location.accuracy.horizontal: 4.740530
App.tsx?t=1702404116709:33 message:      com.apple.quicktime.location.ISO6709: +37.9871-105.6924+2448.085/
App.tsx?t=1702404116709:33 message:      com.apple.quicktime.make: Apple
App.tsx?t=1702404116709:33 message:      com.apple.quicktime.model: iPhone 13 Pro Max
App.tsx?t=1702404116709:33 message:      com.apple.quicktime.software: 16.6.1
App.tsx?t=1702404116709:33 message:      com.apple.quicktime.creationdate: 2023-12-12T10:52:47-0700
App.tsx?t=1702404116709:33 message:    Duration: 00:00:15.77, start: 0.000000, bitrate: 5669 kb/s
App.tsx?t=1702404116709:33 message:    Stream #0:0[0x1](und): Video: hevc (Main 10) (hvc1 / 0x31637668), yuv420p10le(tv, bt2020nc/bt2020/arib-std-b67), 1280x720, 5442 kb/s, 30 fps, 30 tbr, 600 tbn (default)
App.tsx?t=1702404116709:33 message:      Metadata:
App.tsx?t=1702404116709:33 message:        creation_time   : 2023-12-12T17:52:47.000000Z
App.tsx?t=1702404116709:33 message:        handler_name    : Core Media Video
App.tsx?t=1702404116709:33 message:        vendor_id       : [0][0][0][0]
App.tsx?t=1702404116709:33 message:        encoder         : HEVC
App.tsx?t=1702404116709:33 message:      Side data:
App.tsx?t=1702404116709:33 message:        DOVI configuration record: version: 1.0, profile: 8, level: 2, rpu flag: 1, el flag: 0, bl flag: 1, compatibility id: 4
App.tsx?t=1702404116709:33 message:        displaymatrix: rotation of -90.00 degrees
App.tsx?t=1702404116709:33 message:    Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 174 kb/s (default)
App.tsx?t=1702404116709:33 message:      Metadata:
App.tsx?t=1702404116709:33 message:        creation_time   : 2023-12-12T17:52:47.000000Z
App.tsx?t=1702404116709:33 message:        handler_name    : Core Media Audio
App.tsx?t=1702404116709:33 message:        vendor_id       : [0][0][0][0]
App.tsx?t=1702404116709:33 message:    Stream #0:2[0x3](und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
App.tsx?t=1702404116709:33 message:      Metadata:
App.tsx?t=1702404116709:33 message:        creation_time   : 2023-12-12T17:52:47.000000Z
App.tsx?t=1702404116709:33 message:        handler_name    : Core Media Metadata
App.tsx?t=1702404116709:33 message:    Stream #0:3[0x4](und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
App.tsx?t=1702404116709:33 message:      Metadata:
App.tsx?t=1702404116709:33 message:        creation_time   : 2023-12-12T17:52:47.000000Z
App.tsx?t=1702404116709:33 message:        handler_name    : Core Media Metadata
App.tsx?t=1702404116709:33 message:    Stream #0:4[0x5](und): Data: none (mebx / 0x7862656D), 34 kb/s (default)
App.tsx?t=1702404116709:33 message:      Metadata:
App.tsx?t=1702404116709:33 message:        creation_time   : 2023-12-12T17:52:47.000000Z
App.tsx?t=1702404116709:33 message:        handler_name    : Core Media Metadata
App.tsx?t=1702404116709:33 message:  Stream mapping:
App.tsx?t=1702404116709:33 message:    Stream #0:0 -> #0:0 (hevc (native) -> h264 (libx264))
App.tsx?t=1702404116709:33 

Screenshots None taken.

Desktop (please complete the following information):

Soykertje commented 9 months ago

Probably because that demo uses Multi-thread and is a known issue of FFMPEG getting stuck while using multi-thread mode.

More info: #597 #628

ijt commented 9 months ago

@Soykertje , I changed the exec line to this (just added "-threads", "1") and it worked:

await ffmpeg.exec(["-threads", "1", "-f", "mov", "-i", "input.mov",  "-vf", "scale=-2:480", "output.mov"]);