Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Video AG Infrastruktur
ffworker
Commits
1e06a2b5
Commit
1e06a2b5
authored
Oct 29, 2017
by
Julian Rother
Browse files
remux: Added "format" and "options" parameters
parent
e1fac6aa
Changes
1
Hide whitespace changes
Inline
Side-by-side
remux.c
View file @
1e06a2b5
...
...
@@ -8,9 +8,15 @@ static AVRational chapter_time_base = {1, 1};
void
parse_dict
(
AVDictionary
**
d
,
char
*
s
)
{
char
*
val
;
char
key
[
JSTR_SIZE
],
value
[
JSTR_SIZE
];
for
(
s
=
jenter
(
s
);
s
;
s
=
jnext
(
s
))
av_dict_set
(
d
,
jstrb
(
s
,
0
,
key
),
jstrb
(
jvalue
(
s
),
0
,
value
),
0
);
{
if
(
val
=
jstrb
(
jvalue
(
s
),
0
,
value
))
av_dict_set
(
d
,
jstrb
(
s
,
0
,
key
),
val
,
0
);
else
av_dict_set_int
(
d
,
jstrb
(
s
,
0
,
key
),
jint
(
jvalue
(
s
),
0
),
0
);
}
}
void
parse_chapters
(
AVFormatContext
*
ctx
,
char
*
s
,
int
duration
)
...
...
@@ -42,6 +48,7 @@ int main(int argc, char *argv[])
AVFormatContext
*
demux
,
*
mux
;
AVPacket
pkt
;
AVStream
*
stream
;
AVDictionary
*
muxopts
;
if
(
argc
!=
5
)
return
1
;
av_register_all
();
...
...
@@ -59,7 +66,7 @@ int main(int argc, char *argv[])
if
(
avformat_open_input
(
&
demux
,
path
,
0
,
0
))
goto
fail
;
avformat_find_stream_info
(
demux
,
0
);
avformat_alloc_output_context2
(
&
mux
,
0
,
0
,
path
);
avformat_alloc_output_context2
(
&
mux
,
0
,
jstr
(
jlookup
(
argv
[
4
],
"format"
),
0
)
,
path
);
av_dict_copy
(
&
mux
->
metadata
,
demux
->
metadata
,
0
);
parse_dict
(
&
mux
->
metadata
,
jlookup
(
argv
[
4
],
"metadata"
));
parse_chapters
(
mux
,
jlookup
(
argv
[
4
],
"chapters"
),
av_rescale_q
(
demux
->
duration
,
AV_TIME_BASE_Q
,
chapter_time_base
));
...
...
@@ -80,7 +87,9 @@ int main(int argc, char *argv[])
mux
->
streams
[
i
]
->
time_base
=
demux
->
streams
[
i
]
->
time_base
;
}
avio_open
(
&
mux
->
pb
,
tmp
,
AVIO_FLAG_WRITE
);
if
(
avformat_write_header
(
mux
,
0
)
<
0
)
muxopts
=
0
;
parse_dict
(
&
muxopts
,
jlookup
(
argv
[
4
],
"options"
));
if
(
avformat_write_header
(
mux
,
&
muxopts
)
<
0
)
goto
fail
;
while
(
!
av_read_frame
(
demux
,
&
pkt
))
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment