Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flutter Agora startRecording() with RecorderStreamType.preview return error code -3 #2155

Open
2 of 5 tasks
DuyNguoiLinh opened this issue Dec 16, 2024 · 1 comment
Open
2 of 5 tasks

Comments

@DuyNguoiLinh
Copy link

DuyNguoiLinh commented Dec 16, 2024

Version of the agora_rtc_engine

6.3.2

Platforms affected

  • Android
  • iOS
  • macOS
  • Windows
  • Web

Steps to reproduce

  1. I want to record the local video stream from Agora, including audio, and save it to the device's gallery. However, I don't want to use Agora's Cloud Recording feature. Thanks in advance!
  2. I have used createMediaRecorder function with type is RecorderStreamType.Preview and startRecording with streamType is streamTypeBoth

Expected results

I want to record both video and audio and save the recording to the gallery

Actual results

I have successfully saved the video to the gallery, but it does not include audio.

Code sample

Code sample
 Future<void> startMediaRecording() async {
    _mediaRecorder ??= await _engine.createMediaRecorder(
        const RecorderStreamInfo(type: RecorderStreamType.preview));

    await _mediaRecorder?.setMediaRecorderObserver(MediaRecorderObserver(
      onRecorderStateChanged: (String channelId, int uid, RecorderState state,
          RecorderReasonCode error) {
        print(
            'onRecorderStateChanged channelId: $channelId, uid: $uid state: $state, error: $error');
      },
      onRecorderInfoUpdated: (String channelId, int uid, RecorderInfo info) {
        file = info.fileName ?? '';
        if (file.isNotEmpty) {
          GallerySaver.saveVideo(file).then((value) {
            print("done");
          });}

        print(
            'onRecorderInfoUpdated channelId: $channelId, uid: $uid, info: ${info
                .toJson()}');
      },
    ));

    Directory appDocDir = Platform.isAndroid
        ? (await getExternalStorageDirectory())!
        : await getApplicationDocumentsDirectory();

    String p = path.join(appDocDir.path, '${DateTime
        .now()
        .microsecondsSinceEpoch}.mp4');
    await _mediaRecorder
        ?.startRecording(MediaRecorderConfiguration(storagePath: p,
        streamType: MediaRecorderStreamType.streamTypeBoth,
        containerFormat: MediaRecorderContainerFormat.formatMp4,
    ));

    _recordingFileStoragePath = p;
    _isStartedMediaRecording = true;
  }

Screenshots or Video

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[Paste your output here]
@DuyNguoiLinh
Copy link
Author

DuyNguoiLinh commented Dec 17, 2024

I met error at startRecoding function in MediaRecoderImpl class

Screenshot 2024-12-17 at 16 05 30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant