How to concat two videos and play it in flutter - flutter

var output =
"${rootPath}_${DateTime.now().microsecondsSinceEpoch}_M3.mp4";
String commandToExecute = '-i $latest -i $compress -filter_complex \'[0:0][1:0]concat=n=2:v=1:a=0[out]\' -map \'[out]\' $output';
await ffmpeg.execute(commandToExecute).then((rc) {
if (rc == 0) {
latest = output;
}
});
Tried this process but rc always shows 1 for android. how to solve it?

Related

flutter package for trim audio

I am trying to create a flutter app with trim audio. For that, I am looking for a library to trim a audio like video_trimmer.
I have tried the audiocutter package. But the package is old and it's use flutter_ffmpeg package.
But In my app used ffmpeg_kit_flutter package for video trimming. So I can't use audiocutter package.
Thanks in Advance
You can use following FFmpegKit command to cut audio.
double start = 1;
double end = 5;
var cmd = "-y -i \"$path\" -vn -ss $start -to $end -ar 16k -ac 2 -b:a 96k -acodec copy $outPath";
FFmpegKit.executeAsync(cmd, (session) async {
final returnCode = await session.getReturnCode();
print("returnCode $returnCode");
});

Merging Audio file with Video file in Flutter

I am working on an app which has similar functionality like Instagram reels. I want to know how do I merge a song(audio) while recording the video and then store them both as a video.
We will do using flutter_ffmpeg package.
create a command like this.
command = "-y -i $videoPath -i $audioPath -map 0:v -map 1:a -c:v copy "
"-shortest $savedFileLocation"
to execute command using
final FlutterFFmpeg _flutterFFmpeg = FlutterFFmpeg();
_flutterFFmpeg.execute(command.string).then((rc) {
statusCode = rc;
print("FFmpeg process exited with rc $rc");
return statusCode;
});

How drawtext on video using flutter ffmpeg 0.3.0

Hello I want to add text and image on video but my command not working with flutter ffmpeg 0.3.0
Here is my commands :
Working command code with only logo:
FlutterFFmpeg flutterFFmpeg = new FlutterFFmpeg();
flutterFFmpeg.execute('-i $video -i $logo -filter_complex "overlay=20:20" $output').then((rc) =>
print("FFmpeg process exited with rc $rc"));
Not Working command code with logo and text:
FlutterFFmpeg flutterFFmpeg = new FlutterFFmpeg();
flutterFFmpeg.execute('-i $video -i $logo -filter_complex "overlay=20:20" drawtext=text=mytext $output').then((rc) =>
print("FFmpeg process exited with rc $rc"));
Please help me
-i $video -i watermark.png -filter_complex "[0:v][1:v] overlay=5:2, drawtext=fontsize=20:fontcolor=white:fontfile=simple.ttf:text=hello" out.mp4
execute this command to add watermark with text in a flutter.
I was an error from fontfile don't forget to add fontfile correct path

Trim the video to 5 minutes

I am working on a demo project on which I have to get only 5 minutes video is there any way to trim the video to 5 minutes only. Currently, I am using FFmpeg flutter to get the video file and its metadata.
You can use any ffmpeg command in execute() method of flutter-ffmpeg package, to trim first 5 minutes of video
import 'package:flutter_ffmpeg/flutter_ffmpeg.dart';
....
final FlutterFFmpeg _flutterFFmpeg = new FlutterFFmpeg();
_flutterFFmpeg.execute("-ss 00:00:00 -i input.mp4 -to 00:05:00 -c copy output.mp4").then((rc) => print("FFmpeg process exited with rc $rc"));
You can use following command code to split a video.
final FlutterFFmpeg _flutterFFmpeg = new FlutterFFmpeg();
_flutterFFmpeg
.execute(
'-i videoplayback.mp4 -ss 00:00:50 -t 00:01:30 -c copy smallfile1.mp4')
.then((value) {
print('Got value ');
}).catchError((error) {
print('Error');
});
Start time is -ss 00:00:50 end time is 00:01:30
For getting video information you may can try following code.
fFmpeg.execute('-i video.mp4 -f null /dev/null').then((value) {
print('Got value ');
}).catchError((error) {
print('Error');
});

Execute linux command on Centos using dotnet core

I'm running a .NET Core Console Application on CentOS box. The below code is executing for normal command like uptime, but not executing for lz4 -dc --no-sparse vnp.tar.lz4 | tar xf - Logs.pdf:
try
{
var connectionInfo = new ConnectionInfo("server", "username", new PasswordAuthenticationMethod("username", "pwd"));
using (var client = new SshClient(connectionInfo))
{
client.Connect();
Console.WriteLine("Hello World!");
var command = client.CreateCommand("lz4 -dc --no-sparse vnp.tar | tar xf - Logs.pdf");
var result = command.Execute();
Console.WriteLine("yup ! UNIX Commands Executed from C#.net Application");
Console.WriteLine("Response came form UNIX Shell" + result);
client.Disconnect();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Expected output is Logs.pdf file needs to be extracted and saved in the current location. Can someone correct me where im
If application is running on Linux machine then you can try this also:
string command = "write your command here";
string result = "";
using (System.Diagnostics.Process proc = new System.Diagnostics.Process())
{
proc.StartInfo.FileName = "/bin/bash";
proc.StartInfo.Arguments = "-c \" " + command + " \"";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.Start();
result += proc.StandardOutput.ReadToEnd();
result += proc.StandardError.ReadToEnd();
proc.WaitForExit();
}
return result;