On Sun, 7 Sep 2014, Michael Niedermayer wrote:
Signed-off-by: Michael Niedermayer <michae...@gmx.at>
---
ffplay.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/ffplay.c b/ffplay.c
index 06bccce..64ec058 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -185,6 +185,7 @@ typedef struct VideoState {
int realtime;
int audio_finished;
int video_finished;
+ int video_frames;
Clock audclk;
Clock vidclk;
@@ -311,7 +312,7 @@ static int fast = 0;
static int genpts = 0;
static int lowres = 0;
static int decoder_reorder_pts = -1;
-static int autoexit = 1;
+static int autoexit = -1;
static int exit_on_keydown;
static int exit_on_mousedown;
static int loop = 1;
@@ -1701,6 +1702,8 @@ static int get_video_frame(VideoState *is, AVFrame
*frame, AVPacket *pkt, int *s
int ret = 1;
double dpts = NAN;
+ is->video_frames ++;
+
if (decoder_reorder_pts == -1) {
frame->pts = av_frame_get_best_effort_timestamp(frame);
} else if (decoder_reorder_pts) {
@@ -2995,7 +2998,7 @@ static int read_thread(void *arg)
(!is->video_st || (is->video_finished == is->videoq.serial &&
pictq_nb_remaining(is) == 0))) {
if (loop != 1 && (!loop || --loop)) {
stream_seek(is, start_time != AV_NOPTS_VALUE ? start_time : 0,
0, 0);
- } else if (autoexit) {
+ } else if (autoexit == 1 || (autoexit == -1 && is->video_frames !=
1)) {
ret = AVERROR_EOF;
goto fail;
}
--
1.7.9.5
You should reset video_frames in get_video_frame on flush packet.
Other thing came to mind is that unless I am mistaken audio streams with
an attachment picture will also keep ffplay running with this patch even
after the end of the audio. Probably that is not what the user would
expect, so maybe you should add an additional check to only keep
ffplay running if there is no audio stream.
Regards,
Marton
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel