Skip to content

Instantly share code, notes, and snippets.

View gonzo-oin's full-sized avatar

Stéphane Gérardot gonzo-oin

  • Music World Media
  • France
View GitHub Profile
### Keybase proof
I hereby claim:
* I am gonzo-oin on github.
* I am gonzooin (https://keybase.io/gonzooin) on keybase.
* I have a public key ASAIBVagUFeEuqNAiurEM8GZJpSAjQb9w7zw2Xrvjq-UWgo
To claim this, I am signing this object:
@gonzo-oin
gonzo-oin / gist:b300dc7391f83bddd9bcd60aae4614b7
Created April 1, 2019 16:53
AVAsset with separate video and audio urls (iOS)
let videoAsset = AVAsset(url: videoStreamURL)
var duration: CMTime!
if (CMTimeGetSeconds(audioAsset.duration) < CMTimeGetSeconds(videoAsset.duration)) {
duration = audioAsset.duration;
} else {
duration = videoAsset.duration;
}
var compo = AVMutableComposition()
let track = compo.addMutableTrack(withMediaType: .audio, preferredTrackID: kCMPersistentTrackID_Invalid)
@gonzo-oin
gonzo-oin / DuplicateProtocol.swift
Last active November 8, 2017 10:51
Swift Duplicatable protocol: Duplicate class object that implement Codable.
import Foundation
protocol Duplicatable {}
extension Duplicatable where Self: Codable {
func duplicate() throws -> Self {
return try JSONDecoder().decode(Self.self, from: JSONEncoder().encode(self))
}
}
//
// UIViewController.h
// UIKit
//
// Copyright (c) 2007-2013, Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKitDefines.h>
#import <UIKit/UIApplication.h>