Skip to content

Instantly share code, notes, and snippets.

View depthlove's full-sized avatar

depthlove depthlove

View GitHub Profile
#import <AVFoundation/AVFoundation.h>
@interface AVCaptureDevice(Additions)
+ (NSArray<AVCaptureDevice *>*)inputCameraDevices;
- (BOOL)isBuiltIn;
- (BOOL)hasVideoMedia;
- (BOOL)canOpenCamera;
@end
@AllanChen
AllanChen / rgba2yuv.m
Last active May 20, 2024 08:53
UIImage to YUV420f NV12 (iOS)
-(CVPixelBufferRef)imageToYUVPixelBuffer:(UIImage *)image{
// convert to CGImage & dump to bitmapData
CGImageRef imageRef = [image CGImage];
int width = (int)CGImageGetWidth(imageRef);
int height = (int)CGImageGetHeight(imageRef);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
NSUInteger bytesPerPixel = 4;
NSUInteger bytesPerRow = ((bytesPerPixel*width+255)/256)*256;
@kyleneideck
kyleneideck / headphones-detect.c
Created November 19, 2017 12:10
Runs a command when headphones are plugged in to or unplugged from the built-in audio device.
//
// headphones-detect.c
// Kyle Neideck, [email protected]
//
// Compile with:
// clang -framework CoreAudio -framework CoreFoundation -o headphones-detect headphones-detect.c
//
// Runs a command when headphones are plugged in to or unplugged from the
// built-in audio device.
//
@tad-iizuka
tad-iizuka / ViewController.swift
Created October 13, 2017 02:39
MP3 Recording with lame and AVAudioEngine, Swift 4
//
// ViewController.swift
// MP3RecordingSample
//
// Created by Tadashi on 2017/10/13.
// Copyright © 2017 UBUNIFU Inc. All rights reserved.
//
import UIKit
import AVFoundation
import AudioToolbox
@nikhita
nikhita / update-golang.md
Last active October 13, 2025 08:48
How to update the Go version

How to update the Go version

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

@Akagi201
Akagi201 / mobile_live_streaming.md
Last active October 9, 2019 08:10
[移动直播技术分享]

###1. 推流端 直播技术的流程大致可以分为几个步骤:数据采集、数据处理、视频编码、封包发送、云端(服务端)(转码、录制、分发)、播放器。

  1. 数据采集:通过摄像头和麦克风获得实时的音视频数据;
  2. 数据处理:将数据采集的输入流进行实时滤镜,得到我们美化之后的音视频数据, 视频包括各种处理滤镜,美颜,动态贴纸等, 音频包括降噪, 放大等处理;
  3. 音视频编码:编码分为软编码和硬编码。现在直播默认的编码都是 H.264。软编码是利用 CPU 进行编码,硬编码就是使用 GPU 进行编码。软编码支持现在所有的系统版本。由于苹果在 iOS8 才开放硬编码的 API,故硬编码只支持 iOS8 以上的系统;
  4. 封包发送:现在直播推流中,一般采用的格式是 FLV , 然后利用 ffmpeg 或者 librtmp 进行传输, 这两者封包的处理是不一样的,我们采用的是 ffmpeg , 所以没有对 librtmp 进行深入的研究;
  5. 云端(服务端):进行流的转码、分发和录制;
  6. 播放器:负责拉流、解码、播放。
@tomron
tomron / parquet_to_json.py
Created November 17, 2016 10:53
Converts parquet file to json using spark
# impor spark, set spark context
from pyspark import SparkContext, SparkConf
from pyspark.sql.context import SQLContext
import sys
import os
if len(sys.argv) == 1:
sys.stderr.write("Must enter input file to convert")
sys.exit()
input_file = sys.argv[1]
//
// PLGPUImageFilterViewController.m
// PLStreamingKit
//
// Created by 0dayZh on 16/3/8.
// Copyright © 2016年 0dayZh. All rights reserved.
//
#import "PLGPUImageFilterViewController.h"
#import "GPUImage.h"
@mrkpatchaa
mrkpatchaa / README.md
Last active October 22, 2025 07:06
Bulk delete github repos

Use this trick to bulk delete your old repos or old forks

(Inspired by https://medium.com/@icanhazedit/clean-up-unused-github-rpositories-c2549294ee45#.3hwv4nxv5)

  1. Open in a new tab all to-be-deleted github repositores (Use the mouse’s middle click or Ctrl + Click) https://github.com/username?tab=repositories

  2. Use one tab https://chrome.google.com/webstore/detail/onetab/chphlpgkkbolifaimnlloiipkdnihall to shorten them to a list.

  3. Save that list to some path

  4. The list should be in the form of “ur_username\repo_name” per line. Use regex search (Sublime text could help). Search for ' |.*' and replace by empty.