[MPlayer-dev-eng] [PATCH] -ass in mencoder - pts issue
Rudolf Polzer
divVerent at alientrap.org
Sat May 1 14:55:11 CEST 2010
Hi,
currently, -ass in mencoder only works in conjunction with the "fixpts" video
filter, which is only usable for fixed frame rate input.
However, as I am dealing with variable frame rate input, I needed a way to pass
through the correct pts values to the "ass" filter.
One solution for that is the "-keep-pts" option by the original author of the
mencoder ass-support patch. However, that part of his patchset was not
committed to mencoder svn, which probably had to do with the problem that it
does not play well with e.g. frame rate changing or files with damaged pts info
(as described in the help message).
Therefore, I instead tried an alternative solution (patch included) - the ass
filter now will, if no pts is received (i.e. if fixpts is not used and in
mencoder), just use the timer. The handling is equivalent to the vo_pts
handling for video output. In my patch I used a separate vf_pts variable for
this purpose, but I probably would suggest merging these into one.
I am currently encoding a bunch of videos using it, and it seems to work fine,
by the way.
Best regards,
Rudolf Polzer
Index: libmpcodecs/vf_ass.c
===================================================================
--- libmpcodecs/vf_ass.c (revision 31109)
+++ libmpcodecs/vf_ass.c (working copy)
@@ -332,6 +332,10 @@
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
{
ass_image_t* images = 0;
+
+ if(pts == MP_NOPTS_VALUE)
+ pts = vf_pts / 90000.0;
+
if (sub_visibility && vf->priv->ass_priv && ass_track && (pts != MP_NOPTS_VALUE))
images = ass_mp_render_frame(vf->priv->ass_priv, ass_track, (pts+sub_delay) * 1000 + .5, NULL);
Index: libmpcodecs/vf.c
===================================================================
--- libmpcodecs/vf.c (revision 31109)
+++ libmpcodecs/vf.c (working copy)
@@ -217,6 +217,8 @@
NULL
};
+double vf_pts;
+
// For the vf option
m_obj_settings_t* vf_settings = NULL;
const m_obj_list_t vf_obj_list = {
Index: libmpcodecs/vf.h
===================================================================
--- libmpcodecs/vf.h (revision 31109)
+++ libmpcodecs/vf.h (working copy)
@@ -21,6 +21,8 @@
#include "mp_image.h"
+extern double vf_pts;
+
struct vf_instance;
struct vf_priv_s;
Index: mplayer.c
===================================================================
--- mplayer.c (revision 31109)
+++ mplayer.c (working copy)
@@ -3780,7 +3780,7 @@
/*========================== PLAY VIDEO ============================*/
- vo_pts=mpctx->sh_video->timer*90000.0;
+ vf_pts=vo_pts=mpctx->sh_video->timer*90000.0;
vo_fps=mpctx->sh_video->fps;
if (!mpctx->num_buffered_frames) {
Index: mencoder.c
===================================================================
--- mencoder.c (revision 31109)
+++ mencoder.c (working copy)
@@ -472,6 +472,8 @@
}
if (sh_video->pts >= end_pts) done = 1;
+ vf_pts=sh_video->timer*90000.0; // TODO rather use sh_video->pts?
+
if (vfilter) {
int softskip = (vfilter->control(vfilter, VFCTRL_SKIP_NEXT_FRAME, 0) == CONTROL_TRUE);
void *decoded_frame = decode_video(sh_video, frame_data->start, frame_data->in_size, !softskip, MP_NOPTS_VALUE);
@@ -1534,6 +1536,9 @@
if(skip_flag<=0) muxer_write_chunk(mux_v,sizeof(int),AVIIF_KEYFRAME, MP_NOPTS_VALUE, MP_NOPTS_VALUE);
break;
default:
+
+ vf_pts=sh_video->timer*90000.0; // TODO rather use sh_video->pts?
+
// decode_video will callback down to ve_*.c encoders, through the video filters
{void *decoded_frame = decode_video(sh_video,frame_data.start,frame_data.in_size,
skip_flag>0 && (!sh_video->vfilter || ((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter, VFCTRL_SKIP_NEXT_FRAME, 0) != CONTROL_TRUE), MP_NOPTS_VALUE);
More information about the MPlayer-dev-eng
mailing list