Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Devin Heitmueller <devin.heitmueller@ltnglobal.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: matthew@watchgood.com
Subject: Re: [FFmpeg-devel] [PATCH] Playout to DeckLink will wait for all buffered frames before stopping.
Date: Tue, 8 Jul 2025 10:54:39 -0400
Message-ID: <CAHGibzFgLA-O5tjWLgHYTR54B-Gtx=Jr7uKJ_9HwR6hJHkumRg@mail.gmail.com> (raw)
In-Reply-To: <mailman.5605.1751938799.1384.ffmpeg-devel@ffmpeg.org>

Hi Matt,

Thanks for your contribution.  Comments inline.

On Mon, Jul 7, 2025 at 9:40 PM Matt via ffmpeg-devel
<ffmpeg-devel@ffmpeg.org> wrote:
> diff --git a/libavdevice/decklink_enc.cpp b/libavdevice/decklink_enc.cpp
> index cb8f91730e..5751f27de8 100644
> --- a/libavdevice/decklink_enc.cpp
> +++ b/libavdevice/decklink_enc.cpp
> @@ -20,6 +20,7 @@
>   */
>
>  #include <atomic>
> +#include <unistd.h>

Not needed (see below)

>  using std::atomic;
>
>  /* Include internal.h first to avoid conflict between winsock.h (used by
> @@ -369,11 +370,26 @@ av_cold int ff_decklink_write_trailer(AVFormatContext *avctx)
>  {
>      struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
>      struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
> +    uint32_t buffered;
>
>      if (ctx->playback_started) {
>          BMDTimeValue actual;
>          ctx->dlo->StopScheduledPlayback(ctx->last_pts * ctx->bmd_tb_num,
>                                          &actual, ctx->bmd_tb_den);
> +        av_log(avctx, AV_LOG_DEBUG, "Stopped at %ld, requested %ld\n", actual, ctx->last_pts * ctx->bmd_tb_num);
> +        while (1){
> +            ctx->dlo->GetBufferedVideoFrameCount(&buffered);
> +            if (buffered <= 0){
> +                break;
> +            }
> +            av_log(avctx, AV_LOG_DEBUG, "Waiting for %d buffered frames to finish\n", buffered);
> +            if (buffered < 5) {
> +                usleep(1);
> +            } else {
> +                usleep(300);
> +            }

The sleep calls should use av_usleep(), which is portable and you
don't need unistd.h.  Also, there should be some limit so that it
doesn't block forever if video frames are scheduled very far in the
future (e.g. after 1 second, give up and log a warning).

Devin

-- 
Devin Heitmueller, Senior Software Engineer
LTN Global Communications
o: +1 (301) 363-1001
w: https://ltnglobal.com  e: devin.heitmueller@ltnglobal.com
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2025-07-08 14:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-08  1:39 Matt via ffmpeg-devel
2025-07-08 14:54 ` Devin Heitmueller [this message]
2025-07-08 15:19   ` Marvin Scholz
2025-07-08 16:22     ` Devin Heitmueller
2025-07-08 17:08       ` Marvin Scholz
2025-07-08 17:13         ` Devin Heitmueller
2025-07-08 20:11           ` Marton Balint

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHGibzFgLA-O5tjWLgHYTR54B-Gtx=Jr7uKJ_9HwR6hJHkumRg@mail.gmail.com' \
    --to=devin.heitmueller@ltnglobal.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    --cc=matthew@watchgood.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git