0%

Submit Patches to FFmpeg

想参加今年的GSoC 2020的一个FFmpeg project,需要先做一个Qualification Task: Fix any open bug(s) on trac, get your patch reviewed on ffmpeg-devel@ mailing list. 花了几天解决了一个bug,没几行代码(我太慢了太菜了),然后在提交patch的时候碰到了不少问题。基本上,hwren的博客FFmpeg - 修改提交流程里面都讲到了,但实际操作中,我还是碰到了一些问题,主要困难在于最后一步git send-email尝试了很久才成功,另外,邮件列表回复格式也折腾了我好久。

本文包含:1. 如何提交patch; 2. git send-email配置; 3. 邮件列表回复格式; 4. 一些经验教训

Check List

  1. 准备好patch
  2. FATE测试:make fate -j8
  3. 提交修改:git commit -s-s表示签名
  4. 生成patch:git format-patch -v[x] -[n]-v[x]是版本,-[n]是打包commit的数量
  5. 检查patch:使用工具tools/pacheck检查patch规范,按提示进行修改
  6. 按照官方check list进行检查:Patch submission checklist
  7. 提交patch:git send-email -to ffmpeg-devel@ffmpeg.org 0001-xxxxx.patch
  8. 检查邮件和https://patchwork.ffmpeg.org/project/ffmpeg/list/,应该可以看到新发的patch
1
2
3
4
5
6
7
8
9
10
11
# example: git commit
commit e27a35e0458224ef6f47753f248ba84ec8284818
Author: Jun Zhao <barryjzhao@tencent.com>
Date: Wed Feb 19 11:51:20 2020 +0800

lavf/dashdec: add 3GPP TS26.247 probe in dash demuxer

Enabled the 3GP-DASH Release-10/Relase-11(3GPP TS26.247) profile
to dash demuxer probe.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>

git send-email configuration

default way

1. 安装软件

  • 发现默认不带git-email,首先安装git-email
1
$sudo apt install git-email

2. 配置smtp

1
2
3
4
5
6
7
8
9
10
11
$vim ~/.gitconfig
# add this
[sendemail]
from = Hongcheng Zhong <sj.hc_Zhong@sjtu.edu.cn>
smtpencryption = tls
smtpserver = smtp.sjtu.edu.cn
smtpserverport = 587
smtpuser = sj.hc_Zhong@sjtu.edu.cn
smtppass = mypasswd
suppresscc = self
chainreplyto = false

3. 生成patch

1
2
3
4
5
6
7
$ git format-patch -n[x] -v[x] -o xxx/
# 常用的参数
# -n[x] 涉及几个commit,效果[PATCH n/m]
# -v[x] 第几个版本,效果[PATCH v4 1/20]
# -o 指定输出的文件夹
# --subject-prefix=<subject prefix> 可以改掉[PATCH]的效果,我用来加GSoC
# --subject-prefix="PATCH] [GSoC",但是这样的效果是[PATCH] [GSoC 1/6] 不是完美的

4. 发送patch

  • 可以先发给自己试一试
1
2
3
4
5
6
7
8
9
10
11
12
13
14
$ git send-email -to sj.hc_Zhong@sjtu.edu.cn 0001-avformat-hlsenc-Fix-initial-setting-for-start_pts.patch  
0001-avformat-hlsenc-Fix-initial-setting-for-start_pts.patch
OK. Log says:
Server: smtp.sjtu.edu.cn
MAIL FROM:<sj.hc_Zhong@sjtu.edu.cn>
RCPT TO:<sj.hc_Zhong@sjtu.edu.cn>
From: Hongcheng Zhong <sj.hc_Zhong@sjtu.edu.cn>
To: sj.hc_Zhong@sjtu.edu.cn
Subject: [PATCH] avformat/hlsenc: Fix initial setting for start_pts
Date: Thu, 5 Mar 2020 21:53:48 +0800
Message-Id: <1583416428-7444-1-git-send-email-sj.hc_Zhong@sjtu.edu.cn>
X-Mailer: git-send-email 2.7.4

Result: 250

use msmtp + proxychain

git send-email not work with normal git proxy config, proxychains is a general proxy for Linux normal shell command, but not work with git send-email.

So, basic we need tell send-email use another smtp client msmtp which compatible proxychains.

1. 安装软件

1
$sudo apt install msmtp proxychain

2. 修改配置文件x3

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$vim ~/.msmtprc
# Example for a user configuration file
# Set default values for all following accounts.
defaults
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.msmtp.log
# My email service
account sjtu
host smtp.sjtu.edu.cn
port 587
# proxy here is useless
# proxy_host 127.0.0.1
# proxy_port 7890
from sj.hc_Zhong@sjtu.edu.cn
user sj.hc_Zhong
password mypasswd
# Set a default account
account default : sjtu
$vim ~/.gitconfig
[sendemail]
smtpserver = /usr/bin/msmtp
$vim /etc/proxychain.conf
[ProxyList]
http 127.0.0.1 7890
https 127.0.0.1 7890
socks5 127.0.0.1 1080

3. 修改~/.msmtprc权限

1
$chmod 0600 ~/.msmtprc

4. 发送patch

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
$ proxychains git send-email -to ffmpeg-devel@ffmpeg.org  0001-avformat-hlsenc-Fix-initial-setting-for-start_pts.patch  
ProxyChains-3.1 (http://proxychains.sf.net)
0001-avformat-hlsenc-Fix-initial-setting-for-start_pts.patch
(mbox) Adding cc: Hongcheng Zhong <sj.hc_Zhong@sjtu.edu.cn> from line 'From: Hongcheng Zhong <sj.hc_Zhong@sjtu.edu.cn>'
(body) Adding cc: Hongcheng Zhong <sj.hc_Zhong@sjtu.edu.cn> from line 'Signed-off-by: Hongcheng Zhong <sj.hc_Zhong@sjtu.edu.cn>'

From: Hongcheng Zhong <sj.hc_Zhong@sjtu.edu.cn>
To: ffmpeg-devel@ffmpeg.org
Cc: Hongcheng Zhong <sj.hc_Zhong@sjtu.edu.cn>
Subject: [PATCH] avformat/hlsenc: Fix initial setting for start_pts
Date: Thu, 5 Mar 2020 21:41:52 +0800
Message-Id: <1583415712-6396-1-git-send-email-sj.hc_Zhong@sjtu.edu.cn>
X-Mailer: git-send-email 2.7.4

The Cc list above has been expanded by additional
addresses found in the patch commit message. By default
send-email prompts before sending whenever this occurs.
This behavior is controlled by the sendemail.confirm
configuration setting.

For additional information, run 'git send-email --help'.
To retain the current behavior, but squelch this message,
run 'git config --global sendemail.confirm auto'.

Send this email? ([y]es|[n]o|[q]uit|[a]ll): y
|DNS-request| smtp.sjtu.edu.cn
|S-chain|-<>-127.0.0.1:7890-<><>-4.2.2.2:53-<><>-OK
|DNS-response| smtp.sjtu.edu.cn is 202.112.26.54
|S-chain|-<>-127.0.0.1:7890-<><>-202.112.26.54:587-<><>-OK
OK. Log says:
Sendmail: /usr/bin/msmtp -i ffmpeg-devel@ffmpeg.org sj.hc_Zhong@sjtu.edu.cn
From: Hongcheng Zhong <sj.hc_Zhong@sjtu.edu.cn>
To: ffmpeg-devel@ffmpeg.org
Cc: Hongcheng Zhong <sj.hc_Zhong@sjtu.edu.cn>
Subject: [PATCH] avformat/hlsenc: Fix initial setting for start_pts
Date: Thu, 5 Mar 2020 21:41:52 +0800
Message-Id: <1583415712-6396-1-git-send-email-sj.hc_Zhong@sjtu.edu.cn>
X-Mailer: git-send-email 2.7.4
Result: OK

Reply email (configure your email client)

  • 因为mail list用的是传统的回复风格,找了好久应该怎么配置邮箱客户端
  • FFmpeg的FAQ中的Rules-and-Etiquette提到的格式相关:
  • Avoid top-posting. Also see What is top-posting?
  • Avoid hijacking threads. Thread hijacking is replying to a message and changing the subject line to something unrelated to the original thread. Most email clients will still show the renamed message under the original thread. This can be confusing and these types of messages are often ignored.
  • Do not send screenshots. Copy and paste console text instead of making screenshots of the text.
  • Avoid sending email disclaimers and legalese if possible as this is a public list.
  • If you attach files avoid compressing small files. Uncompressed is preferred.
  • Please do not send HTML-only messages. The mailing list will ignore the HTML component of your message. Most mail clients will automatically include a text component: this is what the mailing list will use.
  • Configuring your mail client to break lines after 70 or so characters is recommended.
  • 其中提到的”Avoid top-posting”,区分好这个概念很重要,沿着这个找找到了关键
    • sjtu的webmail设置如下:Preferences>Mail>Composing Messages>Email Reply选中Use prefix
    • 其他设置细节还不清楚

Experience

  • 确保你的修改可以通过FATE测试,make fate会比较慢,可以make fate -j8

  • 查到有说在.msmtprc里面加proxy_hostproxy_port来走代理的,但是尝试了一下好像没用。

  • user字段写完整的邮箱地址或者@前面部分都可以。

  • git send-email --smtp-debug=1并不能看到debug信息,也不知道为什么。

  • 比较坑的地方是端口:net.sjtu.edu.cn里面说的:

    SMTP 发信服务器为 smtp.sjtu.edu.cn, 安全端口为 465;

    然而事实上我一开始用465端口死活发不出去,全都死在错误:

    1
    Unable to initialize SMTP properly. Check config and use --smtp-debug. VALUES: server=smtp.sjtu.edu.cn encryption=tls hello=localhost.localdomain port=465 at /usr/lib/git-core/git-send-email line 1383.

    后来在wiki.archlinux.msmtp里面看到了有关的描述,似乎启用TLS的话,应该用587端口,挺坑的。

  • 中间试了几次Gmail,发现Google给我发了拦截未知访问的邮件,Google安全做的真好。

  • 尝试了msmtp+proxychains,并在修改端口为578后成功发送,后来想着再试试原生的方式,没准只是端口的问题,试了一下,果然是这样!

  • 就我尝试的范围内,两种方式的差别有以下:

    1. 原生的方式加的那几条配置挺实用的,还没有在msmtp里面找过
    2. msmtp要求配置文件改权限为600,因为里面写了明文密码,记得还看到过用别的工具把明文密码加密掉的方式,相对安全一些吧。

Reference


欢迎关注我的其它发布渠道