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
2968 }2968 }
2969 }2969 }
2970 }2970 }
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 }
2971 }3002 }
2972 3003
2973 /* open each encoder */3004 /* open each encoder */
@@ -3879,6 +3910,7 @@ static int transcode(void) · 905 unmodified lines
3879 }3910 }
3880 av_freep(&ost->forced_kf_pts);3911 av_freep(&ost->forced_kf_pts);
3881 av_freep(&ost->apad);3912 av_freep(&ost->apad);
3913 av_freep(&ost->disposition);
3882 av_dict_free(&ost->encoder_opts);3914 av_dict_free(&ost->encoder_opts);
3883 av_dict_free(&ost->swr_opts);3915 av_dict_free(&ost->swr_opts);
3884 av_dict_free(&ost->resample_opts);3916 av_dict_free(&ost->resample_opts);
ffmpeg.h+3−0
@@ -206,6 +206,8 @@ typedef struct OptionsContext { · 205 unmodified lines
206 int nb_apad;206 int nb_apad;
207 SpecifierOpt *discard;207 SpecifierOpt *discard;
208 int nb_discard;208 int nb_discard;
209 SpecifierOpt *disposition;
210 int nb_disposition;
209} OptionsContext;211} OptionsContext;
210 212
211typedef struct InputFilter {213typedef struct InputFilter {
@@ -430,6 +432,7 @@ typedef struct OutputStream { · 218 unmodified lines
430 const char *attachment_filename;432 const char *attachment_filename;
431 int copy_initial_nonkeyframes;433 int copy_initial_nonkeyframes;
432 int copy_prior_start;434 int copy_prior_start;
435 char *disposition;
433 436
434 int keep_pix_fmt;437 int keep_pix_fmt;
435 438
ffmpeg_opt.c+6−0
@@ -1186,6 +1186,9 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e · 1185 unmodified lines
1186 ost->enc_ctx->global_quality = FF_QP2LAMBDA * qscale;1186 ost->enc_ctx->global_quality = FF_QP2LAMBDA * qscale;
1187 }1187 }
1188 1188
1189 MATCH_PER_STREAM_OPT(disposition, str, ost->disposition, oc, st);
1190 ost->disposition = av_strdup(ost->disposition);
1191
1189 if (oc->oformat->flags & AVFMT_GLOBALHEADER)1192 if (oc->oformat->flags & AVFMT_GLOBALHEADER)
1190 ost->enc_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER;1193 ost->enc_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER;
1191 1194
@@ -2937,6 +2940,9 @@ const OptionDef options[] = { · 1745 unmodified lines
2937 { "discard", OPT_STRING | HAS_ARG | OPT_SPEC |2940 { "discard", OPT_STRING | HAS_ARG | OPT_SPEC |
2938 OPT_INPUT, { .off = OFFSET(discard) },2941 OPT_INPUT, { .off = OFFSET(discard) },
2939 "discard", "" },2942 "discard", "" },
2943 { "disposition", OPT_STRING | HAS_ARG | OPT_SPEC |
2944 OPT_OUTPUT, { .off = OFFSET(disposition) },
2945 "disposition", "" },
2940 2946
2941 /* video options */2947 /* video options */
2942 { "vframes", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_video_frames },2948 { "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