static int init_output_stream(OutputStream *ost, char *error, int error_len);
+static int init_output_stream_wrapper(OutputStream *ost, unsigned int fatal)
+{
+ int ret = AVERROR_BUG;
+ char error[1024] = {0};
+
+ if (ost->initialized)
+ return 0;
+
+ ret = init_output_stream(ost, error, sizeof(error));
+ if (ret < 0) {
+ av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- %s\n",
+ ost->file_index, ost->index, error);
+
+ if (fatal)
+ exit_program(1);
+ }
+
+ return ret;
+}
+
static void finish_output_stream(OutputStream *ost)
{
OutputFile *of = output_files[ost->file_index];
continue;
filter = ost->filter->filter;
- if (!ost->initialized) {
- char error[1024] = "";
- ret = init_output_stream(ost, error, sizeof(error));
- if (ret < 0) {
- av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- %s\n",
- ost->file_index, ost->index, error);
- exit_program(1);
- }
- }
+ init_output_stream_wrapper(ost, 1);
if (!ost->filtered_frame && !(ost->filtered_frame = av_frame_alloc())) {
return AVERROR(ENOMEM);
// Maybe we should just let encoding fail instead.
if (!ost->initialized) {
FilterGraph *fg = ost->filter->graph;
- char error[1024] = "";
av_log(NULL, AV_LOG_WARNING,
"Finishing stream %d:%d without any data written to it.\n",
finish_output_stream(ost);
}
- ret = init_output_stream(ost, error, sizeof(error));
- if (ret < 0) {
- av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- %s\n",
- ost->file_index, ost->index, error);
- exit_program(1);
- }
+ init_output_stream_wrapper(ost, 1);
}
if (enc->codec_type != AVMEDIA_TYPE_VIDEO && enc->codec_type != AVMEDIA_TYPE_AUDIO)
if (output_streams[i]->filter)
continue;
- ret = init_output_stream(output_streams[i], error, sizeof(error));
+ ret = init_output_stream_wrapper(output_streams[i], 0);
if (ret < 0)
goto dump_format;
}
}
if (ost->filter && ost->filter->graph->graph) {
- if (!ost->initialized) {
- char error[1024] = {0};
- ret = init_output_stream(ost, error, sizeof(error));
- if (ret < 0) {
- av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- %s\n",
- ost->file_index, ost->index, error);
- exit_program(1);
- }
- }
+ init_output_stream_wrapper(ost, 1);
+
if ((ret = transcode_from_filter(ost->filter->graph, &ist)) < 0)
return ret;
if (!ist)