{
_timed_subtitle = s;
- if (_opt->apply_crop) {
+ if (_timed_subtitle && _opt->apply_crop) {
Position const p = _timed_subtitle->subtitle()->position ();
_timed_subtitle->subtitle()->set_position (Position (p.x - _fs->crop().left, p.y - _fs->crop().top));
}
int got_subtitle;
AVSubtitle sub;
if (avcodec_decode_subtitle2 (_subtitle_codec_context, &sub, &got_subtitle, &_packet) && got_subtitle) {
- /* I'm not entirely sure why, but sometimes we get an AVSubtitle with
- no AVSubtitleRects.
+ /* Sometimes we get an empty AVSubtitle, which is used by some codecs to
+ indicate that the previous subtitle should stop.
*/
if (sub.num_rects > 0) {
process_subtitle (shared_ptr<TimedSubtitle> (new TimedSubtitle (sub, _first_video.get())));
+ } else {
+ process_subtitle (shared_ptr<TimedSubtitle> ());
}
avsubtitle_free (&sub);
}