mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
assrender: For synchronizing the text, take the video running time of the next frame
This makes sure that libass already has all text buffers for the next frame at the time when the next frame is processed. Without this text buffers might be one frame late or not shown at all if they're only shown for a single frame.
This commit is contained in:
parent
77d0ded9ed
commit
d7e58ce0a9
2 changed files with 7 additions and 1 deletions
|
@ -651,7 +651,8 @@ gst_ass_render_setcaps_video (GstPad * pad, GstCaps * caps)
|
||||||
render->height = 0;
|
render->height = 0;
|
||||||
|
|
||||||
if (!gst_video_format_parse_caps (caps, &render->format, &render->width,
|
if (!gst_video_format_parse_caps (caps, &render->format, &render->width,
|
||||||
&render->height)) {
|
&render->height) ||
|
||||||
|
!gst_video_parse_caps_framerate (caps, &render->fps_n, &render->fps_d)) {
|
||||||
GST_ERROR_OBJECT (render, "Can't parse caps: %" GST_PTR_FORMAT, caps);
|
GST_ERROR_OBJECT (render, "Can't parse caps: %" GST_PTR_FORMAT, caps);
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -963,6 +964,10 @@ gst_ass_render_chain_text (GstPad * pad, GstBuffer * buffer)
|
||||||
gst_segment_to_running_time (&render->video_segment, GST_FORMAT_TIME,
|
gst_segment_to_running_time (&render->video_segment, GST_FORMAT_TIME,
|
||||||
render->video_segment.last_stop);
|
render->video_segment.last_stop);
|
||||||
|
|
||||||
|
if (render->fps_n && render->fps_d)
|
||||||
|
vid_running_time +=
|
||||||
|
gst_util_uint64_scale (GST_SECOND, render->fps_d, render->fps_n);
|
||||||
|
|
||||||
if (sub_running_time > vid_running_time) {
|
if (sub_running_time > vid_running_time) {
|
||||||
g_assert (render->subtitle_pending == NULL);
|
g_assert (render->subtitle_pending == NULL);
|
||||||
g_mutex_lock (render->subtitle_mutex);
|
g_mutex_lock (render->subtitle_mutex);
|
||||||
|
|
|
@ -55,6 +55,7 @@ struct _GstAssRender
|
||||||
|
|
||||||
GstVideoFormat format;
|
GstVideoFormat format;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
|
gint fps_n, fps_d;
|
||||||
GstAssRenderBlitFunction blit;
|
GstAssRenderBlitFunction blit;
|
||||||
|
|
||||||
GMutex *subtitle_mutex;
|
GMutex *subtitle_mutex;
|
||||||
|
|
Loading…
Reference in a new issue