summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormplayer-svn <svn@mplayerhq.hu>2012-04-15 15:09:34 +0000
committerwm4 <wm4@nowhere>2012-08-03 02:53:21 +0200
commit2d513fac330d7b8b02f053fce5d68a4c422b75f6 (patch)
tree5c8ab62b43da618360d7a7924c5a73fbb04492c8
parent62df332dd5571b27f839a2280aee48268142394f (diff)
downloadmpv-2d513fac330d7b8b02f053fce5d68a4c422b75f6.tar.bz2
mpv-2d513fac330d7b8b02f053fce5d68a4c422b75f6.tar.xz
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
-rw-r--r--libvo/vo_yuv4mpeg.c8
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;