summaryrefslogtreecommitdiff
path: root/avconv.c
diff options
context:
space:
mode:
Diffstat (limited to 'avconv.c')
-rw-r--r--avconv.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/avconv.c b/avconv.c
index 64017602cb..4e19813312 100644
--- a/avconv.c
+++ b/avconv.c
@@ -147,6 +147,7 @@ static void avconv_cleanup(int ret)
FilterGraph *fg = filtergraphs[i];
avfilter_graph_free(&fg->graph);
for (j = 0; j < fg->nb_inputs; j++) {
+ av_buffer_unref(&fg->inputs[j]->hw_frames_ctx);
av_freep(&fg->inputs[j]->name);
av_freep(&fg->inputs[j]);
}
@@ -1252,6 +1253,16 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
ist->resample_channel_layout = decoded_frame->channel_layout;
ist->resample_channels = avctx->channels;
+ for (i = 0; i < ist->nb_filters; i++) {
+ err = ifilter_parameters_from_frame(ist->filters[i], decoded_frame);
+ if (err < 0) {
+ av_log(NULL, AV_LOG_ERROR,
+ "Error reconfiguring input stream %d:%d filter %d\n",
+ ist->file_index, ist->st->index, i);
+ goto fail;
+ }
+ }
+
for (i = 0; i < nb_filtergraphs; i++)
if (ist_in_filtergraph(filtergraphs[i], ist) &&
configure_filtergraph(filtergraphs[i]) < 0) {
@@ -1279,6 +1290,7 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
break;
}
+fail:
av_frame_unref(ist->filter_frame);
av_frame_unref(decoded_frame);
return err < 0 ? err : ret;
@@ -1336,6 +1348,16 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output)
ist->resample_height = decoded_frame->height;
ist->resample_pix_fmt = decoded_frame->format;
+ for (i = 0; i < ist->nb_filters; i++) {
+ err = ifilter_parameters_from_frame(ist->filters[i], decoded_frame);
+ if (err < 0) {
+ av_log(NULL, AV_LOG_ERROR,
+ "Error reconfiguring input stream %d:%d filter %d\n",
+ ist->file_index, ist->st->index, i);
+ goto fail;
+ }
+ }
+
for (i = 0; i < nb_filtergraphs; i++)
if (ist_in_filtergraph(filtergraphs[i], ist) &&
configure_filtergraph(filtergraphs[i]) < 0) {
@@ -2061,6 +2083,14 @@ static int transcode_init(void)
enc_ctx->codec_type == AVMEDIA_TYPE_AUDIO) &&
filtergraph_is_simple(ost->filter->graph)) {
FilterGraph *fg = ost->filter->graph;
+
+ ret = ifilter_parameters_from_decoder(fg->inputs[0],
+ dec_ctx);
+ if (ret < 0) {
+ av_log(NULL, AV_LOG_FATAL, "Error initializing filter input\n");
+ exit_program(1);
+ }
+
if (configure_filtergraph(fg)) {
av_log(NULL, AV_LOG_FATAL, "Error opening filters!\n");
exit_program(1);