Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
986ebcdb
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,发现更多精彩内容 >>
提交
986ebcdb
编写于
6月 30, 2004
作者:
M
Michael Niedermayer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
audio timestamp drift compensation
Originally committed as revision 3272 to
svn://svn.ffmpeg.org/ffmpeg/trunk
上级
b9d2085b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
32 deletion
+43
-32
ffmpeg.c
ffmpeg.c
+42
-31
tests/libav.regression.ref
tests/libav.regression.ref
+1
-1
未找到文件。
ffmpeg.c
浏览文件 @
986ebcdb
...
...
@@ -201,7 +201,8 @@ static int bitexact = 0;
static
char
*
pass_logfilename
=
NULL
;
static
int
audio_stream_copy
=
0
;
static
int
video_stream_copy
=
0
;
static
int
sync_method
=
1
;
static
int
video_sync_method
=
1
;
static
int
audio_sync_method
=
0
;
static
int
copy_ts
=
0
;
static
int
rate_emu
=
0
;
...
...
@@ -432,6 +433,22 @@ static void do_audio_out(AVFormatContext *s,
enc
=
&
ost
->
st
->
codec
;
if
(
audio_sync_method
){
double
delta
=
ost
->
sync_ipts
*
enc
->
sample_rate
-
ost
->
sync_opts
-
fifo_size
(
&
ost
->
fifo
,
ost
->
fifo
.
rptr
)
/
(
ost
->
st
->
codec
.
channels
*
2
);
//FIXME resample delay
if
(
fabs
(
delta
)
>
50
){
int
comp
=
clip
(
delta
,
-
audio_sync_method
,
audio_sync_method
);
assert
(
ost
->
audio_resample
);
if
(
verbose
>
2
)
fprintf
(
stderr
,
"compensating audio timestamp drift:%f compensation:%d in:%d
\n
"
,
delta
,
comp
,
enc
->
sample_rate
);
// fprintf(stderr, "drift:%f len:%d opts:%lld ipts:%lld fifo:%d\n", delta, len/4, ost->sync_opts, (int64_t)(ost->sync_ipts * enc->sample_rate), fifo_size(&ost->fifo, ost->fifo.rptr)/(ost->st->codec.channels * 2));
av_resample_compensate
(
*
(
struct
AVResampleContext
**
)
ost
->
resample
,
delta
,
enc
->
sample_rate
);
}
}
else
ost
->
sync_opts
=
lrintf
(
ost
->
sync_ipts
*
enc
->
sample_rate
)
-
fifo_size
(
&
ost
->
fifo
,
ost
->
fifo
.
rptr
)
/
(
ost
->
st
->
codec
.
channels
*
2
);
//FIXME wrong
if
(
ost
->
audio_resample
)
{
buftmp
=
audio_buf
;
...
...
@@ -467,10 +484,15 @@ static void do_audio_out(AVFormatContext *s,
pkt
.
pts
=
enc
->
coded_frame
->
pts
;
pkt
.
flags
|=
PKT_FLAG_KEY
;
av_interleaved_write_frame
(
s
,
&
pkt
);
ost
->
sync_opts
+=
enc
->
frame_size
;
}
}
else
{
AVPacket
pkt
;
av_init_packet
(
&
pkt
);
ost
->
sync_opts
+=
size_out
/
enc
->
channels
;
/* output a pcm frame */
/* XXX: change encoding codec API to avoid this ? */
switch
(
enc
->
codec
->
id
)
{
...
...
@@ -588,7 +610,7 @@ static void do_video_out(AVFormatContext *s,
AVOutputStream
*
ost
,
AVInputStream
*
ist
,
AVFrame
*
in_picture
,
int
*
frame_size
,
AVOutputStream
*
audio_sync
)
int
*
frame_size
)
{
int
nb_frames
,
i
,
ret
;
AVFrame
*
final_picture
,
*
formatted_picture
;
...
...
@@ -610,7 +632,7 @@ static void do_video_out(AVFormatContext *s,
*
frame_size
=
0
;
if
(
sync_method
){
if
(
video_
sync_method
){
double
vdelta
;
vdelta
=
ost
->
sync_ipts
*
enc
->
frame_rate
/
enc
->
frame_rate_base
-
ost
->
sync_opts
;
//FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c
...
...
@@ -1018,11 +1040,11 @@ static int output_packet(AVInputStream *ist, int ist_index,
AVFrame
picture
;
short
samples
[
AVCODEC_MAX_AUDIO_FRAME_SIZE
/
2
];
void
*
buffer_to_free
;
//fprintf(stderr, "output_packet %d, dts:%lld\n", pkt->stream_index, pkt->dts);
if
(
pkt
&&
pkt
->
dts
!=
AV_NOPTS_VALUE
)
{
//FIXME seems redundant, as libavformat does this too
ist
->
next_pts
=
ist
->
pts
=
pkt
->
dts
;
}
else
{
ist
->
pts
=
ist
->
next_pts
;
assert
(
ist
->
pts
==
ist
->
next_pts
)
;
}
if
(
pkt
==
NULL
)
{
...
...
@@ -1134,7 +1156,7 @@ static int output_packet(AVInputStream *ist, int ist_index,
printf("%d: got pts=%0.3f %0.3f\n", i,
(double)pkt->pts / AV_TIME_BASE,
((double)ist->pts / AV_TIME_BASE) -
((double)ost->st->pts.val * ost->
time_base.num / o
st->time_base.den));
((double)ost->st->pts.val * ost->
st->time_base.num / ost->
st->time_base.den));
#endif
/* set the input output pts pairs */
ost
->
sync_ipts
=
(
double
)(
ist
->
pts
+
input_files_ts_offset
[
ist
->
file_index
])
/
AV_TIME_BASE
;
...
...
@@ -1159,7 +1181,7 @@ static int output_packet(AVInputStream *ist, int ist_index,
}
}
do_video_out
(
os
,
ost
,
ist
,
&
picture
,
&
frame_size
,
audio_sync
);
do_video_out
(
os
,
ost
,
ist
,
&
picture
,
&
frame_size
);
video_size
+=
frame_size
;
if
(
do_vstats
&&
frame_size
)
do_video_stats
(
os
,
ost
,
frame_size
);
...
...
@@ -1460,27 +1482,20 @@ static int av_encode(AVFormatContext **output_files,
ost
->
audio_resample
=
0
;
else
{
ost
->
audio_resample
=
1
;
ost
->
resample
=
audio_resample_init
(
codec
->
channels
,
icodec
->
channels
,
codec
->
sample_rate
,
icodec
->
sample_rate
);
if
(
!
ost
->
resample
)
{
printf
(
"Can't resample. Aborting.
\n
"
);
av_abort
();
}
}
/* Request specific number of channels */
icodec
->
channels
=
codec
->
channels
;
}
else
{
ost
->
audio_resample
=
1
;
ost
->
resample
=
audio_resample_init
(
codec
->
channels
,
icodec
->
channels
,
codec
->
sample_rate
,
icodec
->
sample_rate
);
if
(
!
ost
->
resample
)
{
printf
(
"Can't resample. Aborting.
\n
"
);
av_abort
();
}
}
}
if
(
audio_sync_method
)
ost
->
audio_resample
=
1
;
if
(
ost
->
audio_resample
){
ost
->
resample
=
audio_resample_init
(
codec
->
channels
,
icodec
->
channels
,
codec
->
sample_rate
,
icodec
->
sample_rate
);
if
(
!
ost
->
resample
){
printf
(
"Can't resample. Aborting.
\n
"
);
av_abort
();
}
}
ist
->
decoding_needed
=
1
;
...
...
@@ -2010,11 +2025,6 @@ static void opt_verbose(const char *arg)
av_log_set_level
(
atoi
(
arg
));
}
static
void
opt_sync_method
(
const
char
*
arg
)
{
sync_method
=
atoi
(
arg
);
}
static
void
opt_frame_rate
(
const
char
*
arg
)
{
if
(
parse_frame_rate
(
&
frame_rate
,
&
frame_rate_base
,
arg
)
<
0
)
{
...
...
@@ -3626,7 +3636,8 @@ const OptionDef options[] = {
{
"v"
,
HAS_ARG
,
{(
void
*
)
opt_verbose
},
"control amount of logging"
,
"verbose"
},
{
"target"
,
HAS_ARG
,
{(
void
*
)
opt_target
},
"specify target file type (
\"
vcd
\"
,
\"
svcd
\"
or
\"
dvd
\"
)"
,
"type"
},
{
"threads"
,
HAS_ARG
|
OPT_EXPERT
,
{(
void
*
)
opt_thread_count
},
"thread count"
,
"count"
},
{
"sync"
,
HAS_ARG
|
OPT_EXPERT
,
{(
void
*
)
opt_sync_method
},
"sync method"
,
""
},
{
"vsync"
,
HAS_ARG
|
OPT_INT
|
OPT_EXPERT
,
{(
void
*
)
&
video_sync_method
},
"video sync method"
,
""
},
{
"async"
,
HAS_ARG
|
OPT_INT
|
OPT_EXPERT
,
{(
void
*
)
&
audio_sync_method
},
"audio sync method"
,
""
},
{
"copyts"
,
OPT_BOOL
|
OPT_EXPERT
,
{(
void
*
)
&
copy_ts
},
"copy timestamps"
},
/* video options */
...
...
tests/libav.regression.ref
浏览文件 @
986ebcdb
...
...
@@ -9,7 +9,7 @@ ffmpeg regression test
360251 ./data/b-libav.rm
e0a9ed22a34e0277ec77c84e8b64afd9 *./data/b-libav.mpg
387072 ./data/b-libav.mpg
./data/b-libav.mpg CRC=
ac661eb1
./data/b-libav.mpg CRC=
723a4225
57a8dfc7926802bb337a9d8918de94a8 *./data/b-libav.swf
41816 ./data/b-libav.swf
./data/b-libav.swf CRC=2b273fea
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录