Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
d4890c10
F
Ffmpeg
项目概览
小白菜888
/
Ffmpeg
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Ffmpeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d4890c10
编写于
12月 20, 2012
作者:
S
Stefano Sabatini
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lavf/segment: add support to segment list file entries sliding window listing
In particular, should fix trac ticket #1842.
上级
6b7d9d51
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
56 addition
and
21 deletion
+56
-21
doc/muxers.texi
doc/muxers.texi
+4
-2
libavformat/segment.c
libavformat/segment.c
+51
-18
libavformat/version.h
libavformat/version.h
+1
-1
未找到文件。
doc/muxers.texi
浏览文件 @
d4890c10
...
...
@@ -545,8 +545,10 @@ the specified @var{segment_time}.
Default value is @code{cache}.
@item segment_list_size @var{size}
Overwrite the listfile once it reaches @var{size} entries. If 0
the listfile is never overwritten. Default value is 0.
Update the list file so that it contains at most the last @var{size}
segments. If 0 the list file will contain all the segments. Default
value is 0.
@item segment_list type @var{type}
Specify the format for the segment list file.
...
...
libavformat/segment.c
浏览文件 @
d4890c10
...
...
@@ -95,6 +95,9 @@ typedef struct {
int
reference_stream_index
;
SegmentListEntry
cur_entry
;
SegmentListEntry
*
segment_list_entries
;
SegmentListEntry
*
segment_list_entries_end
;
int
is_first_pkt
;
///< tells if it is the first packet in the segment
}
SegmentContext
;
...
...
@@ -211,15 +214,19 @@ static int segment_list_open(AVFormatContext *s)
return
ret
;
seg
->
list_max_segment_time
=
0
;
if
(
seg
->
list_type
==
LIST_TYPE_M3U8
)
{
if
(
seg
->
list_type
==
LIST_TYPE_M3U8
&&
seg
->
segment_list_entries
)
{
SegmentListEntry
*
entry
;
double
max_duration
=
0
;
avio_printf
(
seg
->
list_pb
,
"#EXTM3U
\n
"
);
avio_printf
(
seg
->
list_pb
,
"#EXT-X-VERSION:3
\n
"
);
avio_printf
(
seg
->
list_pb
,
"#EXT-X-MEDIA-SEQUENCE:%d
\n
"
,
seg
->
segment_
id
x
);
avio_printf
(
seg
->
list_pb
,
"#EXT-X-MEDIA-SEQUENCE:%d
\n
"
,
seg
->
segment_
list_entries
->
inde
x
);
avio_printf
(
seg
->
list_pb
,
"#EXT-X-ALLOWCACHE:%d
\n
"
,
!!
(
seg
->
list_flags
&
SEGMENT_LIST_FLAG_CACHE
));
if
(
seg
->
list_flags
&
SEGMENT_LIST_FLAG_LIVE
)
avio_printf
(
seg
->
list_pb
,
"#EXT-X-TARGETDURATION:%"
PRId64
"
\n
"
,
seg
->
time
/
1000000
);
for
(
entry
=
seg
->
segment_list_entries
;
entry
;
entry
=
entry
->
next
)
max_duration
=
FFMAX
(
max_duration
,
entry
->
end_time
-
entry
->
start_time
);
avio_printf
(
seg
->
list_pb
,
"#EXT-X-TARGETDURATION:%"
PRId64
"
\n
"
,
(
int64_t
)
ceil
(
max_duration
));
}
return
ret
;
...
...
@@ -228,14 +235,6 @@ static int segment_list_open(AVFormatContext *s)
static
void
segment_list_close
(
AVFormatContext
*
s
)
{
SegmentContext
*
seg
=
s
->
priv_data
;
if
(
seg
->
list_type
==
LIST_TYPE_M3U8
)
{
if
(
!
(
seg
->
list_flags
&
SEGMENT_LIST_FLAG_LIVE
))
avio_printf
(
seg
->
list_pb
,
"#EXT-X-TARGETDURATION:%d
\n
"
,
(
int
)
ceil
(
seg
->
list_max_segment_time
));
avio_printf
(
seg
->
list_pb
,
"#EXT-X-ENDLIST
\n
"
);
}
avio_close
(
seg
->
list_pb
);
}
...
...
@@ -276,15 +275,40 @@ static int segment_end(AVFormatContext *s, int write_trailer)
oc
->
filename
);
if
(
seg
->
list
)
{
if
(
seg
->
list_size
&&
!
(
seg
->
segment_count
%
seg
->
list_size
))
{
if
(
seg
->
list_size
||
seg
->
list_type
==
LIST_TYPE_M3U8
)
{
SegmentListEntry
*
entry
=
av_mallocz
(
sizeof
(
*
entry
));
if
(
!
entry
)
{
ret
=
AVERROR
(
ENOMEM
);
goto
end
;
}
/* append new element */
memcpy
(
entry
,
&
seg
->
cur_entry
,
sizeof
(
*
entry
));
if
(
!
seg
->
segment_list_entries
)
seg
->
segment_list_entries
=
seg
->
segment_list_entries_end
=
entry
;
else
seg
->
segment_list_entries_end
->
next
=
entry
;
seg
->
segment_list_entries_end
=
entry
;
/* drop first item */
if
(
seg
->
list_size
&&
seg
->
segment_count
>
seg
->
list_size
)
{
entry
=
seg
->
segment_list_entries
;
seg
->
segment_list_entries
=
seg
->
segment_list_entries
->
next
;
av_freep
(
&
entry
);
}
segment_list_close
(
s
);
if
((
ret
=
segment_list_open
(
s
))
<
0
)
goto
end
;
for
(
entry
=
seg
->
segment_list_entries
;
entry
;
entry
=
entry
->
next
)
segment_list_print_entry
(
seg
->
list_pb
,
seg
->
list_type
,
entry
);
if
(
seg
->
list_type
==
LIST_TYPE_M3U8
)
avio_printf
(
seg
->
list_pb
,
"#EXT-X-ENDLIST
\n
"
);
}
else
{
segment_list_print_entry
(
seg
->
list_pb
,
seg
->
list_type
,
&
seg
->
cur_entry
);
seg
->
list_max_segment_time
=
FFMAX
(
seg
->
cur_entry
.
end_time
-
seg
->
cur_entry
.
start_time
,
seg
->
list_max_segment_time
);
}
segment_list_print_entry
(
seg
->
list_pb
,
seg
->
list_type
,
&
seg
->
cur_entry
);
seg
->
list_max_segment_time
=
FFMAX
(
seg
->
cur_entry
.
end_time
-
seg
->
cur_entry
.
start_time
,
seg
->
list_max_segment_time
);
avio_flush
(
seg
->
list_pb
);
}
...
...
@@ -694,6 +718,8 @@ static int seg_write_trailer(struct AVFormatContext *s)
{
SegmentContext
*
seg
=
s
->
priv_data
;
AVFormatContext
*
oc
=
seg
->
avf
;
SegmentListEntry
*
cur
,
*
next
;
int
ret
;
if
(
!
seg
->
write_header_trailer
)
{
if
((
ret
=
segment_end
(
s
,
0
))
<
0
)
...
...
@@ -712,6 +738,13 @@ fail:
av_freep
(
&
seg
->
times
);
av_freep
(
&
seg
->
frames
);
cur
=
seg
->
segment_list_entries
;
while
(
cur
)
{
next
=
cur
->
next
;
av_free
(
cur
);
cur
=
next
;
}
avformat_free_context
(
oc
);
return
ret
;
}
...
...
libavformat/version.h
浏览文件 @
d4890c10
...
...
@@ -31,7 +31,7 @@
#define LIBAVFORMAT_VERSION_MAJOR 54
#define LIBAVFORMAT_VERSION_MINOR 61
#define LIBAVFORMAT_VERSION_MICRO 10
0
#define LIBAVFORMAT_VERSION_MICRO 10
1
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录