imaginary-cloud / CameraManager

Simple Swift class to provide all the configurations you need to create custom camera view in your app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to record video on MP4

JesusRojass opened this issue · comments

Good morning

I'm doing this school project where I need to record a video and then send it to a web server to play it
I record the video and it says it's mp4 but when I upload it to the server it uploads as a qt file (quicktime, it happens the same with.mov files recorded straight out of the phone)

The server logs out that it's videofile.mp4, but the mimetype says quicktime

Also the server only accepts .mp4 files so the video is always rejected

what can I do

I figured it out bu thanks anyways

I fixed this my converting it even though it says it "records in mp4"

Just add this piece of code after the video record is finished on the Camera View Controller

let destinationPath = NSTemporaryDirectory() + "fileName.mp4"
let newVideoPath: NSURL = NSURL(fileURLWithPath: destinationPath as String)
let exporter = AVAssetExportSession(asset: avAsset, presetName:AVAssetExportPresetHighestQuality)!
exporter.outputURL = newVideoPath as URL
exporter.outputFileType = AVFileType.mp4
exporter.shouldOptimizeForNetworkUse = true
exporter.exportAsynchronously(completionHandler: {
	print("NewPath:\(String(describing: newVideoPath.relativePath))")
})

Thanks for the plugin, cheers! 🤯