This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
def download_net_http(urls, thread_count) | |
queue = Queue.new | |
urls.map { |url| queue << url } | |
threads = thread_count.times.map do | |
Thread.new do | |
Net::HTTP.start('our-s3-bucket.s3.amazonaws.com', 80) do |http| | |
while !queue.empty? && url = queue.pop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Mp4ParserAudioMuxer implements AudioMuxer { | |
@Override | |
public boolean mux(String videoFile, String audioFile, String outputFile) { | |
Movie video; | |
try { | |
video = new MovieCreator().build(videoFile); | |
} catch (RuntimeException e) { | |
e.printStackTrace(); | |
return false; | |
} catch (IOException e) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JcodecMp4VideoMuxer implements VideoMuxer { | |
private FileChannelWrapper mChannelWrapper; | |
private MP4Muxer mMp4Muxer; | |
private FramesMP4MuxerTrack mMp4Track; | |
private ArrayList<ByteBuffer> mSpsList; | |
private ArrayList<ByteBuffer> mPpsList; | |
@Override | |
public boolean initialize() { | |
mSpsList = new ArrayList<ByteBuffer>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static byte[] NV21toYUV420Planar(byte[] input, byte[] output, int width, int height) { | |
final int frameSize = width * height; | |
final int qFrameSize = frameSize/4; | |
System.arraycopy(input, 0, output, 0, frameSize); // Y | |
byte v, u; | |
for (int i = 0; i < qFrameSize; i++) { | |
v = input[frameSize + i*2]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface VideoEncoder { | |
boolean prepare(Context context); | |
boolean sendFrame(@NotNull byte[] frame); | |
Frame receiveFrame() throws VideoEncoderError; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MediaCodecFormatSelector { | |
public static MediaCodecFormatSelector forDevice() { | |
String deviceName = Device.getDeviceName(); | |
if (deviceName.equalsIgnoreCase("samsung gt-i9300") | |
&& isBadMediaCodecSupport()) { | |
return new SamsungGalaxyS3MediaCodecFormatSelector(); | |
else if (isBadMediaCodecSupport() && isAffectedDevice(deviceName)) { | |
return new NoMediaCodecSupportFormatSelector(); | |
} else { | |
return new MediaCodecFormatSelector(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN | |
&& MediaCodecFormatSelector.forDevice().isSupported()) { | |
binder.bind(VideoEncoder.class).to(MediaCodecVideoEncoder.class); | |
} else { | |
binder.bind(VideoEncoder.class).to(JpegVideoEncoder.class); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MediaRecorder mediaRecorder = new MediaRecorder(); | |
CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH); | |
profile.videoFrameWidth = 1280; | |
profile.videoFrameHeight = 720; | |
mediaRecorder.setCamera(Camera.open()); | |
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT); | |
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); | |
mediaRecorder.setProfile(profile); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static class BufferedWritableFileByteChannel implements WritableByteChannel { | |
private static final int BUFFER_CAPACITY = 1000000; | |
private boolean isOpen = true; | |
private final OutputStream outputStream; | |
private final ByteBuffer byteBuffer; | |
private final byte[] rawBuffer = new byte[BUFFER_CAPACITY]; | |
private BufferedWritableFileByteChannel(OutputStream outputStream) { | |
this.outputStream = outputStream; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'delicious', '~> 1.0.0' |