Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
ab7b0389
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,发现更多精彩内容 >>
提交
ab7b0389
编写于
6月 28, 2015
作者:
A
Anton Khirnov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
avconv: factor out the output stream initialization
上级
bd2ab27c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
57 addition
and
46 deletion
+57
-46
avconv.c
avconv.c
+57
-46
未找到文件。
avconv.c
浏览文件 @
ab7b0389
...
...
@@ -1549,6 +1549,60 @@ static InputStream *get_input_stream(OutputStream *ost)
return
NULL
;
}
static
int
init_output_stream
(
OutputStream
*
ost
,
char
*
error
,
int
error_len
)
{
int
ret
=
0
;
if
(
ost
->
encoding_needed
)
{
AVCodec
*
codec
=
ost
->
enc
;
AVCodecContext
*
dec
=
NULL
;
InputStream
*
ist
;
if
((
ist
=
get_input_stream
(
ost
)))
dec
=
ist
->
dec_ctx
;
if
(
dec
&&
dec
->
subtitle_header
)
{
ost
->
enc_ctx
->
subtitle_header
=
av_malloc
(
dec
->
subtitle_header_size
);
if
(
!
ost
->
enc_ctx
->
subtitle_header
)
return
AVERROR
(
ENOMEM
);
memcpy
(
ost
->
enc_ctx
->
subtitle_header
,
dec
->
subtitle_header
,
dec
->
subtitle_header_size
);
ost
->
enc_ctx
->
subtitle_header_size
=
dec
->
subtitle_header_size
;
}
if
(
!
av_dict_get
(
ost
->
encoder_opts
,
"threads"
,
NULL
,
0
))
av_dict_set
(
&
ost
->
encoder_opts
,
"threads"
,
"auto"
,
0
);
av_dict_set
(
&
ost
->
encoder_opts
,
"side_data_only_packets"
,
"1"
,
0
);
if
((
ret
=
avcodec_open2
(
ost
->
enc_ctx
,
codec
,
&
ost
->
encoder_opts
))
<
0
)
{
if
(
ret
==
AVERROR_EXPERIMENTAL
)
abort_codec_experimental
(
codec
,
1
);
snprintf
(
error
,
error_len
,
"Error while opening encoder for output stream #%d:%d - "
"maybe incorrect parameters such as bit_rate, rate, width or height"
,
ost
->
file_index
,
ost
->
index
);
return
ret
;
}
assert_avoptions
(
ost
->
encoder_opts
);
if
(
ost
->
enc_ctx
->
bit_rate
&&
ost
->
enc_ctx
->
bit_rate
<
1000
)
av_log
(
NULL
,
AV_LOG_WARNING
,
"The bitrate parameter is set too low."
"It takes bits/s as argument, not kbits/s
\n
"
);
ret
=
avcodec_copy_context
(
ost
->
st
->
codec
,
ost
->
enc_ctx
);
if
(
ret
<
0
)
{
av_log
(
NULL
,
AV_LOG_FATAL
,
"Error initializing the output stream codec context.
\n
"
);
exit_program
(
1
);
}
ost
->
st
->
time_base
=
ost
->
enc_ctx
->
time_base
;
}
else
{
ret
=
av_opt_set_dict
(
ost
->
enc_ctx
,
&
ost
->
encoder_opts
);
if
(
ret
<
0
)
return
ret
;
ost
->
st
->
time_base
=
ost
->
st
->
codec
->
time_base
;
}
return
ret
;
}
static
void
parse_forced_key_frames
(
char
*
kf
,
OutputStream
*
ost
,
AVCodecContext
*
avctx
)
{
...
...
@@ -1863,52 +1917,9 @@ static int transcode_init(void)
/* open each encoder */
for
(
i
=
0
;
i
<
nb_output_streams
;
i
++
)
{
ost
=
output_streams
[
i
];
if
(
ost
->
encoding_needed
)
{
AVCodec
*
codec
=
ost
->
enc
;
AVCodecContext
*
dec
=
NULL
;
if
((
ist
=
get_input_stream
(
ost
)))
dec
=
ist
->
dec_ctx
;
if
(
dec
&&
dec
->
subtitle_header
)
{
ost
->
enc_ctx
->
subtitle_header
=
av_malloc
(
dec
->
subtitle_header_size
);
if
(
!
ost
->
enc_ctx
->
subtitle_header
)
{
ret
=
AVERROR
(
ENOMEM
);
goto
dump_format
;
}
memcpy
(
ost
->
enc_ctx
->
subtitle_header
,
dec
->
subtitle_header
,
dec
->
subtitle_header_size
);
ost
->
enc_ctx
->
subtitle_header_size
=
dec
->
subtitle_header_size
;
}
if
(
!
av_dict_get
(
ost
->
encoder_opts
,
"threads"
,
NULL
,
0
))
av_dict_set
(
&
ost
->
encoder_opts
,
"threads"
,
"auto"
,
0
);
av_dict_set
(
&
ost
->
encoder_opts
,
"side_data_only_packets"
,
"1"
,
0
);
if
((
ret
=
avcodec_open2
(
ost
->
enc_ctx
,
codec
,
&
ost
->
encoder_opts
))
<
0
)
{
if
(
ret
==
AVERROR_EXPERIMENTAL
)
abort_codec_experimental
(
codec
,
1
);
snprintf
(
error
,
sizeof
(
error
),
"Error while opening encoder for output stream #%d:%d - maybe incorrect parameters such as bit_rate, rate, width or height"
,
ost
->
file_index
,
ost
->
index
);
goto
dump_format
;
}
assert_avoptions
(
ost
->
encoder_opts
);
if
(
ost
->
enc_ctx
->
bit_rate
&&
ost
->
enc_ctx
->
bit_rate
<
1000
)
av_log
(
NULL
,
AV_LOG_WARNING
,
"The bitrate parameter is set too low."
"It takes bits/s as argument, not kbits/s
\n
"
);
ret
=
avcodec_copy_context
(
ost
->
st
->
codec
,
ost
->
enc_ctx
);
if
(
ret
<
0
)
{
av_log
(
NULL
,
AV_LOG_FATAL
,
"Error initializing the output stream codec context.
\n
"
);
exit_program
(
1
);
}
ost
->
st
->
time_base
=
ost
->
enc_ctx
->
time_base
;
}
else
{
ret
=
av_opt_set_dict
(
ost
->
enc_ctx
,
&
ost
->
encoder_opts
);
if
(
ret
<
0
)
return
ret
;
ost
->
st
->
time_base
=
ost
->
st
->
codec
->
time_base
;
}
ret
=
init_output_stream
(
output_streams
[
i
],
error
,
sizeof
(
error
));
if
(
ret
<
0
)
goto
dump_format
;
}
/* init input streams */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录