使用 mediastreamsegmenter 创建实时 HLS 流

XAMPP Setting Alt none

mediastreamsegmenter -s 10 -f /Applications/XAMPP/htdocs/hls/  127.0.0.1:2222

VLC Open Source Setting Alt none

VLC Streaming/Saving Setting Alt none

VLC Open File

Play Live HLS Stream

ffplay http://192.168.0.102/hls/prog_index.m3u8

使用 mediafilesegmenter 生成 HLS 切片

文件流化

mediafilesegmenter -B TEST -i test.m3u8 -t 10 -f ./video  ~/Movies/test.mp4

-B 切片名
-i m3u8文件
-t 时间间隔
-f ts切片存放位置

Alt none

MPEG-2 TS 包格式

Alt none Alt none Alt none Alt none Alt none Alt none

PMT

Alt none

PAT

Alt none

Name Numberof bits 32-bit BE mask Description
4-byte Transport Stream Header      
Sync byte 8 0xff000000 Bit pattern of 0x47 (ASCII char ‘G’)
Transport Error Indicator (TEI) 1 0x800000 Set when a demodulator can’t correct errors from FEC data; indicating the packet is corrupt.
Payload Unit Start Indicator 1 0x400000 Set when a PES, PSI, or DVB-MIP packet begins immediately following the header.
Transport Priority 1 0x200000 Set when the current packet has a higher priority than other packets with the same PID.
PID 13 0x1fff00 Packet Identifier, describing the payload data.
Scrambling control 2 0xc0 ’00’ = Not scrambled.For DVB-CSA only:’01’ (0x40) = Reserved for future use’10’ (0x80) = Scrambled with even key’11’ (0xC0) = Scrambled with odd key

ref: Link

iOS 使用镜头捕捉视频

- (void)takeVideo {
    UIImagePickerController *camera = [[UIImagePickerController alloc] init];
    NSArray *availableTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
    camera.mediaTypes = availableTypes;
    camera.sourceType = UIImagePickerControllerSourceTypeCamera;
    camera.delegate = self;
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    //UIImage *image = info[UIImagePickerControllerOriginalImage];

    // 不同于获取图片,我们从Delegate中取得的是所拍摄视频的URL
    NSURL *videoURL = info[UIImagePickerControllerReferenceURL];

    //拷贝所拍视频到用户相册中,并且删除临时目录中的视频文件
    if (videoURL) {
        if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum([videoURL path])) {
            UISaveVideoAtPathToSavedPhotosAlbum([videoURL path], nil, nil, nil);
            [[NSFileManager defaultManager] removeItemAtPath:[videoURL path] error:nil];
        }
    }
}

github: https://github.com/lnmcc/Homepwne.git

Ubuntu 建立 ssh 代理

Ubuntu 14.04

先强烈鄙视一下北京移动的宽带业务,各种不好用,最郁闷的是把VPN给封了。所以只能想别的方法来访问Google和Android developer了,在这里记录一下方法。

ssh -qTfnN -D 7070  [email protected]

这里的的端口号7070是任意(> 1024)你机器上的空闲端口。

然后打开Settings—-> Network控制面板,把SocksHost对接到本机的7070端口,就是在上一步中建立ssh隧道的端口: Alt none

在这里设置的proxy是系统级别的,你也可以通过你的浏览器来设置一些更详细的规则,这样会省一些proxy流量。不过我发现Chrome只能使用全局proxy,好在有SwitchySharp插件, firefox是可以设置自己的proxy的。 Alt none

PS:参数说明

Argument Comment
-q Quiet mode. Causes all warning and diagnostic messages to be suppressed.
-T Disable pseudo-tty allocation.
-f Requests ssh to go to background just before command execution. This is useful if ssh is going to ask for passwords or passphrases, but the user wants it in the background. This implies -n The recommended way to start X11 programs at a remote site is with something like ssh -f host xterm.
-n Redirects stdin from /dev/null (actually, prevents reading from stdin). This must be used when ssh is run in the background. A common trick is to use this to run X11 programs on a remote machine. For example, ssh -n shadows.cs.hut.fi emacs will start an emacs on shadows.cs.hut.fi, and the X11 connection will be automatically forwarded over an encrypted channel. The ssh program will be put in the background. (This does not work if ssh needs to ask for a password or passphrase; see also the -f option.)
-N Do not execute a remote command. This is useful for just forwarding ports (protocol version 2 only).
-D port Specifies a local “dynamic” application-level port forwarding. This works by allocating a socket to listen to port on the local side, and whenever a connection is made to this port, the connection is forwarded over the secure channel, and the application protocol is then used to determine where to connect to from the remote machine. Currently the SOCKS4 protocol is supported, and ssh will act as a SOCKS4 server. Only root can forward privileged ports. Dynamic port forwardings can also be specified in the configuration file.