Skip to content

Instantly share code, notes, and snippets.

View whatvn's full-sized avatar

Hung whatvn

View GitHub Profile
@whatvn
whatvn / 0. nginx_setup.sh
Last active August 29, 2015 14:26 — forked from mikhailov/0. nginx_setup.sh
Nginx + secure pseudo-streaming
# Nginx can serve FLV/MP4 files by pseudo-streaming way without any specific media-server software.
# To do the custom build we use 2 modules: --with-http_secure_link_module --with-http_flv_module
# This module "secure-link" helps you to protect links from stealing away.
#
# NOTE: see more details at coderwall: http://coderwall.com/p/3hksyg
cd /usr/src
wget http://nginx.org/download/nginx-1.5.13.tar.gz
tar xzvf ./nginx-1.5.13.tar.gz && rm -f ./nginx-1.5.13.tar.gz
def video(gearman_worker, gearman_job):
try:
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(gearman_job.data.decode('utf-8'))
print "raw data: " + gearman_job.data
print "decode data: " + gearman_job.data.decode('utf-8')
today = datetime.date.today()
job_data = json.loads(gearman_job.data.decode('utf-8'))
....
except Exception,e:
/*
* Fancy ID generator that creates 20-character string identifiers with the
* following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't
* collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters
* that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in
package com.firebase.utils;
import java.util.Date;
/**
* Fancy ID generator that creates 20-character string identifiers with the
* following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't
@whatvn
whatvn / scale
Created October 9, 2014 07:10
scale
// scale video
static AVFrame* scale_encode_write_frame(AVFrame *frame, int src_w, int src_h,
int dst_w, int dst_h) {
int ret = 0;
AVFrame *scale_frame;
scale_frame = av_frame_alloc();
if (!scale_frame) {
av_log(NULL, AV_LOG_DEBUG, "Cannot get allocate scale frame\n");
return frame;
}
@whatvn
whatvn / scale.c
Created October 9, 2014 03:44
scale
static AVFrame* scale_encode_write_frame(AVFrame *frame, int src_w, int src_h,
int dst_w, int dst_h) {
int ret = 0;
AVFrame *scale_frame;
frame = av_frame_alloc();
if (!frame) {
av_log(NULL, AV_LOG_DEBUG, "Cannot get allocate scale frame\n");
return frame;
}
SwsContext *scale_context = NULL;
@whatvn
whatvn / register
Created October 6, 2014 02:26
register
rax 0x9c54f349bdfc5672 -7181848007703505294
rbx 0x1fb1a30 33233456
rcx 0x7fff40e96830 140734282426416
rdx 0x21 33
rsi 0x1 1
rdi 0x7fa70e2d0740 140355474097984
rbp 0x9c54f349bdfc5672 0x9c54f349bdfc5672
rsp 0x7fff40e967f0 0x7fff40e967f0
r8 0x0 0
r9 0x7fa70e2d0748 140355474097992
@whatvn
whatvn / transcoding
Created October 6, 2014 02:17
ts transcoding
int in_video_index = -1;
int in_audio_index = -1;
int return_code = ERROR;
int buffer_size;
unsigned char *exchange_area;
AVFormatContext *input_format_context = NULL;
AVFormatContext *output_format_context = NULL;
AVIOContext *io_context;
AVCodec *input_audio_codec = NULL;
AVCodec *output_audio_codec = NULL;
@whatvn
whatvn / ffmpeg
Last active August 29, 2015 14:07
ffmpeg command output
/usr/local/bin/ffmpeg -i /tmp/input.ts -acodec libfdk_aac -vcodec libx264 -s 640x360 -b:v 1000k /tmp/output.ts 2>&1 > /tmp/output.txt
ffmpeg version 2.4.1 Copyright (c) 2000-2014 the FFmpeg developers
built on Oct 4 2014 16:36:36 with gcc 4.6 (Ubuntu/Linaro 4.6.4-3ubuntu1)
configuration: --enable-libx264 --enable-libfdk-aac --enable-gpl --enable-nonfree --enable-shared --enable-avresample --enable-debug=3 --disable-pthreads
libavutil 54. 7.100 / 54. 7.100
libavcodec 56. 1.100 / 56. 1.100
libavformat 56. 4.101 / 56. 4.101
libavdevice 56. 0.100 / 56. 0.100
libavfilter 5. 1.100 / 5. 1.100
libavresample 2. 1. 0 / 2. 1. 0
String seedUrl = "www.google.com www.blogger.com";
_logger.info("Processing url [{}]", seedUrl);
Random random = new Random();
String batchId = String.valueOf(random.nextInt());
Configuration nutchConfiguration = NutchConfiguration.create();
nutchConfiguration.set(BATCH_ID, batchId);
String solrUrl = nutchConfiguration.get(SOLR_URL);
String crawlArgs = String.format("-seedurl %s -depth 5 -topN 10", seedUrl);
// Run Crawl tool
ToolRunner.run(nutchConfiguration, new Crawler(),