Isvisoft/flutter_screen_recording

Recording Screen & audio is not working properly on IOS

danglu999 opened this issue · 4 comments

Hi,
Thanks for your great work.
Recording screen can work well, while I choose record screen & audio, only 1 second is recorded whenever I tap Stop Record.

Flutter version: 3.3.8

Hello @danglu999
I found one solution and I implemented this solution in my project it is working fine.
You need to change swift code in SwiftFlutterScreenRecordingPlugin this file. And it is package file.

switch rpSampleBufferType {
            case .video:

                print("writing sample....")

                if self.assetWriter?.status == AVAssetWriter.Status.unknown {

                    print("Started writing")
                    self.assetWriter?.startWriting()
                    self.assetWriter?.startSession(atSourceTime: CMSampleBufferGetPresentationTimeStamp(cmSampleBuffer))
                }

                if self.assetWriter.status == AVAssetWriter.Status.failed {
                    print("StartCapture Error Occurred, Status = \(self.assetWriter.status.rawValue), \(self.assetWriter.error!.localizedDescription) \(self.assetWriter.error.debugDescription)")
                     return
                }

                if self.assetWriter.status == AVAssetWriter.Status.writing {
                    if self.videoInput.isReadyForMoreMediaData {
                        print("Writing a sample")
                        if self.videoInput.append(cmSampleBuffer) == false {
                             print("problem writing video")
                        }
                     }
                 }

            case .audioMic:
                if self.audioMicInput.isReadyForMoreMediaData {
                    print("audioMic data added")
                    self.audioMicInput.append(cmSampleBuffer)
                }

            default:
                print("not a video sample")
            }

please add one case in above switch case case .audioMic: and also you need to add this switch condition in DispatchQueue.main.async

After that I able to record audio and video in iPhone real device. For your reference follow below link for solution : https://stackoverflow.com/questions/59613660/rpscreenrecorder-shared-startcapture-wont-write-keeps-failing

Is there any updates please ? It still doesn't work on ios

Any updates on this? or @jayu146 are you able to help me implement your solution? Do I need to make a fork of this project and then make the changes. I was a bit confused what to do with "also you need to add this switch condition in DispatchQueue.main.async"

@nikky78 @ttariq7
Screen and audio capture works for me, I implemented the suggested changes in my fork
Thanks @jayu146