Skip to content

Commit c98a0f4

Browse files
committed
ffmpeg use 7.1.1
1 parent 51481ce commit c98a0f4

File tree

36 files changed

+6872
-11
lines changed

36 files changed

+6872
-11
lines changed

configs/ffconfig/auto-detect-third-libs.sh

Lines changed: 79 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,55 @@ THIRD_CFG_FLAGS=
5757
# echo "[❌] --disable-libmp3lame"
5858
# fi
5959

60+
61+
# Function to compare two version numbers
62+
# Returns:
63+
# 1 if v1 == v2 or if v1 > v2
64+
# 0 if v1 < v2
65+
gt_or_equal() {
66+
local v1=$1
67+
local v2=$2
68+
local IFS=.
69+
# 将版本字符串按 "." 分割成数组
70+
# 例如 "7..1" 会变成 (7 "" 1)
71+
local v1_parts=($v1) v2_parts=($v2)
72+
local i
73+
74+
# 确定两个版本号数组中的最大长度
75+
local len_v1=${#v1_parts[@]}
76+
local len_v2=${#v2_parts[@]}
77+
local max_len=$((len_v1 > len_v2 ? len_v1 : len_v2))
78+
79+
for ((i=0; i<$max_len; i++)); do
80+
# 获取版本号的对应部分,如果部分缺失或为空字符串,则默认为 "0"
81+
local p1_val=${v1_parts[i]:-0}
82+
local p2_val=${v2_parts[i]:-0}
83+
84+
# 进一步确保 p1_val 和 p2_val 是纯数字;如果不是,则视为 0
85+
# 这能处理像 "7.a.1" 这样包含非数字部分的情况
86+
if ! [[ "$p1_val" =~ ^[0-9]+$ ]]; then
87+
p1_val=0
88+
fi
89+
if ! [[ "$p2_val" =~ ^[0-9]+$ ]]; then
90+
p2_val=0
91+
fi
92+
93+
# 进行数字比较
94+
# 使用 10# 前缀确保按十进制处理 (例如 "08" 被视为 8 而不是八进制)
95+
if ((10#$p1_val > 10#$p2_val)); then
96+
echo 1 # v1 > v2
97+
return 0
98+
fi
99+
if ((10#$p1_val < 10#$p2_val)); then
100+
echo # v1 < v2
101+
return 0
102+
fi
103+
done
104+
105+
echo 1 # v1 == v2 (所有部分都相等)
106+
return 0
107+
}
108+
60109
echo "----------------------"
61110
# use pkg-config fix ff4.0--ijk0.8.8--20210426--001 use openssl 1_1_1m occur can't find openssl error.
62111

@@ -81,10 +130,19 @@ else
81130
fi
82131

83132
echo "----------------------"
133+
84134
# FFmpeg 4.2 支持AV1、AVS2等格式
85135
# dav1d由VideoLAN,VLC和FFmpeg联合开发,项目由AOM联盟赞助,和libaom相比,dav1d性能普遍提升100%,最高提升400%
86-
#just wait videotoolbox support decode av1
87-
# THIRD_CFG_FLAGS="$THIRD_CFG_FLAGS --enable-decoder=av1"
136+
#从FFmpeg7.1.1开始支持硬解av1,苹果需要M3芯片
137+
result=$(gt_or_equal "$GIT_REPO_VERSION" "7.1.1")
138+
if [[ $result ]]; then
139+
echo "[✅] --enable hw av1 decoder"
140+
THIRD_CFG_FLAGS="$THIRD_CFG_FLAGS --enable-decoder=av1"
141+
else
142+
echo "[❌] --disable hw av1 decoder"
143+
fi
144+
145+
echo "----------------------"
88146

89147
pkg-config --libs dav1d --silence-errors >/dev/null && enable_dav1d=1
90148

@@ -118,13 +176,26 @@ else
118176
fi
119177
echo "----------------------"
120178

121-
pkg-config --libs dvdread --silence-errors >/dev/null && enable_dvdread=1
122-
123-
if [[ $enable_dvdread ]];then
124-
echo "[✅] --enable-libdvdread : $(pkg-config --modversion dvdread)"
125-
THIRD_CFG_FLAGS="$THIRD_CFG_FLAGS --enable-libdvdread --enable-protocol=dvd"
179+
#不确定7代之前的版本是否支持dvdvideo
180+
result=$(gt_or_equal "$GIT_REPO_VERSION" "7.1.1")
181+
if [[ $result ]]; then
182+
pkg-config --libs dvdread --silence-errors >/dev/null && enable_dvdread=1
183+
pkg-config --libs dvdnav --silence-errors >/dev/null && enable_dvdnav=1
184+
if [[ $enable_dvdread && $enable_dvdnav ]];then
185+
echo "[✅] --enable-demuxer=dvdvideo --enable-gpl --enable-libdvdread : $(pkg-config --modversion dvdread)"
186+
#libdvdread is gpl and --enable-gpl is not specified.
187+
THIRD_CFG_FLAGS="$THIRD_CFG_FLAGS --enable-libdvdread --enable-libdvdnav --enable-demuxer=dvdvideo --enable-gpl"
188+
else
189+
echo "[❌] --disable-dvdvideo"
190+
fi
126191
else
127-
echo "[❌] --disable-libdvdread --disable-protocol=dvd"
192+
pkg-config --libs dvdread --silence-errors >/dev/null && enable_dvdread=1
193+
if [[ $enable_dvdread ]];then
194+
echo "[✅] --enable-libdvdread : $(pkg-config --modversion dvdread)"
195+
THIRD_CFG_FLAGS="$THIRD_CFG_FLAGS --enable-libdvdread --enable-protocol=dvd"
196+
else
197+
echo "[❌] --disable-dvd protocol"
198+
fi
128199
fi
129200

130201
echo "----------------------"

configs/libs/ffmpeg.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ if [[ "$GIT_FFMPEG_COMMIT" != "" ]] ;then
3535
export GIT_COMMIT="$GIT_FFMPEG_COMMIT"
3636
export GIT_REPO_VERSION="$GIT_FFMPEG_COMMIT"
3737
else
38-
export GIT_COMMIT=n6.1.1 #origin/release/5.1
39-
export GIT_REPO_VERSION=6.1.1
38+
export GIT_COMMIT=n7.1.1 #origin/release/5.1
39+
export GIT_REPO_VERSION=7.1.1
4040
fi
4141

4242
# pre compiled

patches/ffmpeg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ffmpeg-n6.1
1+
ffmpeg-n7.1.1
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
From 393e5aabe3e0726210ec906fcec1f8208ce66ffa Mon Sep 17 00:00:00 2001
2+
From: qianlongxu <qianlongxu@gmail.com>
3+
Date: Wed, 28 May 2025 17:28:22 +0800
4+
Subject: [PATCH] restore ijk h264_ps null pointer fault tolerant
5+
6+
---
7+
libavcodec/h264_ps.c | 8 ++++----
8+
1 file changed, 4 insertions(+), 4 deletions(-)
9+
10+
diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c
11+
index 3c8fc33..9c0dc50 100644
12+
--- a/libavcodec/h264_ps.c
13+
+++ b/libavcodec/h264_ps.c
14+
@@ -437,7 +437,7 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
15+
}
16+
17+
sps->ref_frame_count = get_ue_golomb_31(gb);
18+
- if (avctx->codec_tag == MKTAG('S', 'M', 'V', '2'))
19+
+ if (avctx && avctx->codec_tag == MKTAG('S', 'M', 'V', '2'))
20+
sps->ref_frame_count = FFMAX(2, sps->ref_frame_count);
21+
if (sps->ref_frame_count > H264_MAX_DPB_FRAMES) {
22+
av_log(avctx, AV_LOG_ERROR,
23+
@@ -480,7 +480,7 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
24+
int width = 16 * sps->mb_width;
25+
int height = 16 * sps->mb_height;
26+
27+
- if (avctx->flags2 & AV_CODEC_FLAG2_IGNORE_CROP) {
28+
+ if (avctx && avctx->flags2 & AV_CODEC_FLAG2_IGNORE_CROP) {
29+
av_log(avctx, AV_LOG_DEBUG, "discarding sps cropping, original "
30+
"values are l:%d r:%d t:%d b:%d\n",
31+
crop_left, crop_right, crop_top, crop_bottom);
32+
@@ -552,7 +552,7 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
33+
if (!sps->vui.sar.den)
34+
sps->vui.sar.den = 1;
35+
36+
- if (avctx->debug & FF_DEBUG_PICT_INFO) {
37+
+ if (avctx && avctx->debug & FF_DEBUG_PICT_INFO) {
38+
static const char csp[4][5] = { "Gray", "420", "422", "444" };
39+
av_log(avctx, AV_LOG_DEBUG,
40+
"sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%u/%u/%u/%u %s %s %"PRId32"/%"PRId32" b%d reo:%d\n",
41+
@@ -819,7 +819,7 @@ int ff_h264_decode_picture_parameter_set(GetBitContext *gb, AVCodecContext *avct
42+
if (pps->chroma_qp_index_offset[0] != pps->chroma_qp_index_offset[1])
43+
pps->chroma_qp_diff = 1;
44+
45+
- if (avctx->debug & FF_DEBUG_PICT_INFO) {
46+
+ if (avctx && avctx->debug & FF_DEBUG_PICT_INFO) {
47+
av_log(avctx, AV_LOG_DEBUG,
48+
"pps:%u sps:%u %s slice_groups:%d ref:%u/%u %s qp:%d/%d/%d/%d %s %s %s %s\n",
49+
pps_id, pps->sps_id,
50+
--
51+
2.39.5 (Apple Git-154)
52+
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
From 2a82e6a5d412189c243cac24b3c9352e5c80e240 Mon Sep 17 00:00:00 2001
2+
From: qianlongxu <qianlongxu@gmail.com>
3+
Date: Wed, 28 May 2025 17:34:08 +0800
4+
Subject: [PATCH] restore ijk hls support discontinuity tag
5+
6+
---
7+
libavformat/hls.c | 59 +++++++++++++++++++++++++++++++++++++++++------
8+
1 file changed, 52 insertions(+), 7 deletions(-)
9+
10+
diff --git a/libavformat/hls.c b/libavformat/hls.c
11+
index b96c5ab..12b49c8 100644
12+
--- a/libavformat/hls.c
13+
+++ b/libavformat/hls.c
14+
@@ -75,6 +75,8 @@ enum KeyType {
15+
};
16+
17+
struct segment {
18+
+ int64_t previous_duration;
19+
+ int64_t start_time;
20+
int64_t duration;
21+
int64_t url_offset;
22+
int64_t size;
23+
@@ -775,6 +777,8 @@ static int test_segment(AVFormatContext *s, const AVInputFormat *in_fmt, struct
24+
static int parse_playlist(HLSContext *c, const char *url,
25+
struct playlist *pls, AVIOContext *in)
26+
{
27+
+ int64_t previous_duration1 = 0, previous_duration = 0, total_duration = 0;
28+
+
29+
int ret = 0, is_segment = 0, is_variant = 0;
30+
int64_t duration = 0;
31+
enum KeyType key_type = KEY_NONE;
32+
@@ -846,6 +850,7 @@ static int parse_playlist(HLSContext *c, const char *url,
33+
pls->finished = 0;
34+
pls->type = PLS_TYPE_UNSPECIFIED;
35+
}
36+
+ int start_seq_no = -1;
37+
while (!avio_feof(in)) {
38+
ff_get_chomp_line(in, line, sizeof(line));
39+
if (av_strstart(line, "#EXT-X-STREAM-INF:", &ptr)) {
40+
@@ -895,7 +900,11 @@ static int parse_playlist(HLSContext *c, const char *url,
41+
"INT64_MAX/2, mask out the highest bit\n");
42+
seq_no &= INT64_MAX/2;
43+
}
44+
- pls->start_seq_no = seq_no;
45+
+ /* Some buggy HLS servers write #EXT-X-MEDIA-SEQUENCE more than once */
46+
+ if (start_seq_no < 0) {
47+
+ start_seq_no = seq_no;
48+
+ pls->start_seq_no = seq_no;
49+
+ }
50+
} else if (av_strstart(line, "#EXT-X-PLAYLIST-TYPE:", &ptr)) {
51+
ret = ensure_playlist(c, &pls, url);
52+
if (ret < 0)
53+
@@ -960,6 +969,8 @@ static int parse_playlist(HLSContext *c, const char *url,
54+
} else if (av_strstart(line, "#EXT-X-ENDLIST", &ptr)) {
55+
if (pls)
56+
pls->finished = 1;
57+
+ } else if (av_strstart(line, "#EXT-X-DISCONTINUITY", &ptr)) {
58+
+ previous_duration = previous_duration1;
59+
} else if (av_strstart(line, "#EXTINF:", &ptr)) {
60+
is_segment = 1;
61+
duration = atof(ptr) * AV_TIME_BASE;
62+
@@ -1043,6 +1054,11 @@ static int parse_playlist(HLSContext *c, const char *url,
63+
" set to default value to 1ms.\n", seg->url);
64+
duration = 0.001 * AV_TIME_BASE;
65+
}
66+
+ previous_duration1 += duration;
67+
+ seg->previous_duration = previous_duration;
68+
+ seg->start_time = total_duration;
69+
+ total_duration += duration;
70+
+
71+
seg->duration = duration;
72+
seg->key_type = key_type;
73+
dynarray_add(&pls->segments, &pls->n_segments, seg);
74+
@@ -2360,6 +2376,7 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
75+
* stream */
76+
if (pls->needed && !pls->pkt->data) {
77+
while (1) {
78+
+ int64_t pkt_ts = AV_NOPTS_VALUE;
79+
int64_t ts_diff;
80+
AVRational tb;
81+
struct segment *seg = NULL;
82+
@@ -2373,12 +2390,40 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
83+
if (pls->is_id3_timestamped && pls->pkt->stream_index == 0) {
84+
/* audio elementary streams are id3 timestamped */
85+
fill_timing_for_id3_timestamped_stream(pls);
86+
+ } else {
87+
+ //discontinuity:ts pts need add up.
88+
+ if (pls->finished) {
89+
+ int seq_no = pls->cur_seq_no - pls->start_seq_no;
90+
+ if (seq_no < pls->n_segments && s->streams[pkt->stream_index]) {
91+
+ struct segment *seg = pls->segments[seq_no];
92+
+ if (seg->previous_duration > 0) {
93+
+ int64_t pred = av_rescale_q(seg->previous_duration,
94+
+ AV_TIME_BASE_Q,
95+
+ s->streams[pkt->stream_index]->time_base);
96+
+ int64_t max_ts = av_rescale_q(seg->start_time + seg->duration,
97+
+ AV_TIME_BASE_Q,
98+
+ s->streams[pkt->stream_index]->time_base);
99+
+ /* EXTINF duration is not precise enough */
100+
+ max_ts += 2 * AV_TIME_BASE;
101+
+ if (s->start_time > 0) {
102+
+ max_ts += av_rescale_q(s->start_time,
103+
+ AV_TIME_BASE_Q,
104+
+ s->streams[pkt->stream_index]->time_base);
105+
+ }
106+
+ if (pls->pkt->dts != AV_NOPTS_VALUE && pls->pkt->dts + pred < max_ts) pls->pkt->dts += pred;
107+
+ if (pls->pkt->pts != AV_NOPTS_VALUE && pls->pkt->pts + pred < max_ts) pls->pkt->pts += pred;
108+
+ }
109+
+ }
110+
+ }
111+
}
112+
113+
- if (c->first_timestamp == AV_NOPTS_VALUE &&
114+
- pls->pkt->dts != AV_NOPTS_VALUE)
115+
- c->first_timestamp = av_rescale_q(pls->pkt->dts,
116+
- get_timebase(pls), AV_TIME_BASE_Q);
117+
+ if (pls->pkt->pts != AV_NOPTS_VALUE)
118+
+ pkt_ts = pls->pkt->pts;
119+
+ else if (pls->pkt->dts != AV_NOPTS_VALUE)
120+
+ pkt_ts = pls->pkt->dts;
121+
+
122+
+ if (c->first_timestamp == AV_NOPTS_VALUE && pkt_ts != AV_NOPTS_VALUE)
123+
+ c->first_timestamp = av_rescale_q(pkt_ts, get_timebase(pls), AV_TIME_BASE_Q);
124+
}
125+
126+
seg = current_segment(pls);
127+
@@ -2395,13 +2440,13 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
128+
if (pls->seek_stream_index < 0 ||
129+
pls->seek_stream_index == pls->pkt->stream_index) {
130+
131+
- if (pls->pkt->dts == AV_NOPTS_VALUE) {
132+
+ if (pkt_ts == AV_NOPTS_VALUE) {
133+
pls->seek_timestamp = AV_NOPTS_VALUE;
134+
break;
135+
}
136+
137+
tb = get_timebase(pls);
138+
- ts_diff = av_rescale_rnd(pls->pkt->dts, AV_TIME_BASE,
139+
+ ts_diff = av_rescale_rnd(pkt_ts, AV_TIME_BASE,
140+
tb.den, AV_ROUND_DOWN) -
141+
pls->seek_timestamp;
142+
if (ts_diff >= 0 && (pls->seek_flags & AVSEEK_FLAG_ANY ||
143+
--
144+
2.39.5 (Apple Git-154)
145+

0 commit comments

Comments
 (0)