summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorRudolf Polzer <divverent@xonotic.org>2013-06-09 15:37:28 +0200
committerRudolf Polzer <divverent@xonotic.org>2013-06-09 15:37:28 +0200
commit0cbc75c0834a4ba93b67a79467b80324b06165f4 (patch)
tree74ad6b13f0b921a3fcec74743ee740952c3600df /video
parent4af59abbb416a365a98efca8875c0f0c1b0c872f (diff)
downloadmpv-0cbc75c0834a4ba93b67a79467b80324b06165f4.tar.bz2
mpv-0cbc75c0834a4ba93b67a79467b80324b06165f4.tar.xz
Option -omaxfps: limit fps when encoding
Lower-fps content is left alone (NOT aligned to this fps); higher fps content is decimated to this frame rate.
Diffstat (limited to 'video')
-rw-r--r--video/out/vo_lavc.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/video/out/vo_lavc.c b/video/out/vo_lavc.c
index 5140720f92..840103c0c2 100644
--- a/video/out/vo_lavc.c
+++ b/video/out/vo_lavc.c
@@ -48,6 +48,7 @@ struct priv {
double lastpts;
int64_t lastipts;
int64_t lastframeipts;
+ int64_t mindeltapts;
double expected_next_pts;
mp_image_t *lastimg;
int lastimg_wants_osd;
@@ -317,6 +318,11 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
vc->worst_time_base = vc->stream->time_base;
vc->worst_time_base_is_stream = 1;
}
+ if (ectx->options->maxfps)
+ vc->mindeltapts = ceil(vc->worst_time_base.den /
+ (vc->worst_time_base.num * ectx->options->maxfps));
+ else
+ vc->mindeltapts = 0;
// NOTE: we use the following "axiom" of av_rescale_q:
// if time base A is worse than time base B, then
@@ -394,6 +400,16 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
vc->lastpts = frameipts * timeunit - encode_lavc_getoffset(ectx, vc->stream);
}
+ // lastipts: pts of last vo frame
+ // frameipts: pts of current vo frame
+ // lastframeipts: pts of last ENCODED frame
+ // now we want to go forward in time until at least lastframeipts + mindeltapts
+ // so let's just assume this frame took place at this time or later
+ if (frameipts >= vc->lastframeipts && frameipts < vc->lastframeipts + vc->mindeltapts) {
+ frameipts = vc->lastframeipts + vc->mindeltapts;
+ vc->lastpts = frameipts * timeunit - encode_lavc_getoffset(ectx, vc->stream);
+ }
+
if (vc->lastipts != MP_NOPTS_VALUE) {
frame = avcodec_alloc_frame();