From 2d513fac330d7b8b02f053fce5d68a4c422b75f6 Mon Sep 17 00:00:00 2001 From: mplayer-svn Date: Sun, 15 Apr 2012 15:09:34 +0000 Subject: vo_yuv4mpeg: support writing to stdout yuv4mpeg: support writing to stdout instead of file. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34861 b3059339-0415-0410-9bf9-f77b7e298cf2 Allow using -vo yuv4mpeg for files with resolution changes. Not all programs can read such files. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34862 b3059339-0415-0410-9bf9-f77b7e298cf2 vo_yuv4mpeg: flush userspace FILE buffers after each frame. Potentially reduces delay when piping to stdout/fifo. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34879 b3059339-0415-0410-9bf9-f77b7e298cf2 Author: reimar --- libvo/vo_yuv4mpeg.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libvo') 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; -- cgit v1.2.3