Delay after a time, using a UDP output

I am going to try to express myself as best as possible, I am using CasparGG to have an automated video channel with a python client, this requires it to be running 24/7.

The problem I have found is that after a few hours, 5 hours for example, the audio begins to be delayed, and after 10 hours the delay has increased.

If I open the udp in a player like VLC or mpv, I have no delay, everything looks fine, then
I have come to assume that the problem is that there may be some discrepancies between the audio and video format, or that there is some buffer time which causes the audio to have some delay, below I put the configuration that I am using in the server configuration.

As additional information, the UDP stream is entering a device that converts from IP to analog television. If I restart UDP reception again, synchrony is recovered. The other channels that I receive via satellite do not suffer that delay.


<?xml version="1.0" encoding="utf-8"?>
<configuration>
	<paths>
		<media-path>media/</media-path>
		<log-path disable="false">log/</log-path>
		<data-path>data/</data-path>
		<template-path>template/</template-path>
	</paths>
	<lock-clear-phrase>secret</lock-clear-phrase>
	<channels>
		<channel>
			<video-mode>NTSC</video-mode>
			<consumers>
				<ffmpeg>
					<path>udp://192.168.10.250:2036?pkt_size=1316</path>
					<args>-codec:v h264_nvenc -preset:v fast -b:v 6000k -filter:v format=pix_fmts=yuv420p,fps=30 -format mpegts</args>
				</ffmpeg>
			</consumers>
		</channel>
		<channel>
			<video-mode>NTSC</video-mode>
			<consumers>
				<ffmpeg>
					<path>udp://192.168.10.250:2037?pkt_size=1316</path>
					<args>-codec:v h264_nvenc -preset:v fast -b:v 6000k -filter:v format=pix_fmts=yuv420p,fps=30 -format mpegts</args>
				</ffmpeg>
			</consumers>
		</channel>
		<channel>
			<video-mode>NTSC</video-mode>
			<consumers>
				<ffmpeg>
					<path>udp://192.168.10.250:2045?pkt_size=1316</path>
					<args>-codec:v h264_nvenc -preset:v fast -b:v 6000k -filter:v format=pix_fmts=yuv420p,fps=30 -format mpegts</args>
				</ffmpeg>
			</consumers>
		</channel>
	</channels>
	<controllers>
		<tcp>
			<port>5250</port>
			<protocol>AMCP</protocol>
		</tcp>
	</controllers>
	<amcp>
		<media-server>
			<host>localhost</host>
			<port>8000</port>
		</media-server>
	</amcp>
</configuration>

This may not be the cause of the issues you have, but your channel configuration seems slightly odd. You have set the three output channels to operate as NTSC (29.97 frames/sec), but you then tell ffmepg to change the frame rate to 30 frames per second.

It sounds like the audio delay might be related to buffer or synchronization issues. Given that VLC or mpv don’t show delays, the problem might be specific to your CasparCG setup. Consider checking if there’s a buffer setting in CasparCG or your UDP stream settings that could be adjusted. You might also look into the pkt_size parameter to see if a different value helps with synchronization.