ffmpegwasm / ffmpegwasm/ffmpeg.wasm

Pass in base64 encoded images as input (invalid PNG signature error)

Open
#350 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
17.8k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
I'm receiving an error when passing in a base64 encoded image as the input, here are what I think are the relevant parts of the logs:

`Invalid PNG signature `
`Consider increasing the value for the 'analyzeduration' and 'probesize' options`
`Input #1, image2, from 'image.png':`
`Error while decoding stream #1:0: Invalid data found when processing input`
`Cannot determine format of input stream 1:0 after EOF`
`Error marking filters as finished`
`Conversion failed!`

My code is this:

fetches the video file:
`ffmpeg.FS('writeFile', name, await fetchFile(files[0]))`

this is the base64 data uri:
`await ffmpeg.FS('writeFile', 'image.png', payload.elements[0].img)`

my complex filter is a variable string, but I've eliminated this as being related to the cause of the issue:
`await ffmpeg.run('-i', name, '-i', 'image.png', '-filter_complex', `${complexFilter}`, '-map', '[out_v]' , '-pix_fmt', 'yuv420p', 'output.mp4')`

I've tried passing it in as a base64 data uri, as just the raw base64 data, as a blob, I can't seem to work out the correct syntax. I've looked through the example scripts, but they retrieve from a local directory rather than encoded images. I'd appreciate it if anyone could help me out with the syntax here.

If it's helpful, here's a link to the base64 string that's inside of payload.elements[0].img:
https://pastebin.com/EZNewbWX

[This site](https://codebeautify.org/base64-to-image-converter) can be used to decode it and show an image, which verifies the base64 data is valid.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.