For a prerecorded fireplace video, FFmpeg can repeat the file and send it to YouTube Live as a real-time broadcast. The command below is a starting template for a 1920×1080, 30 fps file with stereo audio; it is not the right answer for every source, connection or FFmpeg build.
You will need to check the file first, adjust the output to suit it, and substitute the RTMPS ingest address and stream key from YouTube Live Control Room. Test the stream as unlisted and check its health before relying on it unattended.
What this command is designed to do
The template reads a video file at its natural playback pace, repeats it indefinitely, encodes video and audio, then sends the result to YouTube over RTMPS. The repeated source is still one prerecorded file: this command does not create new scenes, repair a damaged file or guarantee that the broadcast will stay connected.
ffmpeg -re -stream_loop -1 -i "fireplace.mp4" \\
-map 0:v:0 -map 0:a:0? \\
-c:v libx264 -preset veryfast \\
-b:v 5000k -maxrate 5000k -bufsize 10000k \\
-pix_fmt yuv420p -r 30 -g 60 -keyint_min 60 -sc_threshold 0 \\
-c:a aac -b:a 128k -ar 44100 \\
-f flv "rtmps://YOUTUBE_INGEST_URL/YOUR_STREAM_KEY"
Each line continues the same shell command because it ends in a backslash. In a Windows command prompt, line-continuation syntax differs; you can put the command on one line or adapt it to the shell you use. The filename fireplace.mp4 is an example, as are both URL placeholders. Do not copy them unchanged and expect a connection.
This example asks for H.264 video and AAC audio in an FLV output carried over RTMPS. YouTube’s live encoder guidance covers supported ingest settings and recommends RTMPS. FFmpeg’s command-line documentation explains how options are applied to inputs and outputs. Check the current official guidance and the options supported by your installed FFmpeg version before a long run.
A loop can make a useful continuous visual for a quiet-room channel, but a long broadcast also involves practical choices beyond encoding. If you are planning an always-on channel rather than a one-off test, see the considerations in creating an always-on YouTube music channel. For another example of repeating prerecorded material, looping podcast episodes on YouTube Live uses a different source workflow but raises similar questions about continuity and monitoring.
Check the source file and its audio track
Before encoding, inspect what the file actually contains. ffprobe is included with many FFmpeg distributions and can report its video dimensions, frame rate, duration, codecs and audio streams. For example:
ffprobe -hide_banner "fireplace.mp4"
Read the output rather than assuming the filename tells you the format. A file may be 1280×720 rather than 1920×1080, or it may use a frame rate other than 30 fps. It may have no audio stream at all. Those details affect which output settings make sense and whether the sample command can map and encode the tracks as written.
The mapping -map 0:v:0 selects the first video stream from input zero. The expression -map 0:a:0? asks for the first audio stream, but the trailing ? makes that mapping optional. That is useful when a file might be silent, though it does not mean you have verified what YouTube will accept in every configuration. If there is no audio, remove the audio mapping and audio encoding options or deliberately add a silent track using a workflow you have tested.
If the fireplace recording has a crackle, music or room tone, listen to its beginning and end. A sharp jump at the loop boundary can be more noticeable than the visual change in a mostly static scene. FFmpeg repeating the file does not crossfade the end into the beginning. If the transition matters, prepare a seamless source or another deliberate edit before streaming.
Also confirm that you have the rights to rebroadcast the video and any audio in it, and that your account is set up to livestream. This command does not check either point. The channel verification guide explains one part of preparing a channel; check YouTube’s current requirements for your account rather than treating an encoding command as account approval.
Why input options come before the filename
FFmpeg commands are read from left to right, and many options apply to the next input or output that follows them. In the sample, -re and -stream_loop -1 appear before -i "fireplace.mp4" because they govern how FFmpeg reads that input. Placing them after the filename would not express the same input configuration.
The -i marks the input boundary. Options after it, such as -map and the codec settings, describe what FFmpeg should select and produce for the output. The final URL is the output destination, so -f flv applies to that output. FFmpeg’s documentation on options is worth consulting when adapting a command: order is part of the meaning, not merely formatting.
This scope distinction is a common source of confusion when commands are copied from a web page. If you move an option while tidying a command, identify whether it belongs to the input, the output, or both, and check the installed build’s help. A command can still run after a misplaced option while doing something other than intended.
Loop and pace the prerecorded input
-stream_loop -1 asks FFmpeg to loop the input indefinitely. The -1 value is the repeat-forever setting; it is not a count of how many times to replay the file. Put it before -i so it applies to the file being read. The loop concerns that input file, not an instruction for YouTube to replay a completed broadcast.
-re tells FFmpeg to read the file at its native rate, rather than consuming the file as fast as the computer can process it. That pacing is useful when a file is being used as a live source. Without it, an offline transcode may finish quickly, and a live ingest would not receive the file as a real-time programme.
The options do not make an unsuitable source suitable. If your source is variable-frame-rate, unusually large, damaged or encoded in a way that is costly for your computer to decode and re-encode, test it for a sustained period. Monitor CPU load, the FFmpeg output and YouTube’s preview. A file that plays once on a desktop is not automatically proof that a long-running stream will behave well.
There is a further distinction between a loop that runs and a broadcast that remains available. A local command depends on the computer, power, network and the process itself. YouTube warns that connection disruptions can affect a stream, and recommends leaving upload-bandwidth margin in its streaming tips. If maintaining an unattended broadcast without leaving your own computer on is the specific problem, StreamNeo removes that particular need by turning an uploaded file into a YouTube live stream that it monitors and restarts if it drops.
Understand the video and audio settings
The template’s video choices assume 1080p at 30 frames per second. Those assumptions matter: encoding a 720p source as 1080p does not add detail, while forcing a different source frame rate can change motion or require extra processing. A flame is moving detail, even if a fireplace scene appears static overall. Compare the actual result rather than assuming a lower frame rate will be invisible.
-c:v libx264 selects the H.264 encoder, and -preset veryfast trades some compression efficiency for less encoding work than slower presets. It does not promise that any particular computer can encode the source smoothly. -pix_fmt yuv420p selects a widely used pixel format for compatibility with common playback and ingest paths; check it against your actual workflow.
The rate-control settings in the example are -b:v 5000k, -maxrate 5000k and -bufsize 10000k. Together they set a target video bitrate, a maximum rate and a buffer size. This is a CBR-style starting point, not a guarantee that the observed network traffic will be exactly constant at every instant. YouTube’s recommended H.264 rates vary by output resolution and frame rate. Its current bitrate guidance lists these example 30 fps rows:
| H.264 output | YouTube recommended video bitrate | Template implication |
|---|---|---|
| 480p at 30 fps | 0.4 Mbps | The 5000k video target is far above this row. |
| 720p at 30 fps | 3 Mbps | Choose settings for this output rather than retaining 5000k by habit. |
| 1080p at 30 fps | 5 Mbps | This is the resolution and frame-rate assumption in the sample. |
These are recommendations, not mandatory rates or a promise of picture quality. Choose a row that matches your intended output, then consider how much detail the source has and whether your sustained upload can carry video plus audio with headroom. YouTube advises a 20% upload-bandwidth margin; treat that as planning guidance, not an uptime guarantee. The resolution and frame-rate bitrate chart is a useful companion when comparing output choices.
-r 30 requests a 30 fps output. -g 60 sets a 60-frame group of pictures, which at 30 fps corresponds to a two-second keyframe interval. -keyint_min 60 sets the minimum interval, while -sc_threshold 0 disables scene-cut keyframes in this setup to keep the cadence regular. YouTube recommends a two-second keyframe interval and says not to exceed four seconds in its encoder guidance. If you change the frame rate, reconsider the frame-count settings rather than keeping 60 automatically.
For audio, -c:a aac chooses AAC, -b:a 128k sets the audio bitrate, and -ar 44100 requests a 44.1 kHz sample rate. The example’s 128 Kbps setting is YouTube’s recommended rate for stereo audio. It assumes the source has an audio stream worth sending; a silent visual does not acquire meaningful ambience simply because an audio encoder is specified. If the source audio is noisy, clipped or unwanted, fix or remove it before the stream rather than expecting these options to improve it.
Replace the RTMPS URL and stream key safely
Open YouTube Live Control Room and use the ingest details shown for the stream. Replace the whole quoted placeholder at the end with the RTMPS server address and stream key YouTube provides. Do not guess the hostname, add separators from another example or publish a real key in a tutorial, screenshot, shared terminal log or public repository.
YouTube describes a stream key as the password and address for the encoder connection. Treat it like a password: anyone who has it may be able to send a feed to your live event. Keep it out of public documents and revoke or reset it through YouTube if you believe it has been exposed. FFmpeg documents RTMPS as RTMP carried over a secure SSL connection; use the endpoint YouTube supplies rather than constructing one yourself. See the official stream setup instructions for the current control-room flow.
Quoting the final URL prevents shell characters from being interpreted unexpectedly, but it does not conceal the key from every person or process with access to the machine. A command entered directly in a terminal may remain in shell history or be visible in process information. On a shared computer, use an appropriate protected method for storing credentials and limit who can access it. Do not replace security with a fake key in a live command copied from someone else.
The output format -f flv is part of this RTMP-style workflow. If you change the protocol or delivery method, the output container and options may need to change too. This is one reason to use the exact ingest details and requirements for your chosen YouTube setup rather than treating the sample URL as universal.
Test the command and troubleshoot common failures
Start with an unlisted test rather than making the first attempt a public, unattended broadcast. YouTube’s encoder setup guidance advises testing and checking stream health. Watch the preview for picture and sound, review Live Control Room’s health indications, and read FFmpeg’s terminal output. A successful process launch alone does not establish that viewers are receiving a good feed.
If FFmpeg says it cannot find the input, check the filename, working directory and quotation marks. If it reports an unknown option or encoder, confirm your FFmpeg build and whether it includes libx264; builds differ. If the map fails, inspect ffprobe output to confirm there is a video stream and determine whether an audio stream exists. Remove or revise audio mapping and encoding options if the file’s tracks do not match the template.
If YouTube rejects the connection, check that the RTMPS URL and key were copied from the correct event, that the key is current, and that the stream is configured to receive an encoder feed. Never paste the real key into a support forum while asking for help. If the connection starts but the stream health is poor, compare the selected resolution and bitrate with YouTube’s current recommendations, check sustained upload capacity and inspect whether encoding can keep up. Lowering resolution or frame rate can reduce work or bandwidth, but it also changes the delivered image and should be tested.
For a long session, watch for more than the first few moments: check for audio drift, visible loop discontinuity, dropped connection, process exit or computer sleep. YouTube’s guidance says streams under 12 hours are automatically archived; for a stream longer than 12 hours, do not assume there will be one complete archived video. If a complete VOD matters, plan shorter sessions and verify the result in Studio. Streaming continuously also depends on stable power and connectivity, so an unattended setup needs an operational plan, not only a loop flag.
If you are operating from a machine that will remain on, the process itself can stop because of sleep, power loss or a crash. A restart policy can help with process failures, but it cannot restore a failed network or correct a bad source. The systemd guide for FFmpeg on an Indian VPS discusses one way to restart a local FFmpeg process; it is relevant when you have chosen to manage that operating environment yourself.
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
Does -stream_loop -1 loop the video forever?
It tells FFmpeg to repeat the input indefinitely while that FFmpeg process continues running. It does not prevent a computer from sleeping, restore a failed connection or ensure YouTube keeps the event live. Monitor the process and stream health.
Can I use the sample command for a 720p fireplace file?
You can adapt it, but the example targets 1080p30 and uses the matching 5 Mbps H.264 recommendation cited above. Set output resolution and bitrate for the result you intend to send, and reconsider frame rate and keyframe frame counts together. Upscaling a 720p source does not create additional source detail.
What if my fireplace video has no audio?
The optional -map 0:a:0? allows the command to proceed without an audio stream in some cases, but the actual ingest configuration should be tested. You can remove the audio mapping and encoding options or add deliberate silence using a method you have checked. Do not assume that an audio encoder creates useful sound from a silent file.
Will one broadcast produce a complete YouTube archive if it runs all day?
Do not assume so. YouTube says streams under 12 hours are automatically archived, so a longer session may not produce one complete archive. If the archive matters, plan shorter sessions and confirm what appears in YouTube Studio.