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

Saving video to device, Couldn't write a frame #353

Open
tomihr opened this issue Feb 11, 2021 · 4 comments
Open

Saving video to device, Couldn't write a frame #353

tomihr opened this issue Feb 11, 2021 · 4 comments

Comments

@tomihr
Copy link

tomihr commented Feb 11, 2021

I am tring to save the video to the device, but I didn't succeed yet.
I am setting session property session?.saveLocalVideo = true
and providing file name and path, here is my code:

session?.saveLocalVideo = true
let now = NSDate()
let nowTimeStamp = self.getCurrentTimeStampWOMiliseconds(dateToConvert: now)
pathToMovie = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as NSString).appendingPathComponent(nowTimeStamp + "_UMOO.mp4")
print("pathToMovie: " + pathToMovie)
let movieURL:NSURL = NSURL(fileURLWithPath: pathToMovie)
print("movieURL: " + movieURL.absoluteString!)
session?.saveLocalVideoPath = movieURL as URL

Do I have to do something else?

Thanks

@harsh12312
Copy link

harsh12312 commented Feb 20, 2021

   `session?.saveLocalVideo = true
    let cachesDir = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).map(\.path)[0]
    let movieName = "\(UUID().uuidString).mp4"
    let pathToMovie = URL(fileURLWithPath: cachesDir).appendingPathComponent(movieName).path
    session?.saveLocalVideoPath = URL(fileURLWithPath: pathToMovie)`

Then in liveStateDidChange, case stop

` if let videoURL = self.session.saveLocalVideoPath{
UISaveVideoAtPathToSavedPhotosAlbum(videoURL.relativePath, self, #selector(self.image(_:didFinishSavingWithError:contextInfo:)), nil)
}

//MARK: - Save Video callback
@objc func image(_ image: UIImage, didFinishSavingWithError error: Error?, contextInfo: UnsafeRawPointer) {
    if let error = error {
        print(error.localizedDescription)
    } else {
        print("Success")
    }

}`

@tomihr
Copy link
Author

tomihr commented Feb 21, 2021

Thanks, will try.

@tomihr
Copy link
Author

tomihr commented Feb 21, 2021

Is it possible to save the video without streaming it to the RMTP server, just to have a save mode that will
not relay on RMTP streaming?

Thanks

@tomihr
Copy link
Author

tomihr commented Feb 26, 2021

I stumbled on one issue, if I put the app in the background ad then activate it again and move it to the foreground, I got this message:

Couldn't write a frame

No matter am I recording or not, and streaming is broken.
How do I fix this?

Thanks

@tomihr tomihr changed the title Saving video to device Saving video to device, Couldn't write a frame Feb 26, 2021
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

2 participants