Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing greenscreen to create transparent video RuntimeError: memory access out of bounds #786

Open
jonleinena opened this issue Oct 9, 2024 · 0 comments

Comments

@jonleinena
Copy link

jonleinena commented Oct 9, 2024

Describe the bug
When trying to remove the greenscreen background of a video to output a transparent bg video (using libvpx-vp9 and colorkey) throws a Memory acces out of bounds error.

To Reproduce

`

            await ffmpeg.writeFile('input.mp4', await fetchFile(processedVideoUrl));
            await ffmpeg.exec([
                '-i',
                'input.mp4',
                '-vf',
                'colorkey=#00DD01:similarity=0.3:blend=0.1',
                '-c',
                'copy',
                '-c:v',
                'libvpx-vp9',
                'output.webm'
            ]);


            const outputData = (await ffmpeg.readFile('output.webm')) as any;

           
            const webmBlob = new Blob([outputData.buffer], { type: 'video/webm' });
            const webmUrl = URL.createObjectURL(webmBlob);

`

Expected behavior
To remove the greenscreen background of the input video and output a transparent bg webm format video (works in console).

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Using in nextjs with typescript. Full execution log:

ffmpeg version 5.1.4 Copyright (c) 2000-2023 the FFmpeg developers
ffmpeg version 5.1.4 Copyright (c) 2000-2023 the FFmpeg developers
built with emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.40 (5c27e79dd0a9c4e27ef2326841698cdd4f6b5784)
built with emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.40 (5c27e79dd0a9c4e27ef2326841698cdd4f6b5784)
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' --extra-cxxflags='-I/opt/include -O3 -msimd128' --disable-pthreads --disable-w32threads --disable-os2threads --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
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' --extra-cxxflags='-I/opt/include -O3 -msimd128' --disable-pthreads --disable-w32threads --disable-os2threads --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
libavutil 57. 28.100 / 57. 28.100
libavutil 57. 28.100 / 57. 28.100
libavcodec 59. 37.100 / 59. 37.100
libavcodec 59. 37.100 / 59. 37.100
libavformat 59. 27.100 / 59. 27.100
libavformat 59. 27.100 / 59. 27.100
libavdevice 59. 7.100 / 59. 7.100
libavdevice 59. 7.100 / 59. 7.100
libavfilter 8. 44.100 / 8. 44.100
libavfilter 8. 44.100 / 8. 44.100
libswscale 6. 7.100 / 6. 7.100
libswscale 6. 7.100 / 6. 7.100
libswresample 4. 7.100 / 4. 7.100
libswresample 4. 7.100 / 4. 7.100
libpostproc 56. 6.100 / 56. 6.100
libpostproc 56. 6.100 / 56. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
Metadata:
Metadata:
major_brand : isom
major_brand : isom
minor_version : 512
minor_version : 512
compatible_brands: isomiso2avc1mp41
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.76.100
encoder : Lavf58.76.100
Duration: 00:00:16.10, start: 0.000000, bitrate: 3444 kb/s
Duration: 00:00:16.10, start: 0.000000, bitrate: 3444 kb/s
Stream #0:00x1: Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 480x848 [SAR 1:1 DAR 30:53], 3442 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
Stream #0:00x1: Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 480x848 [SAR 1:1 DAR 30:53], 3442 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
Metadata:
Metadata:
handler_name : VideoHandler
handler_name : VideoHandler
vendor_id : [0][0][0][0]
vendor_id : [0][0][0][0]
Multiple -c, -codec, -acodec, -vcodec, -scodec or -dcodec options specified for stream 0, only the last option '-c:v libvpx-vp9' will be used.
Multiple -c, -codec, -acodec, -vcodec, -scodec or -dcodec options specified for stream 0, only the last option '-c:v libvpx-vp9' will be used.
Stream mapping:
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> vp9 (libvpx-vp9))
Stream #0:0 -> #0:0 (h264 (native) -> vp9 (libvpx-vp9))
[swscaler @ 0x118d7f0] No accelerated colorspace conversion found from yuv420p to argb.
[swscaler @ 0x118d7f0] No accelerated colorspace conversion found from yuv420p to argb.
[libvpx-vp9 @ 0xdf1ae0] v1.13.1
[libvpx-vp9 @ 0xdf1ae0] v1.13.1
[libvpx-vp9 @ 0xdf1ae0] Neither bitrate nor constrained quality specified, using default CRF of 32
[libvpx-vp9 @ 0xdf1ae0] Neither bitrate nor constrained quality specified, using default CRF of 32
Output #0, webm, to 'output.webm':
Output #0, webm, to 'output.webm':
Metadata:
Metadata:
major_brand : isom
major_brand : isom
minor_version : 512
minor_version : 512
compatible_brands: isomiso2avc1mp41
compatible_brands: isomiso2avc1mp41
encoder : Lavf59.27.100
encoder : Lavf59.27.100
Stream #0:0(und): Video: vp9, yuva420p(tv, progressive), 480x848 [SAR 1:1 DAR 30:53], q=2-31, 30 fps, 1k tbn (default)
Stream #0:0(und): Video: vp9, yuva420p(tv, progressive), 480x848 [SAR 1:1 DAR 30:53], q=2-31, 30 fps, 1k tbn (default)
Metadata:
Metadata:
handler_name : VideoHandler
handler_name : VideoHandler
vendor_id : [0][0][0][0]
vendor_id : [0][0][0][0]
encoder : Lavc59.37.100 libvpx-vp9
encoder : Lavc59.37.100 libvpx-vp9
Side data:
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame= 1 fps=0.0 q=0.0 size= 1kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 1 fps=0.0 q=0.0 size= 1kB time=00:00:00.00 bitrate=N/A speed= 0x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant