IOS Video Compression Swift iOS 8 corrupt video file

This answer has been completely rewritten and annotated to support Swift 4.0. Keep in mind that changing the AVFileType and presetName values allows you to tweak the final output in terms of size and quality. import AVFoundation extension ViewController: AVCaptureFileOutputRecordingDelegate { // Delegate function has been updated func fileOutput(_ output: AVCaptureFileOutput, didFinishRecordingTo outputFileURL: URL, from … Read more

Detect if PDF file is correct (header PDF) [closed]

I check Header PDF like this: public bool IsPDFHeader(string fileName) { byte[] buffer = null; FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); long numBytes = new FileInfo(fileName).Length; //buffer = br.ReadBytes((int)numBytes); buffer = br.ReadBytes(5); var enc = new ASCIIEncoding(); var header = enc.GetString(buffer); //%PDF−1.0 // If you are loading it into … Read more