diff options
-rw-r--r-- | libvo/vo_yuv4mpeg.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libvo/vo_yuv4mpeg.c b/libvo/vo_yuv4mpeg.c index 67013eaa90..a7b5dd05c1 100644 --- a/libvo/vo_yuv4mpeg.c +++ b/libvo/vo_yuv4mpeg.c @@ -104,7 +104,6 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, "Video formats differ (w:%i=>%i, h:%i=>%i, fps:%f=>%f), " "restarting output.\n", image_width, width, image_height, height, image_fps, vo_fps); - uninit(); } image_height = height; image_width = width; @@ -129,9 +128,11 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, } write_bytes = image_width * image_height * 3 / 2; + free(image); image = malloc(write_bytes); - yuv_out = fopen(yuv_filename, "wb"); + if (!yuv_out) + yuv_out = strcmp(yuv_filename, "-") ? fopen(yuv_filename, "wb") : stdout; if (!yuv_out || image == 0) { mp_tmsg(MSGT_VO,MSGL_FATAL, @@ -168,6 +169,7 @@ static void vo_y4m_write(const void *ptr, const size_t num_bytes) if (fwrite(ptr, 1, num_bytes, yuv_out) != num_bytes) mp_tmsg(MSGT_VO,MSGL_ERR, "Error writing image to output!"); + fflush(yuv_out); } static int write_last_frame(void) @@ -237,7 +239,7 @@ static void uninit(void) free(image); image = NULL; - if(yuv_out) + if(yuv_out && yuv_out != stdout) fclose(yuv_out); yuv_out = NULL; |