Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Use FFmpeg’s amix filter to blend a video’s existing speech or ambience with a separate music file. Lower the music before mixing, choose which audio input controls the mix length, and encode the filtered audio while copying the video stream when its codec is compatible with the output container.
Mix the original audio and music with FFmpeg
The command below keeps the video stream, mixes its first audio stream with a music file, and writes a new AAC audio stream in an MP4 container:
ffmpeg -i input.mp4 -i music.mp3
-filter_complex "[1:a:0]volume=0.25[music];[0:a:0][music]amix=inputs=2:duration=first:dropout_transition=0[mix]"
-map 0:v:0 -map "[mix]" -c:v copy -c:a aac -b:a 192k output.mp4
Replace input.mp4 and music.mp3 with your file names. FFmpeg’s filter documentation describes amix as combining multiple audio inputs into one output. This command is an illustrative pattern, not a guarantee that every source file has the same stream layout or compatible codecs.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallWhat the command does
-i input.mp4and-i music.mp3load the video and music as inputs 0 and 1.[1:a:0]volume=0.25[music]reduces the music input before the mix. The value is a starting point, not a universal voice-to-music setting; listen to the result and adjust for the material.[0:a:0][music]amix=inputs=2:duration=first:dropout_transition=0[mix]combines the first audio stream from the video with the adjusted music.duration=firstmakes the first audio input determine the mix’s duration. A zero-second dropout transition disables the renormalization transition as an input ends.-map 0:v:0selects the first video stream, while-map "[mix]"selects the filtered audio output.-c:v copycopies video without re-encoding it, if the source video codec is compatible with MP4. The filtered audio cannot be stream-copied, so-c:a aacencodes it as AAC;-b:a 192ksets the audio bitrate.
Check that the source has audio
This pattern expects an audio stream at [0:a:0]. If the video has no audio, there is nothing to preserve: mix the music input by itself and map that filtered result. If the file has multiple audio streams, confirm which one you want before choosing its stream index. The -map selections must match the streams and labels that actually exist in your inputs.
Popular on Amazon
- Advanced build quality and engineering; Designed for studio tracking and mixing
- 40 mm drivers with rare earth magnets and copper clad aluminum wire voice coils
- Tuned for enhanced low frequency performance
- Circumaural design contours around the ears for excellent sound isolation in loud environments
- Convenient single side cable exit
Choose how long the mix should run
The duration option determines when amix ends its output:
| Setting | When the mix ends | Use it when |
|---|---|---|
duration=first |
When the first audio input ends | The original video audio should control the mix length, as in the example. |
duration=shortest |
When the shortest audio input ends | You do not want the mix to outlast whichever audio stream is shorter. |
duration=longest |
When the longest audio input ends | You want the longer audio input to continue after the shorter one ends. |
These options concern the audio inputs, not necessarily the video’s end time. If the video ends before the mixed audio, consider output-level duration handling such as -shortest, then check the exported file. The result depends on the streams’ actual lengths, so review the end of the file rather than assuming the selected audio duration also sets the video duration.
Also popular on Amazon
- Bass Sound: Enjoy clear sound and superior comfort with the OneOdio Studio Monitor Headphones. Equipped with large 50mm speaker drivers and neodymium magnets, pro-10 deliver powerful bass, clear vocals, and crisp highs for a balanced stereo sound.
- Built for Comfort: The soft, padded ear cushions are designed to provide long-lasting comfort and effective noise isolation. The adjustable, stretchable headband allows you to easily find the perfect fit and angle for your listening pleasure.
- Single-side Monitoring: The 90° swiveling ear cups allow for single-ear monitoring, making it ideal for DJing or mixing. The self-adjusting and flexible headband ensures a fatigue-free listening experience, even during extended sessions, making these headphones perfect for mastering and mixing.
- Compatibility: Pro-10 wired headphones work exclusively in wired mode and are compatible with a wide range of devices, including smartphones, laptops, tablets, desktop computers, audio interfaces, DJ mixers, amplifiers, and any device that features either a 3.5mm or 6.35mm audio jack.
- Share Audio Port: With a shared audio port, easily connect another pair to share music or videos—no splitters or special cables needed.
Set the music level and avoid clipping
The example applies volume=0.25 to the music alone, so the original sound is not turned down by that filter. Adjust the gain by listening to the exported mix: speech should remain intelligible, while music should sit at the prominence you intend. No single gain value suits every recording.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesamix normalization is enabled by default. If you disable it, FFmpeg warns that clipping can be heavy unless you manage input levels. Listen for distortion and check that the mix remains clear, especially where loud speech, ambience, or musical peaks overlap.
Also popular on Amazon
- Neodymium magnets and 40 millimeter drivers for powerful, detailed sound.Specific uses for product : Professional audio system,Home audio system
- Closed ear design provides comfort and outstanding reduction of external noises
- 9.8 foot cord ends in gold plated plug and it is not detachable; 1/4 inch adapter included
- Folds up for storage or travel in provided soft case
- Frequency Response: 10 Hertz to 20 kilohertz
The dropout_transition option controls how long volume renormalization takes when an input ends; its documented default is two seconds. Use dropout_transition=0 to avoid that transition, or omit the option if you want the documented default behavior. amix is for summing audio inputs; amerge serves a different purpose, combining channels rather than making this kind of background mix.
Check the export before uploading
- Play the file from beginning to end, including the last seconds, to check audio intelligibility, clipping, and whether the mix ends as intended.
- Confirm that the video is present and that its duration is not unexpectedly shorter than the audio.
- If stream-copying the video fails because the source codec is unsuitable for the target container, choose a compatible output/container or encode the video instead of using
-c:v copy. - If FFmpeg reports a missing stream, inspect the input’s stream layout and correct the audio index or mapping; a video without an audio stream cannot use the example’s original-audio label.
Check music rights before publishing on YouTube
Technical ability to mix a track into a video does not establish permission to publish it. YouTube says music and sound effects in its Audio Library in YouTube Studio are royalty-free, and identifies tracks from that library as the music it knows to be copyright-safe. Some Audio Library tracks use Creative Commons licenses and require attribution in the video description; check the selected track’s terms and provide the required credit.
Also popular on Amazon
- Critically acclaimed sonic performance praised by top audio engineers and pro audio reviewers
- Proprietary 45 millimeter large aperture drivers with rare earth magnets and copper clad aluminum wire voice coils
- Exceptional clarity throughout an extended frequency range, with deep, accurate bass response
- Circumaural design contours around the ears for excellent sound isolation in loud environments
- 90 degree swiveling earcups for easy, one ear monitoring, and professional grade earpad and headband material delivers more durability and comfort
YouTube says it cannot give legal advice and is not responsible for issues with music from other libraries. An external source’s “royalty-free” label alone is not YouTube’s assurance. Check the applicable license and attribution requirements for the exact track before uploading.
Or let it run in the cloud
FFmpeg prepares a prerecorded video file; it does not keep a YouTube live stream running. If your goal is to loop prerecorded videos as a 24/7 YouTube stream, StreamNeo is a separate cloud option: upload a recording or playlist, add your YouTube stream key, and go live. It plays uploaded videos, not a camera feed.
Quick Recap
Also popular on Amazon
- High-Resolution Sound Quality: Engineered with massive 50mm dynamic drivers, these wired headphones deliver punchy bass, balanced mids, and precise treble across a wide $20 ext{Hz} - 20 ext{kHz}$ frequency range. Ideal for DJ mixing, studio monitoring, and audiophile listening, they ensure accurate vocal self-monitoring during recording and tracking sessions.
- Maximum Comfort & Portability: Weighing just 260g (9.1 oz), this over-ear headset features skin-friendly protein leather and plush memory foam for long-lasting comfort and passive noise isolation.
- Single-Side Monitoring: Designed for live performing and mixing, the 90° swiveling earcups allow instant single-ear monitoring. The self-adjustable, flexible headband contours perfectly to any head size, ensuring a secure, fatigue-free fit during extended studio sessions.
- Music & Audio Sharing Tech: Share your mix or media without a splitter. This unique feature allows you to daisy-chain multiple headphones: connect the main headset to your device via the 3.5mm jack, then bridge the 6.35mm output to another pair for seamless, zero-latency co-listening.
- No Adapter Required: Equipped with a detachable 5.7ft - 6ft coiled cord, these headphones offer ultimate freedom of movement. Dual 3.5mm and 6.35mm plugs provide plug-and-play compatibility with audio mixers, interfaces, PCs, tablets, and smartphones.
- Your computer and home connection do not have to stay on; StreamNeo runs the stream in the cloud and automatically recovers if YouTube drops it.
- Videos stream as uploaded, up to 4K 60fps, at one flat price per slot with no quality tiers.
- The first day is free with no card, one free day per account. Monthly pricing is $9.99 per month.
See StreamNeo or start the free first day.
Sources and further reading
- FFmpeg Filters Documentation —
amixoptions and behavior. - YouTube Help: Use music and sound effects from the Audio Library — Audio Library, attribution, and copyright guidance.
- FFmpeg Cookbook: Add Background Music with FFmpeg — a published practical example updated September 27, 2026, identifying FFmpeg 8.1.






Say something about this film