[FFmpeg-cvslog] ffplay: ensure that we buffer at least 1 second of content
Marton Balint
git at videolan.org
Mon Jun 20 00:00:00 CEST 2016
ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Sat Jun 11 12:11:11 2016 +0200| [e32857f30eed011e6c49d578418692f54d8e9a5d] | committer: Marton Balint
ffplay: ensure that we buffer at least 1 second of content
In order to do that, we keep track of the total duration of packets in a packet
queue.
Signed-off-by: Marton Balint <cus at passwd.hu>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e32857f30eed011e6c49d578418692f54d8e9a5d
---
ffplay.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/ffplay.c b/ffplay.c
index 9f5b2a4..d32b023 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -117,6 +117,7 @@ typedef struct PacketQueue {
MyAVPacketList *first_pkt, *last_pkt;
int nb_packets;
int size;
+ int64_t duration;
int abort_request;
int serial;
SDL_mutex *mutex;
@@ -417,6 +418,7 @@ static int packet_queue_put_private(PacketQueue *q, AVPacket *pkt)
q->last_pkt = pkt1;
q->nb_packets++;
q->size += pkt1->pkt.size + sizeof(*pkt1);
+ q->duration += pkt1->pkt.duration;
/* XXX: should duplicate packet data in DV case */
SDL_CondSignal(q->cond);
return 0;
@@ -478,6 +480,7 @@ static void packet_queue_flush(PacketQueue *q)
q->first_pkt = NULL;
q->nb_packets = 0;
q->size = 0;
+ q->duration = 0;
SDL_UnlockMutex(q->mutex);
}
@@ -528,6 +531,7 @@ static int packet_queue_get(PacketQueue *q, AVPacket *pkt, int block, int *seria
q->last_pkt = NULL;
q->nb_packets--;
q->size -= pkt1->pkt.size + sizeof(*pkt1);
+ q->duration -= pkt1->pkt.duration;
*pkt = pkt1->pkt;
if (serial)
*serial = pkt1->serial;
@@ -2800,7 +2804,7 @@ static int stream_has_enough_packets(AVStream *st, int stream_id, PacketQueue *q
return stream_id < 0 ||
queue->abort_request ||
(st->disposition & AV_DISPOSITION_ATTACHED_PIC) ||
- queue->nb_packets > MIN_FRAMES;
+ queue->nb_packets > MIN_FRAMES && (!queue->duration || av_q2d(st->time_base) * queue->duration > 1.0);
}
static int is_realtime(AVFormatContext *s)
More information about the ffmpeg-cvslog
mailing list