[FFmpeg-devel] [PATCH] ffplay: terminate program on EOF.

Jorge Ramirez-Ortiz jorge.ramirez-ortiz at linaro.org
Fri Jul 21 15:26:03 EEST 2017


ffplay always requires user intervention via the GUI to close the
video at the end of the file.

This commit, stops playing and terminates the program when EOF is
received.
---
 ffplay.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/ffplay.c b/ffplay.c
index c0b326c..12de7ba 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -593,7 +593,7 @@ static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) {
                 if (ret == AVERROR_EOF) {
                     d->finished = d->pkt_serial;
                     avcodec_flush_buffers(d->avctx);
-                    return 0;
+                    return -1;
                 }
                 if (ret >= 0)
                     return 1;
@@ -2088,8 +2088,13 @@ static int video_thread(void *arg)
 
     for (;;) {
         ret = get_video_frame(is, frame);
-        if (ret < 0)
-            goto the_end;
+        if (ret < 0) {
+                SDL_Event event;
+                event.type = FF_QUIT_EVENT;
+                event.user.data1 = is;
+                SDL_PushEvent(&event);
+                goto the_end;
+        }
         if (!ret)
             continue;
 
-- 
2.7.4



More information about the ffmpeg-devel mailing list