星期日, 五月 01, 2016

使用 ffmpeg 合并 bilibili for mac 下载的分段视频

效果

下载的分段视频:
合并后:

原理

使用ffmpeg转换flv到mp4

ffmpeg -i out.flv -vcodec copy -acodec copy out.mp4

使用ffmpeg合并MP4文件

ffmpeg -i "Apache Sqoop Tutorial Part 1.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
ffmpeg -i "Apache Sqoop Tutorial Part 2.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
ffmpeg -i "Apache Sqoop Tutorial Part 3.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate3.ts
ffmpeg -i "Apache Sqoop Tutorial Part 4.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate4.ts
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts|intermediate3.ts|intermediate4.ts" -c copy -bsf:a aac_adtstoasc "Apache Sqoop Tutorial.mp4"
然后写个脚本调用就行了,我是用 Automator 建了个服务

工具

  • Automator
  • ffmpeg
brew install ffmpeg

新建一个系统服务

使用 Automator 新建一个服务:文件➜新建➜服务,我这里命名为"flv合并为mp4"
添加「过滤 Finder 项目」「给 Finder 项目排序」「运行 Shell 脚本」组件
按图配置就行了,其中 Shell 脚本如下:
注: 脚本中包含 rm 方法,会将视频源文件和临时文件删除
for f in "$@"
do
 concat_file+="${f%.*}.ts"\|
 /usr/local/bin/ffmpeg -i "$f" -vcodec copy -acodec copy -c copy -bsf:v h264_mp4toannexb -f mpegts "${f%.*}.ts"
done

/usr/local/bin/ffmpeg -i "concat:${concat_file%|*}" -c copy -bsf:a aac_adtstoasc "${f%-*}.mp4"

for f in "$@"
do
 rm "${f%.*}.flv"
 rm "${f%.*}.ts"
done

exit 0

使用方法

选中 所有 分段的视频,右键➜服务➜flv合并为mp4

参考

星期四, 十一月 12, 2015

Mac 转发 PS4 twitch 直播流量到第三方直播平台

Mac 设置

I. enable IP Forwarding

1. 开机启用

新建或编辑 /etc/sysctl.conf 文件
加入内容:
net.inet.ip.forwarding=1

2. 现在启用

$ sudo sysctl -w net.inet.ip.forwarding=1  

II. set Traffic Redirection (Port Forwarding)

编辑 pf 配置文件

编辑 /etc/pf.conf 文件[^1]
在 rdr-anchor 下面新增一行
rdr-anchor "ps4"
在 load anchor 下面新增一行
load anchor "ps4" from "/etc/pf.anchors/ps4"
新建 /etc/pf.anchors/ps4 文件[^1]
内容:
rdr pass on en0 inet proto tcp from any to 199.9.0.0/16 port 1935 -> 127.0.0.1 port 1935
[^1] 文件需要以空行结尾

启用 pf 规则

1. 现在启用

# 重新加载 pf 规则
$ sudo pfctl -f /etc/pf.conf

# 启用 pf
$ sudo pfctl -e

2. 开机启用

编辑 /System/Library/LaunchDaemons/com.apple.pfctl.plist 文件
在 pfctl 下面加入一行
<string>-e</string>

III. set nginx rtmp server

安装 nginx

# http://brew.sh/homebrew-nginx/
$ brew tap homebrew/nginx
$ brew install nginx-full --with-rtmp-module

配置 nginx

编辑 /usr/local/etc/nginx/nginx.conf 文件
与 http 同级,加入
rtmp {
    server {
        listen 1935;
        chunk_size 131072;
        max_message 256M;
        application app {
            live on;
            record off;
            meta copy;
            push rtmp://直播地址;
        }
    }
}

开启 nginx

# Start process:
$ sudo nginx

# Reload config:
$ sudo nginx -s reload

# Stop process:
$ sudo nginx -s stop

PS4 设置

网关设为 Mac 的 ip 地址

星期二, 一月 20, 2015

[root]一条命令开启 Google Now & 位置报告

使用 root 权限运行以下命令(重启后失效)
setprop gsm.sim.operator.alpha "AT&T" && 
setprop gsm.sim.operator.iso-country "us" && 
setprop gsm.sim.operator.numeric "310090"
一段时间(几小时)后 Google Now 就能打开了
理论上位置报告也能开启,可能是 sim 卡没插吧
  

星期六, 四月 05, 2014

在 windows 上使用 Dvorak 键盘布局

第一种:修改输入法

1、英文输入法

控制面板 - 更换输入法,添加 美国英语-DVORAK

2、中文输入法

注册表定位到
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Keyboard Layouts\00000804
修改 Layout File 的值为 KBDDV.DLL,然后注销电脑
说明:00000804 表示 Chinese (Simplified) - US Keyboard

第二种:修改键盘映射

先把下面的文字另存为 qwerty.reg,留着备用。
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"ScanCode Map"=hex:00,00,00,00,00,00,00,00,01,00,00,00,00,00,00,00
把下面的文字另存为 dvorak.reg 文件,双击导入注册表,注销后生效。
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"ScanCode Map"=hex:00,00,00,00,00,00,00,00,22,00,00,00,2d,00,30,00,24,00,2e,00,\
11,00,33,00,33,00,11,00,12,00,20,00,34,00,12,00,1b,00,0d,00,0d,00,1b,00,16,\
00,21,00,17,00,22,00,20,00,23,00,1a,00,0c,00,2e,00,17,00,23,00,24,00,14,00,\
25,00,31,00,26,00,35,00,1a,00,30,00,31,00,13,00,18,00,26,00,19,00,2f,00,34,\
00,28,00,10,00,0c,00,28,00,19,00,13,00,18,00,1f,00,1f,00,27,00,2c,00,35,00,\
15,00,14,00,22,00,16,00,25,00,2f,00,10,00,2d,00,21,00,15,00,27,00,2c,00,00,\
00,00,00

星期日, 九月 29, 2013

[tasker]使用 VPN 而无需使用 PIN 或图案解锁的方法(VPN without PIN)

需要神器 Secure Settings

  1. [Secure Settings] Enable Device admin (Settings—> Security—> Device Administrators—> check "Secure Settings").

  2. 设置一个 VPN (目的为启用存储凭据),设置 PIN 为 0000

  3. [Tasker]添加任务,命名为 "boot"

    • (+) → 任务 → 等待 → 设为 30 秒

    • (+) → 插件 → Secure Settings → 编辑 → Password/PIN → Enabled , 选择 "Pin Code",输入Pin 和 Confirm Pin (步骤2设置的PIN)

    • (+) → 任务 → 等待 → 设为 5 秒(确保上一个任务已经完成)

    • (+) → 插件 → Secure Settings → 编辑 → Password/PIN → Disabled.

      !别忘了保存

  4. [Tasker]添加配置文件

    (+) → 事件 → 系统 → 设备已启动

    选择任务“boot”

  5. 重启手机 运行 boot 任务

重要

  • 设备需要约1-2分钟来解密您保存的凭据,在这段时间内,试图访问VPN设置或保存的密码将呈现一个密码对话框。只要取消该对话框,并多等待一会即可。

  • 等待时间缩短也没什么问题

xda 原文(有删减)

[tasker]set DNS 教程

Screenshot_2013-09-29-15-08-49 Screenshot_2013-09-29-15-08-07

星期二, 九月 03, 2013

What's installed in my Nexus 4?

Recovery

clockworkmod, 使用 ROM Manager 可以方便的更新 recovery (需 root 权限)

ROOT 管理

SuperSU

PS: Root 后可安装神器 BusyBox

权限管理

文件管理

防火墙

Android Firewall

自启管理

Autorun Manager

图标替换

Unicon[注 1] 可以替换图标而不需要使用第三方桌面

虚拟按键替换

SoftKeyZ ★ root

软件个性化

App Settings[注 1] 可以设置每个软件的分辨率、语言、横竖屏模式、全屏模式等

内核

内核管理

Faux123 Kernel Enhancement Pro

音效管理

FauxSound Audio/Sound Control 内核级, 减少杂音

手势加强

Touch Control (Nexus 4)可以实现手势锁屏以及滑动解锁,需要内核支持

短信拦截

CC短信拦截

来去电归属地

QC 归属地 小巧, 可惜已经不再更新了 (归属地数据库)

翻墙

无线同步

BitTorrent® Sync 局域网之间同步,数据不在云端保留,数据传输经过加密

亮度调节

Brightness 可以把亮度调的比最暗还暗

自动化

Tasker 配合 Secure Settings 可以控制飞行模式,还可以在用 VPN 的同时使用滑动解锁 (参见 XDA 或者我的另一篇博文)

备注

  1. ^ 需要安装 Xposed 外挂模块