aboutsummaryrefslogtreecommitdiffstats
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorNicolas George <nicolas.george@normalesup.org>2012-08-09 11:44:17 +0200
committerNicolas George <nicolas.george@normalesup.org>2012-08-14 11:17:45 +0200
commit0cad101ea10d01cb9f4780ebd915fb16dad19997 (patch)
tree7a4f655f210ebbded5acaa703163d4b108bf804c /ffmpeg.c
parent1bfa349a8d706424b5f2f379c439c11be21f4316 (diff)
downloadandroid_external_ffmpeg-0cad101ea10d01cb9f4780ebd915fb16dad19997.tar.gz
android_external_ffmpeg-0cad101ea10d01cb9f4780ebd915fb16dad19997.tar.bz2
android_external_ffmpeg-0cad101ea10d01cb9f4780ebd915fb16dad19997.zip
ffmpeg: add an option to fix subtitles durations.
With this option, transcoding DVB subtitles becomes possible.
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 411cad1c45..5aeaba217a 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1649,6 +1649,7 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output)
static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output)
{
AVSubtitle subtitle;
+ int64_t pts = pkt->pts;
int i, ret = avcodec_decode_subtitle2(ist->st->codec,
&subtitle, got_output, pkt);
if (ret < 0 || !*got_output) {
@@ -1657,6 +1658,26 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output)
return ret;
}
+ if (ist->fix_sub_duration) {
+ if (ist->prev_sub.got_output) {
+ int end = av_rescale_q(pts - ist->prev_sub.pts, ist->st->time_base,
+ (AVRational){ 1, 1000 });
+ if (end < ist->prev_sub.subtitle.end_display_time) {
+ av_log(ist->st->codec, AV_LOG_DEBUG,
+ "Subtitle duration reduced from %d to %d\n",
+ ist->prev_sub.subtitle.end_display_time, end);
+ ist->prev_sub.subtitle.end_display_time = end;
+ }
+ }
+ FFSWAP(int64_t, pts, ist->prev_sub.pts);
+ FFSWAP(int, *got_output, ist->prev_sub.got_output);
+ FFSWAP(int, ret, ist->prev_sub.ret);
+ FFSWAP(AVSubtitle, subtitle, ist->prev_sub.subtitle);
+ }
+
+ if (!*got_output || !subtitle.num_rects)
+ return ret;
+
rate_emu_sleep(ist);
sub2video_update(ist, &subtitle, pkt->pts);
@@ -1667,7 +1688,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output)
if (!check_output_constraints(ist, ost) || !ost->encoding_needed)
continue;
- do_subtitle_out(output_files[ost->file_index]->ctx, ost, ist, &subtitle, pkt->pts);
+ do_subtitle_out(output_files[ost->file_index]->ctx, ost, ist, &subtitle, pts);
}
avsubtitle_free(&subtitle);