dart Android应用程序崩溃应用音频(从远程url下载)视频编辑器sdk imgly视频

rqqzpn5f  于 11个月前  发布在  Android
关注(0)|答案(1)|浏览(89)

我正在使用视频编辑器sdk通过imgly编辑视频在我的Flutter应用程序它的工作正常的Ios,但在android如果我试图添加音频覆盖在视频上应用音频应用程序崩溃,我已经下载了音频文件从远程网址
video_editor_sdk:^3.0.0 minSdkVersion 24 compileSdkVersion 33 ext.Kotlin_version = '1.7.20'
下面是导航到视频编辑器屏幕的代码

void onEditPress() async {
      var filePath = Get.arguments["videoPath"];

      final List<Future<String>> downloads = audioSources
          .map((e) => downloadAudioFile(
              "https://storage.googleapis.com/ps_users/imgly-background-music/$e.mp3",
              "$e.mp3"))
          .toList();
      final List<String> localPaths = await Future.wait(downloads);

      // Convert the sources to valid `AudioClip`s.
      final List<AudioClip> audioClips = audioSources
          .asMap()
          .entries
          .map((clip) => AudioClip(clip.value, localPaths[clip.key],
              title: clip.value.replaceAll('_', ' ').toCapitalize().toString()))
          .toList();

      // Create [AudioOptions] to customize the audio tool.
      final audioOptions = AudioOptions(
          categories: [AudioClipCategory("", "", items: audioClips)]);

      Map<String, dynamic>? serialization;
      // Load a serialization from the assets folder.
      final serializationString = sharedPreferencesRepository.getString('editChanges');
      if (serializationString != null) {
        serialization = jsonDecode(serializationString);
      }

      // Create [SerializationOptions] to configure the serialization feature.
      final serializationOptions = SerializationOptions(
        enabled: true, // Enable the serialization feature.
        // For this example, the serialization should be returned as an object to simply logging it in the console.
        exportType: SerializationExportType.object,
      );

      // Create [ExportOptions] to apply the [serializationOptions].
      final exportOptions = ExportOptions(serialization: serializationOptions);

      // Create a [Configuration] instance.
      final configuration =
          Configuration(export: exportOptions, audio: audioOptions);

      //  go to editor screen
      final video = Video(filePath);

      Get.back();
      // Open the video editor and handle the export as well as any occurring errors.
      await VESDK.unlockWithLicense("assets/license/vesdk_license");
      final result = await VESDK.openEditor(video,
          configuration: configuration, serialization: serialization);
      if (result != null) {
// The user exported a new video successfully and the newly generated video is located at `result.video`.
        var videoPath = result.video;
      } else {
        // The user tapped on the cancel button within the editor.
        return;
      }
    }
  }

字符串
这里是从远程下载文件的功能

/// Downloads the file from the [url] to the local directory.
Future<String> downloadAudioFile(String url, String filename) async {
  final fileOutputDirectory = await getApplicationDocumentsDirectory();
  String fileLocation = "${fileOutputDirectory.path}/$filename";
  bool fileExist = _checkFileExistsSync(fileLocation);
  if (fileExist) {
    return fileLocation;
  } else {
    final client = HttpClient();
    final request = await client.getUrl(Uri.parse(url));
    final response = await request.close();
    final bytes = await consolidateHttpClientResponseBytes(response);
    final outputFile = File(fileLocation);
    await outputFile.writeAsBytes(bytes);
    return outputFile.path;
  }
}


和错误日志

I/CCodec  (26189): state->set(FLUSHING)
I/CCodec  (26189): state->set(FLUSHED)
I/CCodec  (26189): state->set(RESUMING)
I/CCodecConfig(26189): query failed after returning 7 values (BAD_INDEX)
W/Codec2Client(26189): query -- param skipped: index = 1342179345.
W/Codec2Client(26189): query -- param skipped: index = 2415921170.
I/CCodec  (26189): state->set(RUNNING)
I/CCodecBufferChannel(26189): [c2.sec.mp3.decoder#558] 4 initial input buffers available
I/CCodec  (26189): state->set(FLUSHING)
I/CCodec  (26189): state->set(FLUSHED)
I/CCodec  (26189): state->set(RESUMING)
I/CCodecConfig(26189): query failed after returning 7 values (BAD_INDEX)
W/Codec2Client(26189): query -- param skipped: index = 1342179345.
W/Codec2Client(26189): query -- param skipped: index = 2415921170.
I/CCodec  (26189): state->set(RUNNING)
I/CCodecBufferChannel(26189): [c2.sec.mp3.decoder#558] 4 initial input buffers available
D/CCodecBuffers(26189): [c2.android.aac.decoder#447:1D-Input.Impl[N]] codec released a buffer owned by client (index 2)
I/CCodec  (26189): state->set(FLUSHING)
I/CCodec  (26189): state->set(FLUSHED)
I/CCodec  (26189): state->set(RESUMING)
I/CCodecConfig(26189): query failed after returning 7 values (BAD_INDEX)
W/Codec2Client(26189): query -- param skipped: index = 1342179345.
W/Codec2Client(26189): query -- param skipped: index = 2415921170.
I/CCodec  (26189): state->set(RUNNING)
I/CCodecBufferChannel(26189): [c2.sec.mp3.decoder#558] 4 initial input buffers available
D/NativeAudioDecoder(26189): dequeueOutputBuffer timed out! /data/user/0/com.proshort.enterprise/app_flutter/summer_walk.mp3
I/CCodec  (26189): state->set(FLUSHING)
I/CCodec  (26189): state->set(FLUSHED)
I/CCodec  (26189): state->set(RESUMING)
I/CCodecConfig(26189): query failed after returning 7 values (BAD_INDEX)
W/Codec2Client(26189): query -- param skipped: index = 1342179345.
W/Codec2Client(26189): query -- param skipped: index = 2415921170.
I/CCodec  (26189): state->set(RUNNING)
I/CCodecBufferChannel(26189): [c2.sec.mp3.decoder#558] 4 initial input buffers available
D/NativeAudioDecoder(26189): dequeueOutputBuffer timed out! /data/user/0/com.proshort.enterprise/app_flutter/summer_walk.mp3
I/ViewRootImpl@2379ad7[FlutterVESDKActivity](26189): ViewPostIme pointer 0
I/ViewRootImpl@2379ad7[FlutterVESDKActivity](26189): ViewPostIme pointer 1
E/AndroidRuntime(26189): FATAL EXCEPTION: Thread-59
E/AndroidRuntime(26189): Process: com.proshort.enterprise, PID: 26189
E/AndroidRuntime(26189): java.io.FileNotFoundException
E/AndroidRuntime(26189):    at ly.img.android.pesdk.backend.decoder.Decoder.getUncachedInputStream(Decoder.java:151)
E/AndroidRuntime(26189):    at ly.img.android.pesdk.utils.UriHelper.copyAsFile(UriHelper.kt:63)
E/AndroidRuntime(26189):    at ly.img.android.pesdk.utils.UriHelper.copyAsFile$default(UriHelper.kt:62)
E/AndroidRuntime(26189):    at ly.img.android.pesdk.utils.UriHelper.convertToLocalUri(UriHelper.kt:207)
E/AndroidRuntime(26189):    at ly.img.android.pesdk.utils.DownloadUtils.downloadIfNeeded(DownloadUtils.kt:67)
E/AndroidRuntime(26189):    at ly.img.android.pesdk.backend.decoder.AudioSource.cacheUriIfNeeded(AudioSource.kt:88)
E/AndroidRuntime(26189):    at ly.img.android.pesdk.ui.panels.AudioGalleryToolPanel$onBeforeDetach$$inlined$runAsync$1.run(ThreadUtils.kt:435)
E/AndroidRuntime(26189):    at java.lang.Thread.run(Thread.java:1012)
D/AudioTrack(26189): stop(1061): called with 74424 frames delivered
D/BufferPoolAccessor2.0(26189): bufferpool2 0xe1ec6ed8 : 5(40960 size) total buffers - 4(32768 size) used buffers - 0/5 (recycle/alloc) - 4/800 (fetch/transfer)
D/BufferPoolAccessor2.0(26189): evictor expired: 1, evicted: 1
E/FirebaseCrashlytics(26189): Cannot send reports. Timed out while fetching settings.
I/Process (26189): Sending signal. PID: 26189 SIG: 9

gudnpqoy

gudnpqoy1#

当传递到音频剪辑时,您必须将文件路径更改为file:/path/to/your/file

相关问题