Skip to content
streamneo.
Tools11 min read

FFmpeg Keyframe Interval for YouTube Live at 30fps

Set FFmpeg to -g 60 for YouTube Live at 30fps, configure a closed GOP and verify stream health before going live.

sn.
StreamNeoPublished 7 October 2026
Worth sharing?

For YouTube Live over RTMP or RTMPS at 30 fps, use a two-second keyframe interval. In FFmpeg, that converts to -g 60: the two-second interval multiplied by 30 frames per second.

YouTube’s encoder guidance recommends two seconds and says not to exceed four seconds. The 60-frame figure is the arithmetic conversion for 30 fps, not a separate frame-count specification from YouTube. Set a closed GOP as well, then check YouTube’s stream health during a test rather than assuming the command alone proves the output is correct.

The interval YouTube recommends

YouTube Help’s encoder settings guidance gives the RTMP/RTMPS keyframe frequency as “Recommended 2 seconds” and “Do not exceed 4 seconds”. These are time-based instructions. They are the starting point for deciding what to put in FFmpeg, where the GOP interval is commonly expressed as a number of frames.

At 30 fps, two seconds of video contains 60 frames. Four seconds contains 120. The first conversion gives you the recommended target; the second converts the upper bound. Do not treat the upper bound as an alternative recommendation: a value at the ceiling is not the same as choosing the recommended interval.

These figures are for the RTMP/RTMPS encoder guidance. YouTube documents other ingest protocols separately. For example, its DASH live-ingestion guide says the GOP should be about two seconds and under eight seconds, and also calls for closed GOPs. That protocol-specific wording is not a reason to use an eight-second GOP with an RTMP/RTMPS stream.

Before converting seconds to frames, confirm that the output really is 30 fps. A source video may have one frame rate while the encoded output uses another. The GOP count needs to be interpreted against the output rate: 60 frames at a different rate will not represent two seconds. If your channel is built from a playlist or looping media, it is worth checking the actual output profile, not just the properties of one source file. A Hindi playlist loop using Restreamer may be assembled from media with differing properties, so verify the encoder’s output rather than infer it from the files.

Convert two seconds into 60 frames

The conversion is straightforward: interval in seconds multiplied by frames per second equals the number of frames. For the recommended interval at 30 fps, that is 2 × 30 = 60. For YouTube’s four-second maximum, it is 4 × 30 = 120. You are calculating frame counts from YouTube’s time guidance; you are not quoting a separate YouTube rule that says “60 frames”.

RTMP/RTMPS interval Conversion at 30 fps Meaning
Recommended 2 seconds 60 frames Use this as the target interval
Do not exceed 4 seconds 120 frames Upper bound, not the recommended target

The count is useful because FFmpeg’s -g option controls the number of frames between keyframes. FFmpeg’s documentation for encoder settings describes g as the maximum distance between keyframes. In typical fixed-GOP use, -g 60 is therefore the practical interval setting for this case. The qualifier matters: the option sets an interval limit, and encoder behaviour and other options can affect the resulting stream. It is sensible to check the live output rather than rely only on a command line.

The calculation assumes a steady 30 fps output. If the output is variable frame rate or the encoder is configured for another frame rate, do not assume the same count means the same duration. Inspect or set the output frame rate first. In a longer-running channel, confirm this after changing the profile, not only when you first configure it; a profile change can invalidate the old arithmetic.

Set FFmpeg GOP with -g 60

For the interval itself, the relevant FFmpeg setting is:

-g 60

Put it among the options for the video encoder in your command. It means that the encoder should not let the keyframe distance exceed 60 frames. At a verified output rate of 30 fps, that corresponds to two seconds. This is the direct answer to the title’s question; the rest of the setup determines whether the output is appropriate and whether YouTube accepts it cleanly.

There is no universal full FFmpeg command that can be prescribed from this setting alone. The exact command depends on the codec, encoder implementation, input, audio, bitrate, container and ingest protocol. A command copied from a different encoder may use an option that is ignored or has different behaviour. Treat -g 60 as the GOP interval setting, not as a complete recipe for every YouTube Live stream.

If you are using a software encoder in OBS or another tool that builds an FFmpeg command for you, set the GOP or keyframe interval in that tool’s encoder controls. Do not add -g 60 blindly to a field that is not passed to the video encoder. A useful check is whether the tool exposes a keyframe interval as seconds or frames: enter the value in the unit the field asks for, and avoid converting twice. For example, a field explicitly asking for seconds would take two, not 60.

Keep the rest of the encoding configuration aligned with YouTube’s current guidance for your protocol and codec. The Help page lists settings beyond keyframes, including bitrate encoding guidance. The best configuration for a devotional audio loop may differ from a local news feed with regular motion, but neither changes the two-second conversion at 30 fps. For a broader setup context, the guide to starting a 24/7 devotional podcast stream in India can help distinguish the content workflow from the encoder settings.

Configure a closed GOP and the rest of the output

Use a closed GOP. YouTube’s LiveStream API health documentation identifies open GOP as unsupported and can report an openGop configuration issue. The precise closed-GOP option depends on the encoder and codec, so use the selected encoder’s own documentation to find and confirm the right control. Do not infer that the GOP is closed just because you set -g 60; that option addresses the interval, not the GOP mode.

This distinction avoids a common configuration mistake: treating the interval and GOP structure as one setting. They answer different questions. The interval determines how far apart keyframes are; the closed-GOP setting determines whether pictures in one GOP depend on pictures from another. YouTube’s health check can flag an open GOP, so set it deliberately and check the ingest result.

YouTube publishes separate requirements for protocols. Its HLS ingestion guide also specifies closed GOPs, but HLS segment-duration guidance is not the same thing as the RTMP/RTMPS keyframe interval. If your workflow uses HLS or DASH, read that protocol’s current documentation rather than transplanting the RTMP/RTMPS table. For a typical FFmpeg-to-YouTube RTMP/RTMPS setup, keep the recommendation from the encoder settings page as the controlling interval guidance.

Other output settings still matter. The video codec and encoder must be supported for the ingest path you choose, the output frame rate must be what you think it is, and audio must be present and configured correctly. YouTube’s encoder settings page is the primary place to check current supported settings. The intended configuration is not validated merely because FFmpeg starts without an error; an encoder can produce a stream while YouTube reports a health problem.

If you send a backup stream, align its keyframe frequency with the main stream. YouTube’s health messages include a GOP mismatch diagnostic, so differing settings can create an avoidable ingest issue during a failover. This is especially worth checking in a setup designed to keep a channel running continuously: document the main and backup output profiles together, including frame rate, interval and GOP mode. The article on relaunching a YouTube live stream without changing its URL covers a related continuity concern, but it does not replace checking the encoder settings on both outputs.

Read keyframe and stream-health warnings

A value in the command is an intention. YouTube’s stream health is evidence about what it receives. The LiveStream API health-status documentation describes diagnostics for issues including GOPs that are too long, open GOP, and mismatched GOP settings. Use those diagnostics to investigate the ingest rather than treating the presence of -g 60 as proof of compliance.

A warning about a GOP longer than four seconds is a signal to check the actual output and the configured frame rate. It does not mean you should target four seconds; the RTMP/RTMPS guidance still recommends two. A very small GOP can also reduce image quality, according to the health documentation. Avoid trying to improve reliability by making keyframes arbitrarily frequent. Start with the published interval, then change settings only in response to a specific problem and re-test.

When a warning appears, isolate the likely cause methodically. Confirm that the stream is going to the intended YouTube ingest and protocol. Check that the output frame rate is 30 fps, then inspect the video encoder’s GOP interval and closed-GOP control. If the feed has a backup, compare its settings with the main feed. Finally, allow the test stream to run with representative content and see whether the warning clears. If it persists, consult the current documentation for the exact health message and your encoder’s controls.

YouTube Studio’s stream health view is useful during an actual ingest because it reflects the stream YouTube is receiving. FFmpeg logs help establish what the local process is doing, but they cannot tell you by themselves whether YouTube has accepted the stream without a relevant health issue. If a long-running broadcast is managed from a computer that may be switched off or lose power, a cloud-run service such as StreamNeo can remove the specific burden of keeping that local machine running; you still need to configure and verify the stream settings described here.

Test the live ingest before relying on it

Run a test with representative material before scheduling an overnight or continuous broadcast. Include both audio and motion. A static slate with silence may not reveal a missing audio stream, timing issue or behaviour that appears only when the picture changes. YouTube recommends testing and monitoring stream health; the point is to expose configuration problems while you can still correct them, not to assume that a short successful connection proves every part of the channel workflow.

A practical check can follow this order:

  1. Confirm the output frame rate is 30 fps.
  2. Set the keyframe interval to two seconds, or -g 60 in the FFmpeg case.
  3. Configure closed GOP with the encoder-specific control.
  4. Start a private or otherwise appropriate test ingest and check YouTube’s stream health.
  5. Include representative audio and moving picture, and watch for GOP, ingestion or audio warnings.
  6. If there is a backup stream, verify that its keyframe frequency matches the main stream.

Do not use an HLS segment duration as a substitute for the GOP interval. The protocol documentation keeps these concerns distinct, and HLS has its own delivery requirements. Similarly, do not assume an OBS setting is in frames when the interface labels it in seconds. Verify the actual output profile and the live health view after changing the setting.

For a channel built around a repeating media file, test a transition or loop point too. The keyframe interval applies across the encoded output, while a file boundary can introduce separate playback or timing behaviour. If you are running a playlist, check that the stream stays healthy across a change from one item to the next. A setup using Google Drive audio as a YouTube Live playlist has a different content source, but the same need to test the emitted live feed rather than judge it only from the playlist configuration.

Once the test is clean, save the known-good encoder profile and note its output frame rate, GOP interval, closed-GOP setting, codec and ingest protocol. That record makes later troubleshooting more concrete: if a warning returns after a change, you can identify what changed instead of rebuilding the configuration from memory. Recheck YouTube’s current official guidance when you alter protocol, codec or encoder, since recommendations and diagnostics can change.

Before committing, compare the operating options on the pricing page. When the file and channel are ready, start free — 24-hour trial, no card.

FAQ

Is -g 60 right for YouTube Live at 30 fps?

For an RTMP/RTMPS stream outputting at 30 fps, it is the frame-count conversion of YouTube’s recommended two-second interval. FFmpeg’s -g controls the number of frames between keyframes. Confirm the output frame rate and configure a closed GOP separately.

Is 60 frames a YouTube specification?

YouTube’s encoder guidance states the interval in seconds, not as a separately published 60-frame rule. At 30 fps, two seconds converts to 60 frames. The 120-frame figure similarly converts the four-second upper bound; it is not the recommended target.

Can I set -g 120 because YouTube says not to exceed four seconds?

That would correspond to the four-second ceiling at 30 fps, not the recommended two-second interval. Start with -g 60 for the stated case, then check YouTube stream health during a representative test. Do not treat the maximum as the preferred setting.

Does -g 60 configure a closed GOP?

No. It sets the keyframe interval limit, while closed GOP is a separate encoder configuration. The exact control depends on the selected codec and encoder, and YouTube’s health documentation identifies open GOP as unsupported. Configure the encoder’s closed-GOP option and verify the live ingest.

YOU’VE REACHED THE END

Keep the ideas coming.

More guides, useful tools and a little help for your next broadcast.

Back to the journal ↗
YOUR NEXT READ

A little more to explore.

More Tools guides ↗ · All topics ↗