Commit 1e06a2b5 authored by Julian Rother's avatar Julian Rother
Browse files

remux: Added "format" and "options" parameters

parent e1fac6aa
...@@ -8,9 +8,15 @@ static AVRational chapter_time_base = {1, 1}; ...@@ -8,9 +8,15 @@ static AVRational chapter_time_base = {1, 1};
void parse_dict(AVDictionary **d, char *s) void parse_dict(AVDictionary **d, char *s)
{ {
char *val;
char key[JSTR_SIZE], value[JSTR_SIZE]; char key[JSTR_SIZE], value[JSTR_SIZE];
for (s = jenter(s); s; s = jnext(s)) 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) void parse_chapters(AVFormatContext *ctx, char *s, int duration)
...@@ -42,6 +48,7 @@ int main(int argc, char *argv[]) ...@@ -42,6 +48,7 @@ int main(int argc, char *argv[])
AVFormatContext *demux, *mux; AVFormatContext *demux, *mux;
AVPacket pkt; AVPacket pkt;
AVStream *stream; AVStream *stream;
AVDictionary *muxopts;
if (argc != 5) if (argc != 5)
return 1; return 1;
av_register_all(); av_register_all();
...@@ -59,7 +66,7 @@ int main(int argc, char *argv[]) ...@@ -59,7 +66,7 @@ int main(int argc, char *argv[])
if (avformat_open_input(&demux, path, 0, 0)) if (avformat_open_input(&demux, path, 0, 0))
goto fail; goto fail;
avformat_find_stream_info(demux, 0); 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); av_dict_copy(&mux->metadata, demux->metadata, 0);
parse_dict(&mux->metadata, jlookup(argv[4], "metadata")); 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)); 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[]) ...@@ -80,7 +87,9 @@ int main(int argc, char *argv[])
mux->streams[i]->time_base = demux->streams[i]->time_base; mux->streams[i]->time_base = demux->streams[i]->time_base;
} }
avio_open(&mux->pb, tmp, AVIO_FLAG_WRITE); 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; goto fail;
while (!av_read_frame(demux, &pkt)) while (!av_read_frame(demux, &pkt))
{ {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment