diff options
author | Philip Langdale <philipl@overt.org> | 2012-05-22 21:50:02 -0700 |
---|---|---|
committer | Philip Langdale <philipl@overt.org> | 2012-08-31 20:22:49 -0700 |
commit | 9d89c8b3ac80134f0bd32512eb208b113795ab9e (patch) | |
tree | 69d2f7f93e53afe2599209619c2fdb6acdbde653 /libavformat/srtenc.c | |
parent | 6a0dfe3b9dc6b9420b25bfd089c655583cf045d6 (diff) | |
download | ffmpeg-9d89c8b3ac80134f0bd32512eb208b113795ab9e.tar.gz |
matroskadec, matroskadec, srtenc: Read/Write duration for subtitles.
After much discussion and back-and-forth, we reached the conclusion
that matroska uses convergence_duration for subtitle duration because
a 32bit value isn't large enough to store the duration if sub-micro-second
timebases are used. Matroska may not be the only one that supports these
timebases, but it's certainly the only one that ffmpeg attempts to support
in this way.
The long term solution that we seemed to reach was that if we encounter
a matroska file with a sub-micro-second timebase, we should internally
scale it up to at least micro-second, and then duration can be used
normally. This suggests that on the encode side, we should not allow
generation of files with sub-micro-second timebases, but that's a separate
issue.
That being a non-trivial change, and the subtitle interoperability breakage
being very real, I'm re-submitting this small change for consideration.
In this diff, we make sure that duration is populated by the matroska
demuxer, and that convergence_duration is respected in matroskaenc and
srtenc, but that duration is used otherwise. This ends up being a strict
improvement - pipelines that use convergence duration are unchanged, and
ones that are currently broken due to the duration mismatch will start
working - except for the ones with the extreme timebases, but those were
already broken.
Signed-off-by: Philip Langdale <philipl@overt.org>
Diffstat (limited to 'libavformat/srtenc.c')
-rw-r--r-- | libavformat/srtenc.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/libavformat/srtenc.c b/libavformat/srtenc.c index 6b8278fa80..0b094b00bf 100644 --- a/libavformat/srtenc.c +++ b/libavformat/srtenc.c @@ -65,6 +65,7 @@ static int srt_write_packet(AVFormatContext *avf, AVPacket *pkt) int len; if (d <= 0) + /* For backward compatibility, fallback to convergence_duration. */ d = pkt->convergence_duration; if (s == AV_NOPTS_VALUE || d <= 0) { av_log(avf, AV_LOG_ERROR, "Insufficient timestamps.\n"); |