ffmpegwasm / ffmpegwasm/ffmpeg.wasm

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

Ouverte
#350 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
C
Étoiles
17.8k
Forks
1.1k
Métriques de merge des PR
Aucune PR mergée en 30 j

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.

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.