Open kobimeridor opened 1 year ago
It's most likely a directory permissions issue, I have the same problem when using FFMPEG to create a file in both the app cache dir & temp
Hello, I had the same issue, and after adding a debug line here:
FFmpegKit.executeAsync(command, (session) async {
final state =
FFmpegKitConfig.sessionStateToString(await session.getState());
final returnCode = await session.getReturnCode();
debugPrint("FFmpeg process exited with state $state and rc $returnCode");
+ debugPrint("FFmpeg process output: ${await session.getOutput()}");
if (ReturnCode.isSuccess(returnCode)) {
debugPrint("FFmpeg processing completed successfully.");
debugPrint('Video successfully saved');
onSave(outputPath);
} else {
debugPrint("FFmpeg processing failed.");
debugPrint('Couldn\'t save the video');
onSave(null);
}
});
(ref: https://github.com/sbis04/video_trimmer/blob/main/lib/src/trimmer.dart#L250-L266)
I found out it was coming from ffmpeg itself, in my case.
I/flutter ( 8191): FFmpeg process output: ffmpeg version n5.1.2 Copyright (c) 2000-2022 the FFmpeg developers
I/flutter ( 8191): built with Android (7155654, based on r399163b1) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d)
I/flutter ( 8191): configuration: --cross-prefix=x86_64-linux-android- --sysroot=/files/android-sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/sysroot --prefix=/home/taner/Projects/ffmpeg-kit/prebuilt/android-x86_64-lts/ffmpeg --pkg-config=/usr/bin/pkg-config --enable-version3 --arch=x86_64 --cpu=x86_64 --target-os=android --disable-neon --enable-asm --enable-inline-asm --ar=x86_64-linux-android-ar --cc=x86_64-linux-android21-clang --cxx=x86_64-linux-android21-clang++ --ranlib=x86_64-linux-android-ranlib --strip=x86_64-linux-android-strip --nm=x86_64-linux-android-nm --extra-libs='-L/home/taner/Projects/ffmpeg-kit/prebuilt/android-x86_64-lts/cpu-features/lib -lndk_compat' --disable-autodetect --enable-cross-compile --enable-pic --enable-jni --enable-optimizations --enable-swscale --disable-static --enable-shared --enable-pthreads --enable-v4l2-m2m --disable-outdev=fbdev --disable-indev=fbdev --enable-small --disable-xmm-clobber-test --disable-debug --enable-lto --disable-neon-clobber-test --disable-programs --dis
I/flutter ( 8191): libavutil 57. 28.100 / 57. 28.100
I/flutter ( 8191): libavcodec 59. 37.100 / 59. 37.100
I/flutter ( 8191): libavformat 59. 27.100 / 59. 27.100
I/flutter ( 8191): libavdevice 59. 7.100 / 59. 7.100
I/flutter ( 8191): libavfilter 8. 44.100 / 8. 44.100
I/flutter ( 8191): libswscale 6. 7.100 / 6. 7.100
I/flutter ( 8191): libswresample 4. 7.100 / 4. 7.100
I/flutter ( 8191): Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/data/user/0/com.example.example/cache/file_picker/VID_20230715_140212.mp4':
I/flutter ( 8191): Metadata:
I/flutter ( 8191): major_brand : mp42
I/flutter ( 8191): minor_version : 0
I/flutter ( 8191): compatible_brands: isommp42
I/flutter ( 8191): creation_time : 2023-07-15T12:02:25.000000Z
I/flutter ( 8191): location : +37.4220-122.0839/
I/flutter ( 8191): location-eng : +37.4220-122.0839/
I/flutter ( 8191): com.android.version: 13
I/flutter ( 8191): Duration: 00:00:10.05, start: 0.000000, bitrate: 851 kb/s
I/flutter ( 8191): Stream #0:0[0x1](eng): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1280x720, 536 kb/s, 28.84 fps, 29.33 tbr, 90k tbn (default)
I/flutter ( 8191): Metadata:
I/flutter ( 8191): creation_time : 2023-07-15T12:02:25.000000Z
I/flutter ( 8191): handler_name : VideoHandle
I/flutter ( 8191): vendor_id : [0][0][0][0]
I/flutter ( 8191): Side data:
I/flutter ( 8191): displaymatrix: rotation of -90.00 degrees
I/flutter ( 8191): Stream #0:1[0x2](eng): Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, fltp, 12 kb/s (default)
I/flutter ( 8191): Metadata:
I/flutter ( 8191): creation_time : 2023-07-15T12:02:25.000000Z
I/flutter ( 8191): handler_name : SoundHandle
I/flutter ( 8191): vendor_id : [0][0][0][0]
I/flutter ( 8191): [mp4 @ 0x7e2379676f00] Could not find tag for codec amr_nb in stream #1, codec not currently supported in container
I/flutter ( 8191): Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
I/flutter ( 8191): Error initializing output stream 0:1 --
I/flutter ( 8191): Stream mapping:
I/flutter ( 8191): Stream #0:0 -> #0:0 (copy)
I/flutter ( 8191): Stream #0:1 -> #0:1 (copy)
2
I/flutter ( 8191):
Which after a quick search lead me to this issue: https://github.com/tanersener/mobile-ffmpeg/issues/560#issuecomment-792897661
So all I had to do to fix it was providing the parameter ffmpegCommand
:
_trimmer.saveTrimmedVideo(
startValue: _startValue,
endValue: _endValue,
+ ffmpegCommand: '-c:a aac -c:v copy',
+ customVideoFormat: '.mp4',
onSave: (outputPath) {
setState(() {
_progressVisibility = false;
});
debugPrint('OUTPUT PATH: $outputPath');
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (context) => Preview(outputPath),
),
);
},
);
Note that then I also need to add the customVideoFormat
, otherwise the outputFormatString
is not set, since we use a custom command.
Hello, I had the same issue, and after adding a debug line here:
FFmpegKit.executeAsync(command, (session) async { final state = FFmpegKitConfig.sessionStateToString(await session.getState()); final returnCode = await session.getReturnCode(); debugPrint("FFmpeg process exited with state $state and rc $returnCode"); + debugPrint("FFmpeg process output: ${await session.getOutput()}"); if (ReturnCode.isSuccess(returnCode)) { debugPrint("FFmpeg processing completed successfully."); debugPrint('Video successfully saved'); onSave(outputPath); } else { debugPrint("FFmpeg processing failed."); debugPrint('Couldn\'t save the video'); onSave(null); } });
(ref: https://github.com/sbis04/video_trimmer/blob/main/lib/src/trimmer.dart#L250-L266)
I found out it was coming from ffmpeg itself, in my case.
I/flutter ( 8191): FFmpeg process output: ffmpeg version n5.1.2 Copyright (c) 2000-2022 the FFmpeg developers I/flutter ( 8191): built with Android (7155654, based on r399163b1) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d) I/flutter ( 8191): configuration: --cross-prefix=x86_64-linux-android- --sysroot=/files/android-sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/sysroot --prefix=/home/taner/Projects/ffmpeg-kit/prebuilt/android-x86_64-lts/ffmpeg --pkg-config=/usr/bin/pkg-config --enable-version3 --arch=x86_64 --cpu=x86_64 --target-os=android --disable-neon --enable-asm --enable-inline-asm --ar=x86_64-linux-android-ar --cc=x86_64-linux-android21-clang --cxx=x86_64-linux-android21-clang++ --ranlib=x86_64-linux-android-ranlib --strip=x86_64-linux-android-strip --nm=x86_64-linux-android-nm --extra-libs='-L/home/taner/Projects/ffmpeg-kit/prebuilt/android-x86_64-lts/cpu-features/lib -lndk_compat' --disable-autodetect --enable-cross-compile --enable-pic --enable-jni --enable-optimizations --enable-swscale --disable-static --enable-shared --enable-pthreads --enable-v4l2-m2m --disable-outdev=fbdev --disable-indev=fbdev --enable-small --disable-xmm-clobber-test --disable-debug --enable-lto --disable-neon-clobber-test --disable-programs --dis I/flutter ( 8191): libavutil 57. 28.100 / 57. 28.100 I/flutter ( 8191): libavcodec 59. 37.100 / 59. 37.100 I/flutter ( 8191): libavformat 59. 27.100 / 59. 27.100 I/flutter ( 8191): libavdevice 59. 7.100 / 59. 7.100 I/flutter ( 8191): libavfilter 8. 44.100 / 8. 44.100 I/flutter ( 8191): libswscale 6. 7.100 / 6. 7.100 I/flutter ( 8191): libswresample 4. 7.100 / 4. 7.100 I/flutter ( 8191): Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/data/user/0/com.example.example/cache/file_picker/VID_20230715_140212.mp4': I/flutter ( 8191): Metadata: I/flutter ( 8191): major_brand : mp42 I/flutter ( 8191): minor_version : 0 I/flutter ( 8191): compatible_brands: isommp42 I/flutter ( 8191): creation_time : 2023-07-15T12:02:25.000000Z I/flutter ( 8191): location : +37.4220-122.0839/ I/flutter ( 8191): location-eng : +37.4220-122.0839/ I/flutter ( 8191): com.android.version: 13 I/flutter ( 8191): Duration: 00:00:10.05, start: 0.000000, bitrate: 851 kb/s I/flutter ( 8191): Stream #0:0[0x1](eng): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1280x720, 536 kb/s, 28.84 fps, 29.33 tbr, 90k tbn (default) I/flutter ( 8191): Metadata: I/flutter ( 8191): creation_time : 2023-07-15T12:02:25.000000Z I/flutter ( 8191): handler_name : VideoHandle I/flutter ( 8191): vendor_id : [0][0][0][0] I/flutter ( 8191): Side data: I/flutter ( 8191): displaymatrix: rotation of -90.00 degrees I/flutter ( 8191): Stream #0:1[0x2](eng): Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, fltp, 12 kb/s (default) I/flutter ( 8191): Metadata: I/flutter ( 8191): creation_time : 2023-07-15T12:02:25.000000Z I/flutter ( 8191): handler_name : SoundHandle I/flutter ( 8191): vendor_id : [0][0][0][0] I/flutter ( 8191): [mp4 @ 0x7e2379676f00] Could not find tag for codec amr_nb in stream #1, codec not currently supported in container I/flutter ( 8191): Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument I/flutter ( 8191): Error initializing output stream 0:1 -- I/flutter ( 8191): Stream mapping: I/flutter ( 8191): Stream #0:0 -> #0:0 (copy) I/flutter ( 8191): Stream #0:1 -> #0:1 (copy) 2 I/flutter ( 8191):
Which after a quick search lead me to this issue: tanersener/mobile-ffmpeg#560 (comment)
So all I had to do to fix it was providing the parameter
ffmpegCommand
:_trimmer.saveTrimmedVideo( startValue: _startValue, endValue: _endValue, + ffmpegCommand: '-c:a aac -c:v copy', + customVideoFormat: '.mp4', onSave: (outputPath) { setState(() { _progressVisibility = false; }); debugPrint('OUTPUT PATH: $outputPath'); Navigator.of(context).pushReplacement( MaterialPageRoute( builder: (context) => Preview(outputPath), ), ); }, );
Note that then I also need to add the
customVideoFormat
, otherwise theoutputFormatString
is not set, since we use a custom command.
still happening in my case :(
Hi, The
outputPath
inonSave
is null What is the wrong?video_trimmer: 2.0.0 Android Studio + emulator Pixel Pro 6