Home > Blockchain >  Combine multiple videos in one video in flutter app
Combine multiple videos in one video in flutter app

Time:12-12

I want to combine multiple videos that user uploads from gallery in Flutter app and merge them as one video before uploading to the server. Anyone can help me in this issue

I tried FFmpeg Cli and Ffmpeg

CodePudding user response:

To combine multiple videos into one using Flutter, you can use a library called video_merger. This library allows you to merge multiple videos together and save the result as a new video file.

Example:

    import 'package:video_merger/video_merger.dart';

// Create a list of video paths
List<String> videoPaths = [
  '/path/to/video1.mp4',
  '/path/to/video2.mp4',
  '/path/to/video3.mp4',
];

// Create a VideoMerger instance
final videoMerger = VideoMerger();

// Merge the videos and save the result to a new file
final outputPath = await videoMerger.merge(videoPaths, '/path/to/output.mp4');

// Upload the output video to a server
uploadVideo(outputPath);

You can also use the FFmpeg library to combine multiple videos together. This library provides a wrapper around the ffmpeg command-line tool, which can be used to perform various operations on video files, including merging multiple videos into one.

Here's an example of how you can use FFmpeg to combine multiple videos:

import 'package:ffmpeg/ffmpeg.dart';

// Create a list of video paths
List<String> videoPaths = [
  '/path/to/video1.mp4',
  '/path/to/video2.mp4',
  '/path/to/video3.mp4',
];

// Create an instance of the FFmpeg class
final ffmpeg = FFmpeg();

// Merge the videos and save the result to a new file
final outputPath = await ffmpeg.merge(videoPaths, '/path/to/output.mp4');

// Upload the output video to a server
uploadVideo(outputPath);

CodePudding user response:

Please check here: Flutter (Dart): Merge two videos and view the new output in the device's gallery (photos) Will it helpful? Are you expecting something like this?

  • Related