diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-01-14 04:33:12 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-01-17 23:47:38 +0100 |
commit | 706741e8d79710943aafcd6d6049c0c548b08937 (patch) | |
tree | 3022823b84343f6781ad5ed50b78244b90710892 /ffmpeg.c | |
parent | 4ff77d44512100b8b1258b98491776755f45d30b (diff) | |
download | ffmpeg-706741e8d79710943aafcd6d6049c0c548b08937.tar.gz |
ffmpeg: properly close down muxers on av_interleaved_write_frame() failure
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'ffmpeg.c')
-rw-r--r-- | ffmpeg.c | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -313,6 +313,7 @@ void term_exit(void) static volatile int received_sigterm = 0; static volatile int received_nb_signals = 0; +static int main_return_code = 0; static void sigterm_handler(int sig) @@ -547,6 +548,15 @@ static void update_benchmark(const char *fmt, ...) } } +static void close_all_output_streams(OutputStream *ost, int this_stream, int others) +{ + int i; + for (i = 0; i < nb_output_streams; i++) { + OutputStream *ost2 = output_streams[i]; + ost2->finished |= ost == ost2 ? this_stream : others; + } +} + static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) { AVBitStreamFilterContext *bsfc = ost->bitstream_filters; @@ -647,7 +657,8 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) ret = av_interleaved_write_frame(s, pkt); if (ret < 0) { print_error("av_interleaved_write_frame()", ret); - exit_program(1); + main_return_code = 1; + close_all_output_streams(ost, 3, 1); } } @@ -655,7 +666,7 @@ static void close_output_stream(OutputStream *ost) { OutputFile *of = output_files[ost->file_index]; - ost->finished = 1; + ost->finished |= 1; if (of->shortest) { int64_t end = av_rescale_q(ost->sync_opts - ost->first_pts, ost->st->codec->time_base, AV_TIME_BASE_Q); of->recording_time = FFMIN(of->recording_time, end); @@ -3568,6 +3579,6 @@ int main(int argc, char **argv) if ((decode_error_stat[0] + decode_error_stat[1]) * max_error_rate < decode_error_stat[1]) exit_program(69); - exit_program(received_nb_signals ? 255 : 0); - return 0; + exit_program(received_nb_signals ? 255 : main_return_code); + return main_return_code; } |