diff options
Diffstat (limited to 'src/lib/ffmpeg_decoder.cc')
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 45983795b..a8bfd2a38 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -45,7 +45,7 @@ #include "util.h" #include "video_decoder.h" #include "video_filter_graph.h" -#include <dcp/subtitle_string.h> +#include <dcp/text_string.h> #include <sub/ssa_reader.h> #include <sub/subtitle.h> #include <sub/collect.h> @@ -178,9 +178,8 @@ FFmpegDecoder::flush_fill() full_length = full_length.ceil (frc.source); if (video && !video->ignore()) { double const vfr = _ffmpeg_content->video_frame_rate().get(); - auto const f = full_length.frames_round (vfr); - auto const v = video->position(film()).get_value_or(ContentTime()).frames_round(vfr) + 1; - if (v < f) { + auto const v = video->position(film()).get_value_or(ContentTime()) + ContentTime::from_frames(1, vfr); + if (v < full_length) { video->emit(film(), make_shared<const RawImageProxy>(_black_image), v); did_something = true; } @@ -244,6 +243,11 @@ FFmpegDecoder::pass () decode_and_process_audio_packet (packet); } + if (_have_current_subtitle && _current_subtitle_to && position() > *_current_subtitle_to) { + only_text()->emit_stop(*_current_subtitle_to); + _have_current_subtitle = false; + } + av_packet_free (&packet); return false; } @@ -260,7 +264,7 @@ deinterleave_audio(AVFrame* frame) /* XXX: can't we use swr_convert() to do the format conversion? */ - int const channels = frame->channels; + int const channels = frame->ch_layout.nb_channels; int const frames = frame->nb_samples; int const total_samples = frames * channels; auto audio = make_shared<AudioBuffers>(channels, frames); @@ -622,7 +626,7 @@ FFmpegDecoder::process_video_frame () video->emit ( film(), make_shared<RawImageProxy>(image), - llrint(pts * _ffmpeg_content->active_video_frame_rate(film())) + ContentTime::from_seconds(pts) ); } else { LOG_WARNING_NC ("Dropping frame without PTS"); @@ -672,7 +676,7 @@ FFmpegDecoder::decode_and_process_subtitle_packet (AVPacket* packet) if (sub_period.to) { _current_subtitle_to = *sub_period.to + _pts_offset; } else { - _current_subtitle_to = optional<ContentTime>(); + _current_subtitle_to = {}; } ContentBitmapText bitmap_text(from); @@ -698,10 +702,6 @@ FFmpegDecoder::decode_and_process_subtitle_packet (AVPacket* packet) only_text()->emit_bitmap_start(bitmap_text); } - if (_current_subtitle_to) { - only_text()->emit_stop (*_current_subtitle_to); - } - avsubtitle_free (&sub); } @@ -816,9 +816,9 @@ FFmpegDecoder::process_ass_subtitle (string ass, ContentTime from) int commas = 0; string text; for (size_t i = 0; i < ass.length(); ++i) { - if (commas < 9 && ass[i] == ',') { + if (commas < 8 && ass[i] == ',') { ++commas; - } else if (commas == 9) { + } else if (commas == 8) { text += ass[i]; } } @@ -827,12 +827,11 @@ FFmpegDecoder::process_ass_subtitle (string ass, ContentTime from) return; } - sub::RawSubtitle base; auto video_size = _ffmpeg_content->video->size(); DCPOMATIC_ASSERT(video_size); sub::SSAReader::Context context(video_size->width, video_size->height, sub::Colour(1, 1, 1)); - auto const raw = sub::SSAReader::parse_line(base, text, context); + auto const raw = sub::SSAReader::parse_line({}, text, context); for (auto const& i: sub::collect<vector<sub::Subtitle>>(raw)) { only_text()->emit_plain_start (from, i); |
