Git Product home page Git Product logo

Comments (5)

jeromewu avatar jeromewu commented on July 16, 2024 1

In the latest version (0.9.3) of ffmpeg.wasm, we are using a separate ffmpeg-core.wasm file by default, so this issue is fixed. ๐ŸŽ‰

from ffmpeg.wasm.

kirtirajsinh avatar kirtirajsinh commented on July 16, 2024 1

I'm getting an error : Uncaught (in promise) TypeError: Failed to fetch

I guess this is because the path is not set properly. here's my code :

`import React, { useCallback, useEffect, useState } from "react";
import { useDropzone } from "react-dropzone";
import { createFFmpeg, fetchFile } from "@ffmpeg/ffmpeg";

const ffmpeg = createFFmpeg({
  log: true,
  corePath: "/node_modules/@ffmpeg/core/dist/ffmpeg-core.js",
});

const VidPrompt = () => {
  const [videos, setVideos] = useState(null);
  const [frames, setFrames] = useState([]);
  const [ready, setReady] = useState(false);

  const onDrop = useCallback((acceptedFiles) => {
    setVideos(
      acceptedFiles.map((file) =>
        Object.assign(file, {
          preview: URL.createObjectURL(file),
        })
      )
    );
  }, []);

  useEffect(() => {
    (async () => {
      await ffmpeg.load();
      setReady(true);
    })();
  }, []);

  useEffect(() => {
    return () => {
      videos?.forEach((file) => URL.revokeObjectURL(file.preview));
    };
  }, [videos]);

  const { getRootProps, getInputProps, isDragActive } = useDropzone({
    onDrop,
  });

  const extractFrames = async (file) => {
    ffmpeg.FS("writeFile", "test.mp4", await fetchFile(file));
    await ffmpeg.run("-i", "test.mp4", "-vf", "fps=1", "out%d.png");
    const data = ffmpeg
      .FS("readdir", "/")
      .filter((item) => item.includes(".png"));
    setFrames(
      data.map((image) => {
        const data = ffmpeg.FS("readFile", image);
        const url = URL.createObjectURL(
          new Blob([data.buffer], { type: "image/png" })
        );
        return url;
      })
    );
  };

  useEffect(() => {
    if (ready && videos) {
      extractFrames(videos[0]);
    }
  }, [videos, ready]);

  return (
    <>
      {!videos && (
        <div
          {...getRootProps()}
          className="border-dashed border-2 border-red from-purple-400 py-32 px-32 flex flex-col justify-center items-center"
        >
          <input {...getInputProps()} />
          {isDragActive ? (
            <p>Drop the videos here ...</p>
          ) : (
            <p>Drag n drop some videos here, or click to select videos</p>
          )}
        </div>
      )}
      <div className="flex flex-row">
        {videos?.map((video, i) => (
          <div key={i}>
            <video src={video.preview} controls width="500" />
          </div>
        ))}
      </div>
      <div className="flex flex-row">
        {frames.map((frame, i) => (
          <div key={i}>
            <img src={frame} alt={`Frame ${i}`} />
          </div>
        ))}
      </div>
    </>
  );
};

export default VidPrompt;
`

without adding corepath to ffmpeg I'm getting the same error.

from ffmpeg.wasm.

jeromewu avatar jeromewu commented on July 16, 2024

Hi @meikidd,
This error is why we don't use @ffmpeg/core-wasm as our default core, it is an issue I am surveying, but haven't got too much progress so far.

from ffmpeg.wasm.

tpetry avatar tpetry commented on July 16, 2024

@meikidd Thanks for the tip, manually changing the url did really help.

@jeromewu I looked at chrome's network panel and can say the standard ffmpeg.js core is not loaded, it's only loading the wasm core. But i still see the extrem slow transcoding process to h264 like @meikidd.

from ffmpeg.wasm.

grkblood13 avatar grkblood13 commented on July 16, 2024

@tpetry manually changing the url to what?

from ffmpeg.wasm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.