[FFmpeg-devel] [PATCH]lavf/matroskaenc: Do not write 0 duration for subtitles

John Stebbins stebbins at jetheaddev.com
Thu Nov 23 21:02:52 EET 2017


On 11/23/2017 03:04 AM, Jerome Martinez wrote:
> On 12/11/2017 03:12, Carl Eugen Hoyos wrote:
>> The matroska spec says blockduration == 0 means the frame is not a
>> keyframe.  Since all subtitles are "keyframes", 0 blockduration should
>> not be written.
> As I understand from discussion on CELLAR mailing-list:
> - if is not expected to have a frame with block duration of 0, in a 
> perfect world the previous frame should have the right duration and the 
> player should hide the previous frame after blockduration of the 
> previous frame.
> - as a workaround, it would make sense to put an empty frame with 
> "unlimited" duration, so no blockduration, as implemented in the patch.
>
> The only issue is in the case someone puts a "not empty" frame with a 
> duration of 0, this patch would change the behavior (from nothing 
> displayed to the frame displayed) but as it is not expected to have a 
> duration of 0 when something is displayed, this is not a real use case IMO.
>
> Suggestion of changes for this patch:
> - Remove the outdated part about specs. A duration of 0 is not coherent, 
> that's all.
> - Add a comment (in the code?) stipulating that duration of 0 is a 
> special case which means "up to the next frame".
>
>

The use case this patch was created for is PGS subtitles that use an "empty" PGS subtitle to mark the end of the
previous subtitle.  An "empty" PGS subtitle is not a packet of 0 length.  It is a PGS subtitle that has zero composition
objects.  So a non-empty frame of 0 duration gets written to mark the end of the previous PGS.   It's not practical to
know the duration of the previous subtitle before writing it because you can't know it till you have seen this empty
PGS.  Once you've seen the empty PGS, it is often too late to properly interleave the previous PGS in the output file.

Your suggestion (0 means up to next frame) however works I believe.  I.e. display the "empty" PGS up to the next frame.

-- 
John      GnuPG fingerprint: D0EC B3DB C372 D1F1 0B01  83F0 49F1 D7B2 60D4 D0F7


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20171123/9e11136d/attachment.sig>


More information about the ffmpeg-devel mailing list