GNOME Bugzilla – Bug 706885
videoencoder: Fix forwarding of GstForceKeyUnit events
Last modified: 2013-08-27 13:11:52 UTC
Created attachment 253242 [details] [review] 0001-videoencoder-fix-forwarding-of-GstForceKeyUnit-event.patch The algorithm to match the output sync frame with a GstForceKeyUnit event should be using the frame_id instead of trying to match using times. With the current code the output is as follows: gst_video_encoder_chain:<x264enc0> Forcing a key unit at running time 0:00:00.083333333 gst_video_encoder_chain:<x264enc0> Forcing a key unit at running time 0:00:02.041666666 gst_video_encoder_finish_frame:<x264enc0> Forced key unit: running-time 0:00:00.000000000, all_headers 0, count 0 gst_video_encoder_chain:<x264enc0> Forcing a key unit at running time 0:00:04.000000000 gst_video_encoder_chain:<x264enc0> Forcing a key unit at running time 0:00:06.000000000 gst_video_encoder_finish_frame:<x264enc0> Forced key unit: running-time 0:00:04.000000000, all_headers 0, count 1 gst_video_encoder_finish_frame:<x264enc0> Forced key unit: running-time 0:00:05.125000000, all_headers 0, count 2 gst_video_encoder_chain:<x264enc0> Forcing a key unit at running time 0:00:08.000000000 gst_video_encoder_finish_frame:<x264enc0> Forced key unit: running-time 0:00:06.000000000, all_headers 0, count 3 gst_video_encoder_finish_frame:<x264enc0> Forced key unit: running-time 0:00:08.000000000, all_headers 0, count 4 gst_video_encoder_chain:<x264enc0> Forcing a key unit at running time 0:00:10.166666666 gst_video_encoder_chain:<x264enc0> Forcing a key unit at running time 0:00:12.000000000 gst_video_encoder_finish_frame:<x264enc0> Forced key unit: running-time 0:00:10.166666666, all_headers 0, count 5 gst_video_encoder_chain:<x264enc0> Forcing a key unit at running time 0:00:14.000000000 gst_video_encoder_finish_frame:<x264enc0> Forced key unit: running-time 0:00:12.000000000, all_headers 0, count 6 gst_video_encoder_finish_frame:<x264enc0> Forced key unit: running-time 0:00:14.000000000, all_headers 0, count 7 gst_video_encoder_chain:<x264enc0> Forcing a key unit at running time 0:00:16.166666666 The problem comes with the second force keyframe, which has a running-time lower than 0:00:02.000000000, so the event for 0:00:04.000000000 is pushed instead. Next come a non-forced keyframe at 0:00:05.125000000 which is pushed because its running-time is bigger than 0:00:02.000000000. Using the frame id to match the keyframe with the event get: gst_video_encoder_chain:<x264enc0> Forcing a key unit at running time 0:00:00.083333333 gst_video_encoder_chain:<x264enc0> Forcing a key unit at running time 0:00:02.041666666 gst_video_encoder_finish_frame:<x264enc0> Forced key unit: running-time 0:00:00.000000000, all_headers 0, count 0 gst_video_encoder_chain:<x264enc0> Forcing a key unit at running time 0:00:04.000000000 gst_video_encoder_finish_frame:<x264enc0> Forced key unit: running-time 0:00:01.958333333, all_headers 0, count 1 gst_video_encoder_chain:<x264enc0> Forcing a key unit at running time 0:00:06.000000000 gst_video_encoder_finish_frame:<x264enc0> Forced key unit: running-time 0:00:04.000000000, all_headers 0, count 2 gst_video_encoder_chain:<x264enc0> Forcing a key unit at running time 0:00:08.000000000 gst_video_encoder_finish_frame:<x264enc0> Forced key unit: running-time 0:00:06.000000000, all_headers 0, count 3 gst_video_encoder_chain:<x264enc0> Forcing a key unit at running time 0:00:10.000000000 gst_video_encoder_finish_frame:<x264enc0> Forced key unit: running-time 0:00:08.000000000, all_headers 0, count 4
commit 688505de8843db95b3bdeff4d7c09bb4755f53a2 Author: Andoni Morales Alastruey <ylatuya@gmail.com> Date: Tue Aug 27 15:03:54 2013 +0200 videoencoder: fix forwarding of GstForceKeyUnit events Use the frame id to match the output forced keyframe with the event that forced it. https://bugzilla.gnome.org/show_bug.cgi?id=706885