Transcoding fMP4 to HLS while writing on iOS using FFmpeg

Strictly speaking you don’t need to transcode the fmp4 if it contains h264+aac, you just need to repackage the sample data as TS. (using ffmpeg -codec copy or gpac) Wrt. alignment (1.2) I suppose this all depends on your encoder settings (frame rate, sample rate and GOP size). It is certainly possible to make sure … Read more

How can I reduce the file size of a video created with UIImagePickerController?

With AVCaptureSession and AVAssetWriter you can set the compression settings as such: NSDictionary *settings = @{AVVideoCodecKey:AVVideoCodecH264, AVVideoWidthKey:@(video_width), AVVideoHeightKey:@(video_height), AVVideoCompressionPropertiesKey: @{AVVideoAverageBitRateKey:@(desired_bitrate), AVVideoProfileLevelKey:AVVideoProfileLevelH264Main31, /* Or whatever profile & level you wish to use */ AVVideoMaxKeyFrameIntervalKey:@(desired_keyframe_interval)}}; AVAssetWriterInput* writer_input = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:settings]; Edit: I guess if you insist on using the UIImagePicker to create the movie in the … Read more

AVAudioPlayer not playing any sound

I found the solution and it’s related to something I didn’t mention and didn’t think about: I’m compiling with Automatic Reference Counting (ARC). ARC inserts a release call to the audio player, so it’s deallocated right after leaving the method where it is created. It has nothing to do with AVAudioPlayer but with ARC. In … Read more

AVCaptureVideoPreviewLayer orientation – need landscape

Swift 5.5, Xcode 13.2 private func updatePreviewLayer(layer: AVCaptureConnection, orientation: AVCaptureVideoOrientation) { layer.videoOrientation = orientation self.previewLayer?.frame = view.bounds } override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() if let connection = self.previewLayer?.connection { let currentDevice = UIDevice.current let orientation: UIDeviceOrientation = currentDevice.orientation let previewLayerConnection: AVCaptureConnection = connection if previewLayerConnection.isVideoOrientationSupported { switch orientation { case .portrait: self.updatePreviewLayer(layer: previewLayerConnection, orientation: .portrait) … Read more

How to play audio in background with Swift?

You need to set your app Capabilities Background Modes (Audio and AirPlay) and set your AVAudioSession category to AVAudioSessionCategoryPlayback and set it active From Xcode 11.4 • Swift 5.2 do { try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default, options: [.mixWithOthers, .allowAirPlay]) print(“Playback OK”) try AVAudioSession.sharedInstance().setActive(true) print(“Session is Active”) } catch { print(error) }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)