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

[Refactor] remove ffmpeg_kit dependency and add web implementation #147

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

maRci002
Copy link

@maRci002 maRci002 commented Apr 7, 2023

closes #146

This PR contains the following:

  • Removed the dependency on the ffmpeg_kit package.
  • Created FFmpegConfig to improve video and cover export functionality.
  • Added an example demonstrating how to export video and cover images using either ffmpeg_kit or ffmpeg_wasm, depending on the platform.
  • Updated the video_thumbnail version to 0.6.0.
  • Updated the project to work on the web.
  • Updated the documentation to reflect these changes.

Breaking changes

  • Replaced File with XFile in VideoEditorController.file.
  • Removed VideoEditorController.getMetaData.
  • Removed VideoEditorController.exportVideo.
  • Removed VideoEditorController.extractCover.

Still need:

Please refer to the redleafsofts/flutter_ffmpeg_wasm#1 README for instructions on how to run ffmpeg_wasm on the web.

This is what it looks like on the web (using HTML renderer):

video_editor_on_the_web.mp4

@maRci002 maRci002 mentioned this pull request Apr 7, 2023
@maRci002 maRci002 changed the title [Refactor] remove ffmpeg-kit dependency, use XFile, add FFmpegConfig, and update VideoThumbnail version [Refactor] remove ffmpeg-kit dependency Apr 7, 2023
@maRci002 maRci002 changed the title [Refactor] remove ffmpeg-kit dependency [Refactor] remove ffmpeg_kit dependency Apr 7, 2023
@maRci002 maRci002 changed the title [Refactor] remove ffmpeg_kit dependency [Refactor] remove ffmpeg_kit dependency and add web implementation Apr 12, 2023
@maRci002 maRci002 marked this pull request as ready for review April 12, 2023 22:31
@LeGoffMael
Copy link
Owner

Thank you a lot for your work this is really great !
I agree that removing ffmpeg from this package is the good approach.

However the web support cannot seems to be published without the video_thumbnail package being updated first.
So this might have to wait a bit.

@LeGoffMael
Copy link
Owner

I have a question about why XFile is needed here instead of simply File ?

@maRci002
Copy link
Author

I have a question about why XFile is needed here instead of simply File ?

Because you would have to import dart:io which won't work on web.

The image_picker library also returns an XFile, which is smart enough to hold a File when the runtime is VM-based and holds a Blob when the runtime is web-based. In addition, the latest version of video_thumbnail library, which is still waiting for a PR to be merged, also returns an XFile object instead of a string path.

@maRci002
Copy link
Author

On the web, when you want to play a Blob, it is treated as a network URL. Therefore, you have to use VideoPlayerController.network instead of VideoPlayerController.file this is done automatically by this package. Currently, VideoEditorController.file takes an XFile. Perhaps we could split it up into file and network constructors. Since export is decoupled from this plugin, it is up to the developer to read bytes for export.

VideoPlayerController _controller = kIsWeb ? VideoPlayerController.network(widget.video.path) : VideoPlayerController.file(File(widget.video.path))

@LeGoffMael LeGoffMael added the enhancement New feature or request label Jun 26, 2023
@hwakstar
Copy link

Hello
I want to run this package on web.
I checked the above mp4 file and I am trying about it.
Please help me as soon as possible.
Thanks.

@Megatronicus
Copy link

What's the status for web?
Read the above discussions, this seems important: "However the web support cannot seems to be published without the video_thumbnail package being updated first.
So this might have to wait a bit."

Is it done? Can we use the web version of video_editor?

Thank you in advance.

@maRci002
Copy link
Author

maRci002 commented Dec 18, 2023

Can we use the web version of video_editor?

  video_thumbnail:
    git:
      url: https://github.com/maRci002/video_thumbnail.git
      ref: feat-web_implementation
      path: video_thumbnail
  video_editor:
    git:
      url: git@github.com:maRci002/video_editor.git
      ref: feature/separate-video-export

What's the status for web?

The primary focus of this PR was on two aspects: removing the ffmpeg_kit dependency and adding a web implementation.

PR #156 had already removed the ffmpeg_kit dependency and introduced some helper functionality to generate ffmpeg commands. My changes are quite similar; however, they have resulted in some conflicts. Therefore, my first step is to make this PR compatible with the current master branch.

The web implementation will introduce some breaking changes, such as the use of XFile instead of File, unless the VideoEditorController.networkUrl constructor is used. XFile is beneficial as it holds important information like the mimeType and allows easy access to bytes, which is useful for working with the web ffmpeg library.

However the web support cannot seems to be published without the video_thumbnail package being updated first.
So this might have to wait a bit.

It appears that the video_thumbnail package has been abandoned. I am considering forking it to enhance its capabilities, such as supporting web or providing support for a Stream of thumbnails. This approach would be more efficient, as the underlying generator (such as AVAssetImageGenerator or MediaMetadataRetriever) wouldn't need to be opened and closed repeatedly but could remain open as needed for each frame.

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

Successfully merging this pull request may close these issues.

Enable web platform
5 participants