FFmpeg
website

ffmpeg  -y -loglevel level+error -vcodec h264 -r 15  -i "in.h264" -vcodec h264  -fpsmax 15 -b:v 1M "out.mp4"
ffmpeg -y -vcodec h264 -r 15 -i in.h264 -vcodec h264 -fpsmax 15 -b:v 1M -filter:v "setpts=15.0*PTS" -preset ultrafast out.mp4

-c:v 用于指定视频编码,-c:a 指定音频编码 -c:v copy 表示复制输入文件中的视频流到输出文件,不重新进行编码
-b:v 用于指定视频的比特率。 -r 15 选项用于指定输出视频的帧率为 15 FPS。
-c:v libx264

-filter:v fps=15

改变视频播放速度(音频不受影响)
$ ffmpeg -i input.mp4 -vf "setpts=0.5*PTS" output.mp4

上述命令会加快视频画面的播放速度,音频播放速度不变。

如果想放慢视频画面的切换速度,可以相应地将 setpts=0.5*PTS 中的 0.5 改为大于 1 的数值。

// 稍微增加点文件大小,编码速度提升很多
-preset ultrafast

// 查看信息
ffmpeg -i bbb.mp4 -hide_banner

// 去掉 ffmpeg 的版本和编译信息
-hide_banner

// 查看信息
ffprobe -show_streams -i out.mp4

调整视频速率
调整视频速率的原理为:修改视频的 presentation timestamp (PTS),dts

调整音频速率
调整视频速率的原理为:简单的方法是调整音频采样率,但是这种方法会改变音色, 一般采用通过对原音进行重采样,差值等方法。

ffmpeg -i in.mkv -filter:a "atempo=2.0" -vn out.mkv


h264 结构相关

H264结构中,一个视频图像编码后的数据叫做一帧,一帧由一个片(slice)或多个片组成,一个片由一个或多个宏块(MB)组成。

H264在网络传输的是NALU,NALU的结构是:NAL头+RBSP

tbn tbc tbr

There are three different time bases for time stamps in FFmpeg. The
values printed are actually reciprocals of these, i.e. 1/tbr, 1/tbn and
1/tbc.

tbn is the time base in AVStream that has come from the container, I
think. It is used for all AVStream time stamps.

tbc is the time base in AVCodecContext for the codec used for a
particular stream. It is used for all AVCodecContext and related time
stamps.

tbr is guessed from the video stream and is the value users want to see
when they look for the video frame rate, except sometimes it is twice
what one would expect because of field rate versus frame rate.

三放就是一黄一白一红,小茴香、莲子、红枣。三不放就是料酒 花椒 八角。炖鸡汤的时候不能放入料酒,不仅不能去腥,还会使鸡汤有股酸味。炖鸡汤讲究鲜香味美比较清淡,放入花椒,有强烈的刺激味道,八角的味道也是比较刺激,放了八角就掩盖了鸡汤的鲜味。

板栗切口,沸水,把板栗洗净放进去煮5分钟,捞起放入凉水中,剥壳,剥皮。
山药去皮,切块。

鸡肉+清水+盐 泡20分钟

焯一下水
一定要等锅里水开以后再把老母鸡下锅焯水,这样才能不让更多的鲜味流失掉。

放入葱姜可以去除腥味
冷水下锅,就是把焯过的老母鸡放入冷水中炖煮,这样能让更多的鲜味和营养充分释放到汤里。

冬瓜或蘑菇,酸笋(目的是去油腻)
枸杞或红枣,等中药材
必须用砂锅炖汤,切记要一定性加足清水,尤其是沸腾之前的那10多分钟,如果打开锅盖就会损失很多的香味

炖老母鸡汤切记不要过早放盐,因为放盐过早会让蛋白质凝固,不易溶解在汤里,从而让汤色发暗,鲜味不足。
葱姜等调味料的用量不宜过多,否则会让老母鸡汤失去应有的原汁原味。
炖汤过程中的火候掌握也很关键,老母鸡下锅后先用大火烧开,然后就要转中小火慢慢地炖煮,让锅里的汤水保持微微沸腾就行了,火力太大会加剧蛋白质分子的运动,从而让汤色变得浑浊。
虫草每次3—4克即可,虫草的炖煮时间不宜过长,最好不要超过2个小时,一般1小时左右即可,且宜采用“文火”,火力不要过大、过猛,若为求肉质酥软,可先炖一段时间内,之后再下虫草

install

sudo apt-get install openssh-server

// 检查是否启动
ps -e|grep ssh

// 手动启动
sudo/etc/init.d/ssh start

remote login

-i 指定私钥路径
-p 指定端口

ssh -i ~/.ssh/private_key developer@192.168.1.237 -p 23

centos 7 + mongodb 4.0

  • create mongodb-org.repo inside /etc/yum.repos.d/ directory

past following contents

[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
  • Installing MongoDB
    sudo yum install mongodb-org

  • Starting MongoDB

    sudo systemctl start mongod
    sudo systemctl enable mongod
  • Verifying MongoDB Installation

    // 进入命令行
    mongo

    db.version()

    //启动服务
    mongod --dbpath /home/tyler/mongodb/stock

    // 使用配置文件启动
    mongod -f /etc/mongod.conf

Failed to unlink socket file /tmp/mongodb-27017.sock Unknown error

delete the /tmp/mongodb-27017.sock file manually and start the mongod process.

Failed to set up listener: SocketException: Address already in use

sudo service mongod stop
sudo mongod
  • Configuring MongoDB
    编辑配置文件 /etc/mongod.conf
security:
authorization: enabled

The authorization option enables Role-Based Access Control (RBAC) that regulates users access to database resources and operations. If this option is disabled each user will have access to any database and will be able to execute any action.

sudo systemctl restart mongod
  • Creating Administrative MongoDB User
    mongo
    use admin

    db.createUser(
    {
    user: "mongoSuperAdmin",
    pwd: "cow2wsx1qaz",
    roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
    }
    )

    quit()
mongo -u mongoSuperAdmin -p --authenticationDatabase admin
use admin
show users

mongo manual

条件筛选

riseUp = len(df[(0.0 < df.rise_percent) & (df.rise_percent < 10.0)])
result = result[(result['var']>0.25) | (result['var']<-0.25)]

count = df['value'].isna().sum()
#或者 count = df['value'].isnull().sum()
(df['value'] == 'NaN').sum()

# 过滤行, 所有列 满足条件
df = df[(df > -2147483645.0)].dropna(how='all')
# 过滤列, 任意列 满足条件
df = df[(df > -2147483645.0)].dropna(axis=1)
阅读全文 »

  1. 普通函数(未定位在类里),都是函数。
  2. 静态方法(@staticmethod),都是函数。
  3. 类方法(@classmethod),都是方法。
  4. 实例方法(首参数为self且非静态、非类方法的),都是方法。
def spam(a, b=42):
print(a, b)
spam(1) # Ok. a=1, b=42
spam(1, 2) # Ok. a=1, b=2

# Using a list as a default value
def spam(a, b=None):
if b is None:
b = []
...

Function Annotations

Java应用中,日志一般分为以下5个级别:
ERROR 错误信息
WARN 警告信息
INFO 一般信息
DEBUG 调试信息
TRACE 跟踪信息

Lombok

简化代码的注解工具
IDEA 安装:
settings->Plugins->Lombok Plugin->Restart IntelliJ IDEA

Annotation Processors->Enable annotation Processing

依赖添加

// 'compile' can be changed to 'compileOnly' for Gradle 2.12+
// or 'provided' if using 'propdeps' plugin from SpringSource
compileOnly "org.projectlombok:lombok:1.18.2"

json to object

import com.fasterxml.jackson.databind.ObjectMapper;// in play 2.3
ObjectMapper mapper = new ObjectMapper();

// As Object
modelResult resultDatas = objectMapper.readValue(content, modelResult.class);

//As Array:
MyClass[] myObjects = mapper.readValue(json, MyClass[].class);

//As List:
List<MyClass> myObjects = mapper.readValue(jsonInput, new TypeReference<List<MyClass>>(){});

//Another way to specify the List type:
List<MyClass> myObjects = mapper.readValue(jsonInput, mapper.getTypeFactory().constructCollectionType(List.class, MyClass.class));

object to json

User user = new User();
user.setFirstName("Shane);
user.setLastName("James");
user.setAge(28);

String userJson = null;
try {
userJson = objectMapper.writeValueAsString(user);
} catch (JsonProcessingException e) {
e.printStackTrace();
}

map to json

ObjectMapper mapper = new ObjectMapper();
String json = "";

Map<String, String> map = new HashMap<String,String>();
map.put("name", "zitong");
map.put("age", "26");

json = mapper.writeValueAsString(map);

Map<String,Object> data = new HashMap<>();
data.put("users",userService.getUser(id));