Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
4a946aca
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,发现更多精彩内容 >>
提交
4a946aca
编写于
3月 28, 2017
作者:
M
Matthieu Bouron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
doc/examples/remuxing: switch to codecpar
Also limits remuxing to audio, video and subtitle streams.
上级
7e3e0f87
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
35 addition
and
7 deletion
+35
-7
doc/examples/remuxing.c
doc/examples/remuxing.c
+35
-7
未找到文件。
doc/examples/remuxing.c
浏览文件 @
4a946aca
...
...
@@ -50,6 +50,9 @@ int main(int argc, char **argv)
AVPacket
pkt
;
const
char
*
in_filename
,
*
out_filename
;
int
ret
,
i
;
int
stream_index
=
0
;
int
*
stream_mapping
=
NULL
;
int
stream_mapping_size
=
0
;
if
(
argc
<
3
)
{
printf
(
"usage: %s input output
\n
"
...
...
@@ -83,25 +86,42 @@ int main(int argc, char **argv)
goto
end
;
}
stream_mapping_size
=
ifmt_ctx
->
nb_streams
;
stream_mapping
=
av_mallocz_array
(
stream_mapping_size
,
sizeof
(
*
stream_mapping
));
if
(
!
stream_mapping
)
{
ret
=
AVERROR
(
ENOMEM
);
goto
end
;
}
ofmt
=
ofmt_ctx
->
oformat
;
for
(
i
=
0
;
i
<
ifmt_ctx
->
nb_streams
;
i
++
)
{
AVStream
*
out_stream
;
AVStream
*
in_stream
=
ifmt_ctx
->
streams
[
i
];
AVStream
*
out_stream
=
avformat_new_stream
(
ofmt_ctx
,
in_stream
->
codec
->
codec
);
AVCodecParameters
*
in_codecpar
=
in_stream
->
codecpar
;
if
(
in_codecpar
->
codec_type
!=
AVMEDIA_TYPE_AUDIO
&&
in_codecpar
->
codec_type
!=
AVMEDIA_TYPE_VIDEO
&&
in_codecpar
->
codec_type
!=
AVMEDIA_TYPE_SUBTITLE
)
{
stream_mapping
[
i
]
=
-
1
;
continue
;
}
stream_mapping
[
i
]
=
stream_index
++
;
out_stream
=
avformat_new_stream
(
ofmt_ctx
,
NULL
);
if
(
!
out_stream
)
{
fprintf
(
stderr
,
"Failed allocating output stream
\n
"
);
ret
=
AVERROR_UNKNOWN
;
goto
end
;
}
ret
=
avcodec_
copy_context
(
out_stream
->
codec
,
in_stream
->
codec
);
ret
=
avcodec_
parameters_copy
(
out_stream
->
codecpar
,
in_codecpar
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"Failed to copy co
ntext from input to output stream codec context
\n
"
);
fprintf
(
stderr
,
"Failed to copy co
dec parameters
\n
"
);
goto
end
;
}
out_stream
->
codec
->
codec_tag
=
0
;
if
(
ofmt_ctx
->
oformat
->
flags
&
AVFMT_GLOBALHEADER
)
out_stream
->
codec
->
flags
|=
AV_CODEC_FLAG_GLOBAL_HEADER
;
out_stream
->
codecpar
->
codec_tag
=
0
;
}
av_dump_format
(
ofmt_ctx
,
0
,
out_filename
,
1
);
...
...
@@ -127,8 +147,14 @@ int main(int argc, char **argv)
break
;
in_stream
=
ifmt_ctx
->
streams
[
pkt
.
stream_index
];
out_stream
=
ofmt_ctx
->
streams
[
pkt
.
stream_index
];
if
(
pkt
.
stream_index
>=
stream_mapping_size
||
stream_mapping
[
pkt
.
stream_index
]
<
0
)
{
av_packet_unref
(
&
pkt
);
continue
;
}
pkt
.
stream_index
=
stream_mapping
[
pkt
.
stream_index
];
out_stream
=
ofmt_ctx
->
streams
[
pkt
.
stream_index
];
log_packet
(
ifmt_ctx
,
&
pkt
,
"in"
);
/* copy packet */
...
...
@@ -156,6 +182,8 @@ end:
avio_closep
(
&
ofmt_ctx
->
pb
);
avformat_free_context
(
ofmt_ctx
);
av_freep
(
&
stream_mapping
);
if
(
ret
<
0
&&
ret
!=
AVERROR_EOF
)
{
fprintf
(
stderr
,
"Error occurred: %s
\n
"
,
av_err2str
(
ret
));
return
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录