Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 53056d262dbd878db5e8eb552420f1fd12376c32 Mon Sep 17 00:00:00 2001
- From: Alexander Strange <astrange@ithinksw.com>
- Date: Mon, 29 Mar 2010 03:48:29 -0400
- Subject: [PATCH 1/4] Add missing b-pyramid flag to the "default" libx264 preset
- ---
- ffpresets/libx264-default.ffpreset | 2 +-
- 1 files changed, 1 insertions(+), 1 deletions(-)
- diff --git a/ffpresets/libx264-default.ffpreset b/ffpresets/libx264-default.ffpreset
- index 75191e2..039f1d6 100644
- --- a/ffpresets/libx264-default.ffpreset
- +++ b/ffpresets/libx264-default.ffpreset
- @@ -18,5 +18,5 @@ bf=3
- refs=3
- directpred=1
- trellis=1
- -flags2=+mixed_refs+wpred+dct8x8+fastpskip
- +flags2=+bpyramid+mixed_refs+wpred+dct8x8+fastpskip
- wpredp=2
- --
- 1.7.0.2
- From 37480b5359d70d5e68b87b277d7925fe136a00d9 Mon Sep 17 00:00:00 2001
- From: Alexander Strange <astrange@ithinksw.com>
- Date: Mon, 29 Mar 2010 03:13:17 -0400
- Subject: [PATCH 2/4] ffmpeg: Move opt_preset() higher up so it can be called from elsewhere
- ---
- ffmpeg.c | 114 +++++++++++++++++++++++++++++++-------------------------------
- 1 files changed, 57 insertions(+), 57 deletions(-)
- diff --git a/ffmpeg.c b/ffmpeg.c
- index 951b0da..4ae785e 100644
- --- a/ffmpeg.c
- +++ b/ffmpeg.c
- @@ -3122,6 +3122,63 @@ static void check_audio_video_sub_inputs(int *has_video_ptr, int *has_audio_ptr,
- *has_subtitle_ptr = has_subtitle;
- }
- +static int opt_preset(const char *opt, const char *arg)
- +{
- + FILE *f=NULL;
- + char filename[1000], tmp[1000], tmp2[1000], line[1000];
- + int i;
- + const char *base[2]= { getenv("HOME"),
- + FFMPEG_DATADIR,
- + };
- +
- + if (*opt != 'f') {
- + for(i=!base[0]; i<2 && !f; i++){
- + snprintf(filename, sizeof(filename), "%s%s/%s.ffpreset", base[i], i ? "" : "/.ffmpeg", arg);
- + f= fopen(filename, "r");
- + if(!f){
- + char *codec_name= *opt == 'v' ? video_codec_name :
- + *opt == 'a' ? audio_codec_name :
- + subtitle_codec_name;
- + snprintf(filename, sizeof(filename), "%s%s/%s-%s.ffpreset", base[i], i ? "" : "/.ffmpeg", codec_name, arg);
- + f= fopen(filename, "r");
- + }
- + }
- + } else {
- + av_strlcpy(filename, arg, sizeof(filename));
- + f= fopen(filename, "r");
- + }
- +
- + if(!f){
- + fprintf(stderr, "File for preset '%s' not found\n", arg);
- + av_exit(1);
- + }
- +
- + while(!feof(f)){
- + int e= fscanf(f, "%999[^\n]\n", line) - 1;
- + if(line[0] == '#' && !e)
- + continue;
- + e|= sscanf(line, "%999[^=]=%999[^\n]\n", tmp, tmp2) - 2;
- + if(e){
- + fprintf(stderr, "%s: Invalid syntax: '%s'\n", filename, line);
- + av_exit(1);
- + }
- + if(!strcmp(tmp, "acodec")){
- + opt_audio_codec(tmp2);
- + }else if(!strcmp(tmp, "vcodec")){
- + opt_video_codec(tmp2);
- + }else if(!strcmp(tmp, "scodec")){
- + opt_subtitle_codec(tmp2);
- + }else if(opt_default(tmp, tmp2) < 0){
- + fprintf(stderr, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n", filename, line, tmp, tmp2);
- + av_exit(1);
- + }
- + }
- +
- + fclose(f);
- +
- + return 0;
- +}
- +
- static void new_video_stream(AVFormatContext *oc)
- {
- AVStream *st;
- @@ -3884,63 +3941,6 @@ static int opt_bsf(const char *opt, const char *arg)
- return 0;
- }
- -static int opt_preset(const char *opt, const char *arg)
- -{
- - FILE *f=NULL;
- - char filename[1000], tmp[1000], tmp2[1000], line[1000];
- - int i;
- - const char *base[2]= { getenv("HOME"),
- - FFMPEG_DATADIR,
- - };
- -
- - if (*opt != 'f') {
- - for(i=!base[0]; i<2 && !f; i++){
- - snprintf(filename, sizeof(filename), "%s%s/%s.ffpreset", base[i], i ? "" : "/.ffmpeg", arg);
- - f= fopen(filename, "r");
- - if(!f){
- - char *codec_name= *opt == 'v' ? video_codec_name :
- - *opt == 'a' ? audio_codec_name :
- - subtitle_codec_name;
- - snprintf(filename, sizeof(filename), "%s%s/%s-%s.ffpreset", base[i], i ? "" : "/.ffmpeg", codec_name, arg);
- - f= fopen(filename, "r");
- - }
- - }
- - } else {
- - av_strlcpy(filename, arg, sizeof(filename));
- - f= fopen(filename, "r");
- - }
- -
- - if(!f){
- - fprintf(stderr, "File for preset '%s' not found\n", arg);
- - av_exit(1);
- - }
- -
- - while(!feof(f)){
- - int e= fscanf(f, "%999[^\n]\n", line) - 1;
- - if(line[0] == '#' && !e)
- - continue;
- - e|= sscanf(line, "%999[^=]=%999[^\n]\n", tmp, tmp2) - 2;
- - if(e){
- - fprintf(stderr, "%s: Invalid syntax: '%s'\n", filename, line);
- - av_exit(1);
- - }
- - if(!strcmp(tmp, "acodec")){
- - opt_audio_codec(tmp2);
- - }else if(!strcmp(tmp, "vcodec")){
- - opt_video_codec(tmp2);
- - }else if(!strcmp(tmp, "scodec")){
- - opt_subtitle_codec(tmp2);
- - }else if(opt_default(tmp, tmp2) < 0){
- - fprintf(stderr, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n", filename, line, tmp, tmp2);
- - av_exit(1);
- - }
- - }
- -
- - fclose(f);
- -
- - return 0;
- -}
- -
- static const OptionDef options[] = {
- /* main options */
- #include "cmdutils_common_opts.h"
- --
- 1.7.0.2
- From 6b9e5db459ae98a3ca61defa1d0474931aae310f Mon Sep 17 00:00:00 2001
- From: Alexander Strange <astrange@ithinksw.com>
- Date: Mon, 29 Mar 2010 03:46:41 -0400
- Subject: [PATCH 3/4] ffmpeg: Adjust new_audio_stream() to allow for future changes
- ---
- ffmpeg.c | 4 ++--
- 1 files changed, 2 insertions(+), 2 deletions(-)
- diff --git a/ffmpeg.c b/ffmpeg.c
- index 4ae785e..06a0ea9 100644
- --- a/ffmpeg.c
- +++ b/ffmpeg.c
- @@ -3362,8 +3362,6 @@ static void new_audio_stream(AVFormatContext *oc)
- } else {
- AVCodec *codec;
- - set_context_opts(audio_enc, avcodec_opts[CODEC_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM);
- -
- if (audio_codec_name) {
- codec_id = find_codec_or_die(audio_codec_name, CODEC_TYPE_AUDIO, 1);
- codec = avcodec_find_encoder_by_name(audio_codec_name);
- @@ -3374,6 +3372,8 @@ static void new_audio_stream(AVFormatContext *oc)
- }
- audio_enc->codec_id = codec_id;
- + set_context_opts(audio_enc, avcodec_opts[CODEC_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM);
- +
- if (audio_qscale > QSCALE_NONE) {
- audio_enc->flags |= CODEC_FLAG_QSCALE;
- audio_enc->global_quality = st->quality = FF_QP2LAMBDA * audio_qscale;
- --
- 1.7.0.2
- From 898cc451d3d70d74b5d5cd8fafe98248a21d0b84 Mon Sep 17 00:00:00 2001
- From: Alexander Strange <astrange@ithinksw.com>
- Date: Mon, 29 Mar 2010 03:14:52 -0400
- Subject: [PATCH 4/4] ffmpeg: Look for a preset named "default" if none is specified.
- This allows specifying per-codec defaults by writing a preset file.
- ---
- ffmpeg.c | 24 ++++++++++++++++++++++++
- 1 files changed, 24 insertions(+), 0 deletions(-)
- diff --git a/ffmpeg.c b/ffmpeg.c
- index 06a0ea9..cd65037 100644
- --- a/ffmpeg.c
- +++ b/ffmpeg.c
- @@ -218,6 +218,10 @@ static int force_fps = 0;
- static int pgmyuv_compatibility_hack=0;
- static float dts_delta_threshold = 10;
- +static int used_vpre = 0;
- +static int used_apre = 0;
- +static int used_spre = 0;
- +
- static unsigned int sws_flags = SWS_BICUBIC;
- static int64_t timer_start;
- @@ -2751,6 +2755,7 @@ static void opt_codec(int *pstream_copy, char **pcodec_name,
- static void opt_audio_codec(const char *arg)
- {
- + used_apre = 0;
- opt_codec(&audio_stream_copy, &audio_codec_name, CODEC_TYPE_AUDIO, arg);
- }
- @@ -2774,11 +2779,13 @@ static void opt_video_tag(const char *arg)
- static void opt_video_codec(const char *arg)
- {
- + used_vpre = 0;
- opt_codec(&video_stream_copy, &video_codec_name, CODEC_TYPE_VIDEO, arg);
- }
- static void opt_subtitle_codec(const char *arg)
- {
- + used_spre = 0;
- opt_codec(&subtitle_stream_copy, &subtitle_codec_name, CODEC_TYPE_SUBTITLE, arg);
- }
- @@ -3149,10 +3156,19 @@ static int opt_preset(const char *opt, const char *arg)
- }
- if(!f){
- + if (*opt != 'f' && !strcmp(arg, "default"))
- + return 0;
- fprintf(stderr, "File for preset '%s' not found\n", arg);
- av_exit(1);
- }
- + if (*opt == 'v')
- + used_vpre = 1;
- + else if (*opt == 'a')
- + used_apre = 1;
- + else if (*opt == 's')
- + used_spre = 1;
- +
- while(!feof(f)){
- int e= fscanf(f, "%999[^\n]\n", line) - 1;
- if(line[0] == '#' && !e)
- @@ -3229,10 +3245,13 @@ static void new_video_stream(AVFormatContext *oc)
- } else {
- codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, CODEC_TYPE_VIDEO);
- codec = avcodec_find_encoder(codec_id);
- + video_codec_name = av_strdup(codec->name);
- }
- video_enc->codec_id = codec_id;
- + if (!used_vpre)
- + opt_preset("vpre", "default");
- set_context_opts(video_enc, avcodec_opts[CODEC_TYPE_VIDEO], AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM);
- if (codec && codec->supported_framerates && !force_fps)
- @@ -3369,9 +3388,12 @@ static void new_audio_stream(AVFormatContext *oc)
- } else {
- codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, CODEC_TYPE_AUDIO);
- codec = avcodec_find_encoder(codec_id);
- + audio_codec_name = av_strdup(codec->name);
- }
- audio_enc->codec_id = codec_id;
- + if (!used_apre)
- + opt_preset("apre", "default");
- set_context_opts(audio_enc, avcodec_opts[CODEC_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM);
- if (audio_qscale > QSCALE_NONE) {
- @@ -3432,6 +3454,8 @@ static void new_subtitle_stream(AVFormatContext *oc)
- if (subtitle_stream_copy) {
- st->stream_copy = 1;
- } else {
- + if (!used_spre)
- + opt_preset("spre", "default");
- set_context_opts(avcodec_opts[CODEC_TYPE_SUBTITLE], subtitle_enc, AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_ENCODING_PARAM);
- subtitle_enc->codec_id = find_codec_or_die(subtitle_codec_name, CODEC_TYPE_SUBTITLE, 1);
- output_codecs[nb_ocodecs] = avcodec_find_encoder_by_name(subtitle_codec_name);
- --
- 1.7.0.2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement