Recording RTSP stream using MobileVLCKit iOS
Posted: 09 Apr 2019 12:51
I am using MobileVLCKit to stream from an RTSP source. I need to capture this stream, so far I have tried to use `startRecording(atPath:) to save the stream to the iOS documents directory but I cannot see any file being generated in the documents directory. Here is the code I am trying:
Code: Select all
import Foundation
class ViewController: UIViewController, VLCMediaPlayerDelegate {
@IBOutlet weak var videoView: UIView!
@IBOutlet weak var playbackView: UIView!
var player: VLCMediaPlayer = VLCMediaPlayer()
let url = URL(string: "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov")
let documents = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as! String
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let media = VLCMedia(url: url!)
player.media = media
player.delegate = self
player.drawable = videoView
player.startRecording(atPath: documents)
player.play()
}
@IBAction func stopButtonPressed(_ sender: UIButton) {
player.stop()
player.stopRecording()
}
}