History

ffmpeg: allow overriding and amending AVStream->disposition

Michael Niedermayer committed 11 years ago

Commit 85d7e021 parent a1062e13 files · +41 −0Browse files

Unified · Split

3 files
  1. ffmpeg.c +32 −0
  2. ffmpeg.h +3 −0
  3. ffmpeg_opt.c +6 −0
ffmpeg.c+32−0
@@ -2968,6 +2968,37 @@ static int transcode_init(void) · 2967 unmodified lines
29682968 }
29692969 }
29702970 }
2971+
2972+ if (ost->disposition) {
2973+ static const AVOption opts[] = {
2974+ { "disposition" , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit = "flags" },
2975+ { "default" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DEFAULT }, .unit = "flags" },
2976+ { "dub" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DUB }, .unit = "flags" },
2977+ { "original" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_ORIGINAL }, .unit = "flags" },
2978+ { "comment" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_COMMENT }, .unit = "flags" },
2979+ { "lyrics" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_LYRICS }, .unit = "flags" },
2980+ { "karaoke" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_KARAOKE }, .unit = "flags" },
2981+ { "forced" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_FORCED }, .unit = "flags" },
2982+ { "hearing_impaired" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_HEARING_IMPAIRED }, .unit = "flags" },
2983+ { "visual_impaired" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_VISUAL_IMPAIRED }, .unit = "flags" },
2984+ { "clean_effects" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CLEAN_EFFECTS }, .unit = "flags" },
2985+ { "captions" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CAPTIONS }, .unit = "flags" },
2986+ { "descriptions" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DESCRIPTIONS }, .unit = "flags" },
2987+ { "metadata" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_METADATA }, .unit = "flags" },
2988+ { NULL },
2989+ };
2990+ static const AVClass class = {
2991+ .class_name = "",
2992+ .item_name = av_default_item_name,
2993+ .option = opts,
2994+ .version = LIBAVUTIL_VERSION_INT,
2995+ };
2996+ const AVClass *pclass = &class;
2997+
2998+ ret = av_opt_eval_flags(&pclass, &opts[0], ost->disposition, &ost->st->disposition);
2999+ if (ret < 0)
3000+ goto dump_format;
3001+ }
29713002 }
29723003
29733004 /* open each encoder */
@@ -3879,6 +3910,7 @@ static int transcode(void) · 905 unmodified lines
38793910 }
38803911 av_freep(&ost->forced_kf_pts);
38813912 av_freep(&ost->apad);
3913+ av_freep(&ost->disposition);
38823914 av_dict_free(&ost->encoder_opts);
38833915 av_dict_free(&ost->swr_opts);
38843916 av_dict_free(&ost->resample_opts);
ffmpeg.h+3−0
@@ -206,6 +206,8 @@ typedef struct OptionsContext { · 205 unmodified lines
206206 int nb_apad;
207207 SpecifierOpt *discard;
208208 int nb_discard;
209+ SpecifierOpt *disposition;
210+ int nb_disposition;
209211 } OptionsContext;
210212
211213 typedef struct InputFilter {
@@ -430,6 +432,7 @@ typedef struct OutputStream { · 218 unmodified lines
430432 const char *attachment_filename;
431433 int copy_initial_nonkeyframes;
432434 int copy_prior_start;
435+ char *disposition;
433436
434437 int keep_pix_fmt;
435438
ffmpeg_opt.c+6−0
@@ -1186,6 +1186,9 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e · 1185 unmodified lines
11861186 ost->enc_ctx->global_quality = FF_QP2LAMBDA * qscale;
11871187 }
11881188
1189+ MATCH_PER_STREAM_OPT(disposition, str, ost->disposition, oc, st);
1190+ ost->disposition = av_strdup(ost->disposition);
1191+
11891192 if (oc->oformat->flags & AVFMT_GLOBALHEADER)
11901193 ost->enc_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER;
11911194
@@ -2937,6 +2940,9 @@ const OptionDef options[] = { · 1745 unmodified lines
29372940 { "discard", OPT_STRING | HAS_ARG | OPT_SPEC |
29382941 OPT_INPUT, { .off = OFFSET(discard) },
29392942 "discard", "" },
2943+ { "disposition", OPT_STRING | HAS_ARG | OPT_SPEC |
2944+ OPT_OUTPUT, { .off = OFFSET(disposition) },
2945+ "disposition", "" },
29402946
29412947 /* video options */
29422948 { "vframes", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_video_frames },

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t