Quantcast
Channel: Active questions tagged frames - Stack Overflow
Viewing all articles
Browse latest Browse all 55

flutter_ffmpeg combine frames to make a video

$
0
0

I have a function combineFramesToVideo to combine several of frames using flutter_ffmpeg package to create video.

Future<void> combineFramesToVideo(  String framesDirectory, String outputVideoPath) async {final flutterFFmpeg = FlutterFFmpeg();// List all files in the frames directoryfinal directory = Directory(framesDirectory);final files = await directory    .list()    .where((entity) => entity is File && entity.path.endsWith('.jpg'))    .toList();// Print out the list of files to verifyprint('Found ${files.length} frames:');files.forEach((file) {  print(file.path);});// Generate input arguments for FFmpegfinal List<String> inputArguments = ['-framerate', '15'];files.forEach((file) {  inputArguments.addAll(['-i', file.path]);});// Execute FFmpeg command to combine frames into a videofinal arguments = [  ...inputArguments, // Input frame files'-c:v', 'mpeg4', // Video codec'-pix_fmt', 'yuv420p', // Pixel format'-y', outputVideoPath, // Output video file path];final result = await flutterFFmpeg.executeWithArguments(arguments);// Print out FFmpeg command arguments to verifyprint('FFmpeg command arguments:');print(inputArguments);// Print out FFmpeg command resultprint('FFmpeg execution result: $result');if (result == 0) {  print('Video creation succeeded');} else {  print('Video creation failed');}

}

This is my first time using this API. The problem is when i run the application and call the function it will show a log like

I/mobile-ffmpeg( 7588): Input #327, image2, from 'directoryPath/frame_1714372990083.jpg':I/mobile-ffmpeg( 7588):   Duration:I/mobile-ffmpeg( 7588): 00:00:00.04I/mobile-ffmpeg( 7588): , start:I/mobile-ffmpeg( 7588): 0.000000I/mobile-ffmpeg( 7588): , bitrate:I/mobile-ffmpeg( 7588): 216230 kb/sI/mobile-ffmpeg( 7588):I/mobile-ffmpeg( 7588):     Stream #327:0I/mobile-ffmpeg( 7588): : Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1910x1080 [SAR 1:1 DAR 191:108]I/mobile-ffmpeg( 7588): ,I/mobile-ffmpeg( 7588): 25 tbr,I/mobile-ffmpeg( 7588): 25 tbn,I/mobile-ffmpeg( 7588): 25 tbcI/mobile-ffmpeg( 7588):I/mobile-ffmpeg( 7588): Stream mapping:I/mobile-ffmpeg( 7588):   Stream #0:0 -> #0:0...I/mobile-ffmpeg( 7588): frame=    1 fps=0.0 q=6.0 Lsize=     124kB time=00:00:00.00 bitrate=15623507.7kbits/s speed=0.00028x

A video is created but only 1 frame is added in the output video (see the last line of the log above). I am not sure why the other frames are not appended or save in the video. You can see in the log, the index of the input frame is 327 so there are around 327 frames. Also i notice the the stream mapping is 0 -> 0. Can someone help me how to solve the issue. Thank you


Viewing all articles
Browse latest Browse all 55

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>