1

I'm trying to trim an audio file using ffmpeg_kit_flutter but I keep getting the error:

audio/path/output.mp3: Operation not permitted.

This is the ffmpeg command that I'm using:

final cmd="-y -i \"$audioPath\" -ss $audioStartTime -to $audioEndTime -c:a libmp3lame $outPutName";

And I've also tried :

final cmd="-y -i \"$audioPath\" -ss $audioStartTime -to $audioEndTime -c copy $outPutName";

But the error is still the same. I'm using the ffmpeg_kit_flutter_full_gpl package.

mortalis
  • 2,060
  • 24
  • 34
  • Have you seen https://stackoverflow.com/questions/73002134/trim-audio-flutter-ffmpeg-kit-flutter-package-not-working ? – MSalters Aug 24 '23 at 15:00
  • @MSalters yes, I've tried adding ext { flutterFFmpegPackage = "audio" } to gradle but still getting the error. – Black Eyed Beans Aug 24 '23 at 17:14
  • Try setting log level to debug for the ffmpeg package using this https://pub.dev/documentation/ffmpeg_kit_flutter/latest/ffmpeg_kit_config/FFmpegKitConfig/setLogLevel.html and check if you get more info in the logcat. Something about write permissions maybe. – mortalis Aug 24 '23 at 17:45
  • @mortalis I figured it out. It's a permission problem because my $outputname is based on a custom directory. When I use the default device temporary directory it seems to work. Problem now is making it work with my custom directory. – Black Eyed Beans Aug 24 '23 at 18:32
  • Don't know much about flutter, but in classical android dev I use all files permission to work with any path in my internal storage. Check this one https://developer.android.com/training/data-storage/manage-all-files, it requires to show a dialog when app starts to confirm the access to all files. It's what file managers do basically. – mortalis Aug 24 '23 at 18:58

1 Answers1

0

I managed to fix it. I had set my custom directory to:

/storage/emulated/0/Pictures/myapp 

Problem was Pictures directory does not allow apps to write audio files to it. Switching to:/storage/emulated/0/Music/myapp Fixed the problem