Feature Summary
Allow users to configure one or more "broadcast delays" of N seconds that can be "dumped", or skipped over, using a GUI button or hotkey, to skip over an event that should not be broadcast. TV and radio stations often use this in case a caller, guest, host, or audience member says swears or says/does something objectionable to prevent it from being broadcast.
The user should be able to set up X number of delays of N seconds, perhaps with some guardrails. This feature should be disabled by default.
After pressing Start Stream, the stream should be delayed as needed to build up the delay.
After a delay is used, the stream could be slowed down by an unnoticeable amount (ex, 0.95x) until the delay is built back up. Maybe this behavior could be configurable.
Implementation Discussion
Adding a broadcast delay in FFmpeg for pre-recorded files is straightforward using the -itsoffset option. For live streams, a filter-based approach with tpad and adelay is necessary to manage timestamps dynamically.
For Pre-recorded Files
The -itsoffset option, placed before an input file (-i), delays all streams within that specific input. To delay only one stream (e.g., video) and not the other (e.g., audio), you must input the same file twice and use mapping options.
Delay all streams (video and audio) by 5 seconds:
ffmpeg -itsoffset 5 -i input.mp4 -c copy output.mp4
The output file will be 5 seconds longer than the input, with silence/blackness at the beginning.
Delay only the video stream by 5 seconds:
ffmpeg -i input.mp4 -itsoffset 5 -i input.mp4 -map 1:v -map 0:a -c copy output.mp4
-i input.mp4: The first input (0:) is for the original audio.
-itsoffset 5 -i input.mp4: The second input (1:) is for the video, with its timestamps offset by 5 seconds.
-map 1:v: Selects the video stream from the second, delayed input.
-map 0:a: Selects the audio stream from the first, non-delayed input.
-c copy: Copies the codecs without re-encoding to preserve quality and speed.
Delay only the audio stream by 5 seconds:
ffmpeg -itsoffset 5 -i input.mp4 -i input.mp4 -map 0:v -map 1:a -c copy output.mp4
This is a variation of the previous command, mapping the video from the first input and the audio from the second.
We may be able to use this despite it not being "for livestreams"
For Live Streams
For live, real-time input (like a webcam or network stream), the file-based -itsoffset method is not suitable. Instead, use the tpad (timestamp pad) and adelay (audio delay) filters within a -filter_complex command.
This example adds a 5-second delay to both video and audio streams for a live input:
ffmpeg -i [input_stream_source] -filter_complex "tpad=start_duration=5:start_mode=add,realtime[v];[0:a]adelay=5000|5000[a]" -map "[v]" -map "[a]" [output_destination]
tpad=start_duration=5: Adds 5 seconds of blackness at the start of the video stream.
realtime: Helps slow down the output rate to match the input rate for live streams.
adelay=5000|5000: Adds a 5000-millisecond silence delay to the first two audio channels (stereo). Adjust the | values for different channel layouts.
-map "[v]" and -map "[a]": Map the output of the named filter graphs to the output file.
For more information on these filters, consult the official FFmpeg documentation.
Feature Summary
Allow users to configure one or more "broadcast delays" of N seconds that can be "dumped", or skipped over, using a GUI button or hotkey, to skip over an event that should not be broadcast. TV and radio stations often use this in case a caller, guest, host, or audience member says swears or says/does something objectionable to prevent it from being broadcast.
The user should be able to set up X number of delays of N seconds, perhaps with some guardrails. This feature should be disabled by default.
After pressing Start Stream, the stream should be delayed as needed to build up the delay.
After a delay is used, the stream could be slowed down by an unnoticeable amount (ex, 0.95x) until the delay is built back up. Maybe this behavior could be configurable.
Implementation Discussion
Adding a broadcast delay in FFmpeg for pre-recorded files is straightforward using the -itsoffset option. For live streams, a filter-based approach with tpad and adelay is necessary to manage timestamps dynamically.
For Pre-recorded Files
The -itsoffset option, placed before an input file (-i), delays all streams within that specific input. To delay only one stream (e.g., video) and not the other (e.g., audio), you must input the same file twice and use mapping options.
Delay all streams (video and audio) by 5 seconds:
ffmpeg -itsoffset 5 -i input.mp4 -c copy output.mp4The output file will be 5 seconds longer than the input, with silence/blackness at the beginning.
Delay only the video stream by 5 seconds:
ffmpeg -i input.mp4 -itsoffset 5 -i input.mp4 -map 1:v -map 0:a -c copy output.mp4-i input.mp4: The first input (0:) is for the original audio.-itsoffset 5 -i input.mp4: The second input (1:) is for the video, with its timestamps offset by 5 seconds.-map 1:v: Selects the video stream from the second, delayed input.-map 0:a: Selects the audio stream from the first, non-delayed input.-c copy: Copies the codecs without re-encoding to preserve quality and speed.Delay only the audio stream by 5 seconds:
ffmpeg -itsoffset 5 -i input.mp4 -i input.mp4 -map 0:v -map 1:a -c copy output.mp4This is a variation of the previous command, mapping the video from the first input and the audio from the second.
We may be able to use this despite it not being "for livestreams"
For Live Streams
For live, real-time input (like a webcam or network stream), the file-based
-itsoffsetmethod is not suitable. Instead, use thetpad(timestamp pad) andadelay(audio delay) filters within a-filter_complexcommand.This example adds a 5-second delay to both video and audio streams for a live input:
ffmpeg -i [input_stream_source] -filter_complex "tpad=start_duration=5:start_mode=add,realtime[v];[0:a]adelay=5000|5000[a]" -map "[v]" -map "[a]" [output_destination]tpad=start_duration=5: Adds 5 seconds of blackness at the start of the video stream.realtime: Helps slow down the output rate to match the input rate for live streams.adelay=5000|5000: Adds a 5000-millisecond silence delay to the first two audio channels (stereo). Adjust the | values for different channel layouts.-map "[v]" and -map "[a]": Map the output of the named filter graphs to the output file.For more information on these filters, consult the official FFmpeg documentation.