Hi,

this is the patch for http://f265.org/bugs/ticket/5

Laurent
diff --git a/cli/cli.c b/cli/cli.c
index ec01f81..34cfc5a 100644
--- a/cli/cli.c
+++ b/cli/cli.c
@@ -413,23 +413,33 @@ int read_yuv_frame(video_data *v)
 /* Open a YUV video file. */
 void open_yuv_file(video_data *v, input_file_data *ifd)
 {
-    FILE *f = fopen(ifd->path, "rb");
-    if (!f)
+    /* Use standard input. */
+    if (!strcmp(ifd->path, "-"))
     {
-        printf("Cannot open %s: %s.\n", ifd->path, strerror(errno));
-        video_data_clear(v);
-        exit(1);
+        ifd->file_handle = stdin;
     }
-    ifd->file_handle = f;
 
-    fseek(f, 0, SEEK_END);
-    ifd->file_size = ftell(f);
-    fseek(f, 0, SEEK_SET);
+    /* Open the specified file. */
+    else
+    {
+        FILE *f = fopen(ifd->path, "rb");
+        if (!f)
+        {
+            printf("Cannot open %s: %s.\n", ifd->path, strerror(errno));
+            video_data_clear(v);
+            exit(1);
+        }
+        ifd->file_handle = f;
+
+        fseek(f, 0, SEEK_END);
+        ifd->file_size = ftell(f);
+        fseek(f, 0, SEEK_SET);
 
-    ifd->frame_count = ifd->file_size / (v->width[0] * v->height[0] * 3 / 2);
+        ifd->frame_count = ifd->file_size / (v->width[0] * v->height[0] * 3 / 2);
 
-    if (!v->nb_frame_to_encode)
-        v->nb_frame_to_encode = ifd->frame_count;
+        if (!v->nb_frame_to_encode)
+            v->nb_frame_to_encode = ifd->frame_count;
+    }
 }
 
 #ifndef F265_NO_LIBAV
diff --git a/doc/params.txt b/doc/params.txt
index 57fc9bb..ea08232 100644
--- a/doc/params.txt
+++ b/doc/params.txt
@@ -19,7 +19,8 @@ do not insert spaces between the parameter names and their values. The value
 of strings.
 
 INPUT is the path to an input 4:2:0 YUV file with the extension '.yuv', or a
-file decodable by ffmpeg.
+file decodable by ffmpeg. If '-' is specified instead of a path, the standard
+input is read as a YUV file.
 
 OUTPUT is the path to the output bitstream.
 

Reply via email to