summaryrefslogtreecommitdiff
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorClément Bœsch <ubitux@gmail.com>2012-08-01 18:39:46 +0200
committerClément Bœsch <ubitux@gmail.com>2012-08-01 20:37:34 +0200
commit53a3748ed23136615e488dc463b91aa57c0e9ec6 (patch)
tree2da95a1755f6090209b3b21da4797d5531efd713 /ffmpeg.c
parentc99d3e2e6c370e366a32b1c0caa2b9dfc8ad5bd1 (diff)
ffmpeg: honor -ss and -t parameters with muxed subtitles.
This patch fixes two things: - in case of subtitles, check_recording_time() is comparing the current PTS to the recording time (-t option, set to INT_MAX by default), so the -ss option needs to be taken into account. It is not required in do_{audio,video}_out() because this adjustment is set while polling the filtergraph (see poll_filters()). - It also adjusts the PTS sent to the encoder (and later transmitted to the muxer) so the TS in the output make sense and are not kept verbatim. Note: this only works for muxers honoring the PTS, such as lavf/matroskaenc. But for other such as the ASS muxer which just does a verbatim copy, or the SubRip muxer which doesn't write the TS in some cases, it will not work yet.
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index f85d8e01a8..cc1b32fc79 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1683,12 +1683,15 @@ static void do_subtitle_out(AVFormatContext *s,
else
nb = 1;
+ /* shift timestamp to honor -ss and make check_recording_time() work with -t */
+ pts = av_rescale_q(pts, ist->st->time_base, AV_TIME_BASE_Q)
+ - output_files[ost->file_index]->start_time;
for (i = 0; i < nb; i++) {
- ost->sync_opts = av_rescale_q(pts, ist->st->time_base, enc->time_base);
+ ost->sync_opts = av_rescale_q(pts, AV_TIME_BASE_Q, enc->time_base);
if (!check_recording_time(ost))
return;
- sub->pts = av_rescale_q(pts, ist->st->time_base, AV_TIME_BASE_Q);
+ sub->pts = pts;
// start_display_time is required to be 0
sub->pts += av_rescale_q(sub->start_display_time, (AVRational){ 1, 1000 }, AV_TIME_BASE_Q);
sub->end_display_time -= sub->start_display_time;