aboutsummaryrefslogtreecommitdiff
path: root/ffmpeg_opt.c
diff options
context:
space:
mode:
authorMichael Niedermayer2015-12-15 16:27:52 +0100
committerMichael Niedermayer2015-12-16 14:03:57 +0100
commit30d770ca448131fba207d9603ff438dea15d10ba (patch)
tree74004cbfc747e15e5cde3e16282ded3b3e903f28 /ffmpeg_opt.c
parent83a04f103d387a8b7f574d97d340d90f42fc18de (diff)
ffmpeg: Allow specifying the program number for created programs
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'ffmpeg_opt.c')
-rw-r--r--ffmpeg_opt.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index fd2c0517cf..3df46da15e 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -2418,7 +2418,7 @@ loop_end:
for (i = 0; i < o->nb_program; i++) {
const char *p = o->program[i].u.str;
int progid = i+1;
- AVProgram *program = av_new_program(oc, progid);
+ AVProgram *program;
while(*p) {
const char *p2 = av_get_token(&p, ":");
@@ -2428,6 +2428,25 @@ loop_end:
if(*p) p++;
key = av_get_token(&p2, "=");
+ if (!key || !*p2)
+ break;
+ p2++;
+
+ if (!strcmp(key, "program_num"))
+ progid = strtol(p2, NULL, 0);
+ }
+
+ program = av_new_program(oc, progid);
+
+ p = o->program[i].u.str;
+ while(*p) {
+ const char *p2 = av_get_token(&p, ":");
+ char *key;
+ if (!p2)
+ break;
+ if(*p) p++;
+
+ key = av_get_token(&p2, "=");
if (!key) {
av_log(NULL, AV_LOG_FATAL,
"No '=' character in program string %s.\n",
@@ -2440,6 +2459,7 @@ loop_end:
if (!strcmp(key, "title")) {
av_dict_set(&program->metadata, "title", p2, 0);
+ } else if (!strcmp(key, "program_num")) {
} else if (!strcmp(key, "st")) {
int st_num = strtol(p2, NULL, 0);
av_program_add_stream_index(oc, progid, st_num);