summaryrefslogtreecommitdiff
path: root/avconv.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-11-19 01:55:55 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-11-19 02:00:06 +0100
commite161b079dee12b11c40df67cf422edeb84772bbe (patch)
treefe5000d84e5fc4049395822c4bf8b4d600851782 /avconv.c
parent36a60fad6215db39e9cd9523e3425f64464046c7 (diff)
parentff3755cbde9bdd2a4dc50e4432f72ddeef1a85ac (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: (22 commits) configure: add check for w32threads to enable it automatically rtmp: do not hardcode invoke numbers cinepack: return non-generic errors fate-lavf-ts: use -mpegts_transport_stream_id option. Add an APIchanges entry and a minor bump for avio changes. avio: Mark the old interrupt callback mechanism as deprecated avplay: Set the new interrupt callback avconv: Set new interrupt callbacks for all AVFormatContexts, use avio_open2() everywhere cinepak: remove redundant coordinate checks cinepak: check strip_size cinepak, simplify, use AV_RB24() cinepak: simplify, use FFMIN() cinepak: Fix division by zero, ask for sample if encoded_buf_size is 0 applehttp: Fix seeking in streams not starting at DTS=0 http: Don't use the normal http proxy mechanism for https tls: Handle connection via a http proxy http: Reorder two code blocks http: Add a new protocol for opening connections via http proxies http: Split out the non-chunked buffer reading part from http_read segafilm: add support for raw videos ... Conflicts: avconv.c configure doc/APIchanges libavcodec/cinepak.c libavformat/applehttp.c libavformat/version.h tests/lavf-regression.sh tests/ref/lavf/ts Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'avconv.c')
-rw-r--r--avconv.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/avconv.c b/avconv.c
index 76d8def806..a019ffaf6f 100644
--- a/avconv.c
+++ b/avconv.c
@@ -588,12 +588,14 @@ static int read_key(void)
return -1;
}
-static int decode_interrupt_cb(void)
+static int decode_interrupt_cb(void *ctx)
{
q_pressed += read_key() == 'q';
return q_pressed > 1;
}
+static const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL };
+
void exit_program(int ret)
{
int i;
@@ -2336,6 +2338,7 @@ static int transcode_init(OutputFile *output_files,
/* open files and write file headers */
for (i = 0; i < nb_output_files; i++) {
os = output_files[i].ctx;
+ os->interrupt_callback = int_cb;
if (avformat_write_header(os, &output_files[i].opts) < 0) {
snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i);
ret = AVERROR(EINVAL);
@@ -3010,7 +3013,7 @@ static void dump_attachment(AVStream *st, const char *filename)
assert_file_overwrite(filename);
- if ((ret = avio_open (&out, filename, AVIO_FLAG_WRITE)) < 0) {
+ if ((ret = avio_open2(&out, filename, AVIO_FLAG_WRITE, &int_cb, NULL)) < 0) {
av_log(NULL, AV_LOG_FATAL, "Could not open file %s for writing.\n",
filename);
exit_program(1);
@@ -3068,6 +3071,7 @@ static int opt_input_file(OptionsContext *o, const char *opt, const char *filena
av_dict_set(&format_opts, "pixel_format", o->frame_pix_fmts[o->nb_frame_pix_fmts - 1].u.str, 0);
ic->flags |= AVFMT_FLAG_NONBLOCK;
+ ic->interrupt_callback = int_cb;
/* open the input file with generic libav function */
err = avformat_open_input(&ic, filename, file_iformat, &format_opts);
@@ -3197,12 +3201,12 @@ static int get_preset_file_2(const char *preset_name, const char *codec_name, AV
if (codec_name) {
snprintf(filename, sizeof(filename), "%s%s/%s-%s.avpreset", base[i],
i != 1 ? "" : "/.avconv", codec_name, preset_name);
- ret = avio_open(s, filename, AVIO_FLAG_READ);
+ ret = avio_open2(s, filename, AVIO_FLAG_READ, &int_cb, NULL);
}
if (ret) {
snprintf(filename, sizeof(filename), "%s%s/%s.avpreset", base[i],
i != 1 ? "" : "/.avconv", preset_name);
- ret = avio_open(s, filename, AVIO_FLAG_READ);
+ ret = avio_open2(s, filename, AVIO_FLAG_READ, &int_cb, NULL);
}
}
return ret;
@@ -3588,8 +3592,9 @@ static int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata)
static int read_ffserver_streams(OptionsContext *o, AVFormatContext *s, const char *filename)
{
int i, err;
- AVFormatContext *ic = NULL;
+ AVFormatContext *ic = avformat_alloc_context();
+ ic->interrupt_callback = int_cb;
err = avformat_open_input(&ic, filename, NULL, NULL);
if (err < 0)
return err;
@@ -3638,6 +3643,7 @@ static void opt_output_file(void *optctx, const char *filename)
}
file_oformat= oc->oformat;
+ oc->interrupt_callback = int_cb;
if (!strcmp(file_oformat->name, "ffm") &&
av_strstart(filename, "http:", NULL)) {
@@ -3729,7 +3735,7 @@ static void opt_output_file(void *optctx, const char *filename)
const char *p;
int64_t len;
- if ((err = avio_open(&pb, o->attachments[i], AVIO_FLAG_READ)) < 0) {
+ if ((err = avio_open2(&pb, o->attachments[i], AVIO_FLAG_READ, &int_cb, NULL)) < 0) {
av_log(NULL, AV_LOG_FATAL, "Could not open attachment file %s.\n",
o->attachments[i]);
exit_program(1);
@@ -3779,7 +3785,9 @@ static void opt_output_file(void *optctx, const char *filename)
assert_file_overwrite(filename);
/* open the file */
- if ((err = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE)) < 0) {
+ if ((err = avio_open2(&oc->pb, filename, AVIO_FLAG_WRITE,
+ &oc->interrupt_callback,
+ &output_files[nb_output_files - 1].opts)) < 0) {
print_error(filename, err);
exit_program(1);
}
@@ -4350,12 +4358,6 @@ int main(int argc, char **argv)
av_register_all();
avformat_network_init();
-#if HAVE_ISATTY
- if(isatty(STDIN_FILENO))
- avio_set_interrupt_cb(decode_interrupt_cb);
-#endif
-
- show_banner();
/* parse options */
parse_options(&o, argc, argv, options, opt_output_file);