aboutsummaryrefslogtreecommitdiffstats
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-11-07 02:41:01 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-11-07 03:01:43 +0100
commit13b7781ec8d475513c1ee40a6e481763b728a71e (patch)
tree953bee0a6461e74085e45e1f7793de6f850534e5 /ffmpeg.c
parentada8d485c0f77a4e79fac7f3f96031c4d0e6bc7a (diff)
parentf2bd8a0786ded12c70d6877f16944b44ea731462 (diff)
downloadffmpeg-13b7781ec8d475513c1ee40a6e481763b728a71e.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: (23 commits) x86inc: use sse versions of common macros instead of sse2 when applicable doc/APIchanges: add missing dates and hashes lavf: don't return from void av_update_cur_dts() Changelog: add more entries. Changelog: update ffmpeg/avconv incompatibility list. avconv: remove some redundant temporary variables. avconv: fix broken indentation avconv: move copy_initial_nonkeyframes to the options context. avconv: use file:stream instead of file.stream in log messages. doc/avconv: elaborate on basic functionality. doc/avconv: -sample_fmts, not -help sample_fmts prints the sample formats openssl: Only use CRYPTO_set_id_callback on OpenSSL < 1.0.0 Call avformat_network_init/deinit in the programs Remove leftover includes of strings.h avutil: Don't allow using strcasecmp/strncasecmp Replace all usage of strcasecmp/strncasecmp avstring: Add locale independent implementations of strcasecmp/strncasecmp avstring: Add locale independent implementations of toupper/tolower cosmetics: insert some spaces in explicit enum value assignments move 8SVX audio codecs to the audio codec list part on the next bump ... Conflicts: avprobe.c doc/APIchanges ffplay.c ffserver.c libavcodec/avcodec.h libavdevice/bktr.c libavdevice/v4l.c libavdevice/v4l2.c libavformat/matroskaenc.c libavformat/wtv.c libavutil/avstring.c libavutil/avstring.h libavutil/avutil.h libswscale/x86/swscale_template.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c63
1 files changed, 34 insertions, 29 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index a836c98abb..f7232c9f8d 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -144,7 +144,6 @@ static int copy_tb= 0;
static int opt_shortest = 0;
static char *vstats_filename;
static FILE *vstats_file;
-static int copy_initial_nonkeyframes = 0;
static int audio_volume = 256;
@@ -255,11 +254,12 @@ typedef struct OutputStream {
AVFilterGraph *graph;
#endif
- int64_t sws_flags;
- AVDictionary *opts;
- int is_past_recording_time;
- int stream_copy;
- const char *attachment_filename;
+ int64_t sws_flags;
+ AVDictionary *opts;
+ int is_past_recording_time;
+ int stream_copy;
+ const char *attachment_filename;
+ int copy_initial_nonkeyframes;
} OutputStream;
@@ -375,6 +375,8 @@ typedef struct OptionsContext {
int nb_top_field_first;
SpecifierOpt *presets;
int nb_presets;
+ SpecifierOpt *copy_initial_nonkeyframes;
+ int nb_copy_initial_nonkeyframes;
#if CONFIG_AVFILTER
SpecifierOpt *filters;
int nb_filters;
@@ -569,6 +571,7 @@ static void term_init(void)
signal(SIGQUIT, sigterm_handler); /* Quit (POSIX). */
}
#endif
+ avformat_network_deinit();
signal(SIGINT , sigterm_handler); /* Interrupt (ANSI). */
signal(SIGTERM, sigterm_handler); /* Termination (ANSI). */
@@ -672,6 +675,7 @@ void exit_program(int ret)
#if CONFIG_AVFILTER
avfilter_uninit();
#endif
+ avformat_network_deinit();
av_freep(&input_tmp);
@@ -869,7 +873,7 @@ need_realloc:
if ((ost->audio_resample && !ost->swr) || resample_changed || ost->audio_channels_mapped) {
if (resample_changed) {
- av_log(NULL, AV_LOG_INFO, "Input stream #%d.%d frame changed from rate:%d fmt:%s ch:%d to rate:%d fmt:%s ch:%d\n",
+ av_log(NULL, AV_LOG_INFO, "Input stream #%d:%d frame changed from rate:%d fmt:%s ch:%d to rate:%d fmt:%s ch:%d\n",
ist->file_index, ist->st->index,
ost->resample_sample_rate, av_get_sample_fmt_name(ost->resample_sample_fmt), ost->resample_channels,
dec->sample_rate, av_get_sample_fmt_name(dec->sample_fmt), dec->channels);
@@ -1165,7 +1169,7 @@ static void do_video_resample(OutputStream *ost,
*out_picture = in_picture;
if (resample_changed) {
av_log(NULL, AV_LOG_INFO,
- "Input stream #%d.%d frame changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n",
+ "Input stream #%d:%d frame changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n",
ist->file_index, ist->st->index,
ost->resample_width, ost->resample_height, av_get_pix_fmt_name(ost->resample_pix_fmt),
dec->width , dec->height , av_get_pix_fmt_name(dec->pix_fmt));
@@ -1918,7 +1922,8 @@ static int output_packet(InputStream *ist, int ist_index,
int64_t ost_tb_start_time= av_rescale_q(of->start_time, AV_TIME_BASE_Q, ost->st->time_base);
av_init_packet(&opkt);
- if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) && !copy_initial_nonkeyframes)
+ if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) &&
+ !ost->copy_initial_nonkeyframes)
#if !CONFIG_AVFILTER
continue;
#else
@@ -2024,12 +2029,12 @@ static int init_input_stream(int ist_index, OutputStream *output_streams, int nb
if (ist->decoding_needed) {
AVCodec *codec = ist->dec;
if (!codec) {
- snprintf(error, error_len, "Decoder (codec %s) not found for input stream #%d.%d",
+ snprintf(error, error_len, "Decoder (codec %s) not found for input stream #%d:%d",
avcodec_get_name(ist->st->codec->codec_id), ist->file_index, ist->st->index);
return AVERROR(EINVAL);
}
if (avcodec_open2(ist->st->codec, codec, &ist->opts) < 0) {
- snprintf(error, error_len, "Error while opening decoder for input stream #%d.%d",
+ snprintf(error, error_len, "Error while opening decoder for input stream #%d:%d",
ist->file_index, ist->st->index);
return AVERROR(EINVAL);
}
@@ -2330,7 +2335,7 @@ static int transcode_init(OutputFile *output_files, int nb_output_files,
AVCodec *codec = ost->enc;
AVCodecContext *dec = input_streams[ost->source_index].st->codec;
if (!codec) {
- snprintf(error, sizeof(error), "Encoder (codec %s) not found for output stream #%d.%d",
+ snprintf(error, sizeof(error), "Encoder (codec %s) not found for output stream #%d:%d",
avcodec_get_name(ost->st->codec->codec_id), ost->file_index, ost->index);
ret = AVERROR(EINVAL);
goto dump_format;
@@ -2345,7 +2350,7 @@ static int transcode_init(OutputFile *output_files, int nb_output_files,
ost->st->codec->subtitle_header_size = dec->subtitle_header_size;
}
if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) {
- snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height",
+ snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d:%d - maybe incorrect parameters such as bit_rate, rate, width or height",
ost->file_index, ost->index);
ret = AVERROR(EINVAL);
goto dump_format;
@@ -2415,7 +2420,7 @@ static int transcode_init(OutputFile *output_files, int nb_output_files,
ost->attachment_filename, ost->file_index, ost->index);
continue;
}
- av_log(NULL, AV_LOG_INFO, " Stream #%d.%d -> #%d.%d",
+ av_log(NULL, AV_LOG_INFO, " Stream #%d:%d -> #%d:%d",
input_streams[ost->source_index].file_index,
input_streams[ost->source_index].st->index,
ost->file_index,
@@ -2430,7 +2435,7 @@ static int transcode_init(OutputFile *output_files, int nb_output_files,
av_log(NULL, AV_LOG_INFO, "]");
}
if (ost->sync_ist != &input_streams[ost->source_index])
- av_log(NULL, AV_LOG_INFO, " [sync #%d.%d]",
+ av_log(NULL, AV_LOG_INFO, " [sync #%d:%d]",
ost->sync_ist->file_index,
ost->sync_ist->st->index);
if (ost->stream_copy)
@@ -2691,7 +2696,7 @@ static int transcode(OutputFile *output_files, int nb_output_files,
//fprintf(stderr,"read #%d.%d size=%d\n", ist->file_index, ist->st->index, pkt.size);
if (output_packet(ist, ist_index, output_streams, nb_output_streams, &pkt) < 0) {
- av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d.%d\n",
+ av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d\n",
ist->file_index, ist->st->index);
if (exit_on_error)
exit_program(1);
@@ -3114,7 +3119,6 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
AVStream *st = ic->streams[i];
AVCodecContext *dec = st->codec;
InputStream *ist;
- double scale = 1.0;
input_streams = grow_array(input_streams, sizeof(*input_streams), &nb_input_streams, nb_input_streams + 1);
ist = &input_streams[nb_input_streams - 1];
@@ -3123,8 +3127,8 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
ist->discard = 1;
ist->opts = filter_codec_opts(codec_opts, ist->st->codec->codec_id, ic, st);
- MATCH_PER_STREAM_OPT(ts_scale, dbl, scale, ic, st);
- ist->ts_scale = scale;
+ ist->ts_scale = 1.0;
+ MATCH_PER_STREAM_OPT(ts_scale, dbl, ist->ts_scale, ic, st);
MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, ic, st);
if (codec_tag) {
@@ -3454,7 +3458,6 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
OutputStream *ost;
AVStream *st = avformat_new_stream(oc, NULL);
int idx = oc->nb_streams - 1, ret = 0;
- int64_t max_frames = INT64_MAX;
char *bsf = NULL, *next, *codec_tag = NULL;
AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;
double qscale = -1;
@@ -3509,8 +3512,8 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
exit_program(1);
}
- MATCH_PER_STREAM_OPT(max_frames, i64, max_frames, oc, st);
- ost->max_frames = max_frames;
+ ost->max_frames = INT64_MAX;
+ MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st);
MATCH_PER_STREAM_OPT(bitstream_filters, str, bsf, oc, st);
while (bsf) {
@@ -3582,7 +3585,7 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc)
char *forced_key_frames = NULL, *frame_rate = NULL, *frame_size = NULL;
char *frame_aspect_ratio = NULL, *frame_pix_fmt = NULL;
char *intra_matrix = NULL, *inter_matrix = NULL, *filters = NULL;
- int i, force_fps = 0, top_field_first = -1;
+ int i;
MATCH_PER_STREAM_OPT(frame_rates, str, frame_rate, oc, st);
if (frame_rate && av_parse_video_rate(&ost->frame_rate, frame_rate) < 0) {
@@ -3671,11 +3674,12 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc)
if (forced_key_frames)
parse_forced_key_frames(forced_key_frames, ost);
- MATCH_PER_STREAM_OPT(force_fps, i, force_fps, oc, st);
- ost->force_fps = force_fps;
+ MATCH_PER_STREAM_OPT(force_fps, i, ost->force_fps, oc, st);
+
+ ost->top_field_first = -1;
+ MATCH_PER_STREAM_OPT(top_field_first, i, ost->top_field_first, oc, st);
- MATCH_PER_STREAM_OPT(top_field_first, i, top_field_first, oc, st);
- ost->top_field_first = top_field_first;
+ MATCH_PER_STREAM_OPT(copy_initial_nonkeyframes, i, ost->copy_initial_nonkeyframes, oc ,st);
#if CONFIG_AVFILTER
MATCH_PER_STREAM_OPT(filters, str, filters, oc, st);
@@ -3980,7 +3984,7 @@ static void opt_output_file(void *optctx, const char *filename)
case AVMEDIA_TYPE_DATA: ost = new_data_stream(o, oc); break;
case AVMEDIA_TYPE_ATTACHMENT: ost = new_attachment_stream(o, oc); break;
default:
- av_log(NULL, AV_LOG_FATAL, "Cannot map stream #%d.%d - unsupported type.\n",
+ av_log(NULL, AV_LOG_FATAL, "Cannot map stream #%d:%d - unsupported type.\n",
map->file_index, map->stream_index);
exit_program(1);
}
@@ -4580,7 +4584,7 @@ static const OptionDef options[] = {
{ "shortest", OPT_BOOL | OPT_EXPERT, {(void*)&opt_shortest}, "finish encoding within shortest input" }, //
{ "dts_delta_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {(void*)&dts_delta_threshold}, "timestamp discontinuity delta threshold", "threshold" },
{ "xerror", OPT_BOOL, {(void*)&exit_on_error}, "exit on error", "error" },
- { "copyinkf", OPT_BOOL | OPT_EXPERT, {(void*)&copy_initial_nonkeyframes}, "copy initial non-keyframes" },
+ { "copyinkf", OPT_BOOL | OPT_EXPERT | OPT_SPEC, {.off = OFFSET(copy_initial_nonkeyframes)}, "copy initial non-keyframes" },
{ "frames", OPT_INT64 | HAS_ARG | OPT_SPEC, {.off = OFFSET(max_frames)}, "set the number of frames to record", "number" },
{ "tag", OPT_STRING | HAS_ARG | OPT_SPEC, {.off = OFFSET(codec_tags)}, "force codec tag/fourcc", "fourcc/tag" },
{ "q", HAS_ARG | OPT_EXPERT | OPT_DOUBLE | OPT_SPEC, {.off = OFFSET(qscale)}, "use fixed quality scale (VBR)", "q" },
@@ -4702,6 +4706,7 @@ int main(int argc, char **argv)
avfilter_register_all();
#endif
av_register_all();
+ avformat_network_init();
#if HAVE_ISATTY
if(isatty(STDIN_FILENO))