The ff_decklink_write_packet() was always caching the last pts received, to be used when calling StopScheduledPlayback(). However because audio and video are on different timebases and the call to StopScheduledPlayback() expects the video timebase, we'll end up sending a weird value to the stop routine if the last packet received contained audio. Move the setting of last_pts to just be for the video stream.
Showing the changes to libavdevice/decklink_enc.cpp (1 of 1 file). Show all
Unified · Split
| @@ -441,6 +441,8 @@ static int decklink_write_video_packet(AVFormatContext *avctx, AVPacket *pkt) · 440 unmodified lines | ||
| 441 | 441 | uint32_t buffered; |
| 442 | 442 | HRESULT hr; |
| 443 | 443 | |
| 444 | + ctx->last_pts = FFMAX(ctx->last_pts, pkt->pts); | |
| 445 | + | |
| 444 | 446 | if (st->codecpar->codec_id == AV_CODEC_ID_WRAPPED_AVFRAME) { |
| 445 | 447 | if (tmp->format != AV_PIX_FMT_UYVY422 || |
| 446 | 448 | tmp->width != ctx->bmd_width || |
| @@ -629,8 +631,6 @@ int ff_decklink_write_packet(AVFormatContext *avctx, AVPacket *pkt) · 182 unmodified lines | ||
| 629 | 631 | struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx; |
| 630 | 632 | AVStream *st = avctx->streams[pkt->stream_index]; |
| 631 | 633 | |
| 632 | − ctx->last_pts = FFMAX(ctx->last_pts, pkt->pts); | |
| 633 | − | |
| 634 | 634 | if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) |
| 635 | 635 | return decklink_write_video_packet(avctx, pkt); |
| 636 | 636 | else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) |