DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
FREEDOM251

Freedom251 › Blog › audio mixing

How to Use FFmpeg to Mix Background Music Under a Prerecorded YouTube Video

By Freedom251 Team · · 5 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use FFmpeg’s amix audio filter to combine a video’s existing sound with a separate music file, then map the filtered audio and video into a new output file. You can keep the video stream unchanged with -c:v copy while encoding the new audio as AAC. The key choices are music level, which audio stream controls the mix’s duration, and whether the music is licensed for your YouTube upload.

Mix the original audio and music with FFmpeg

In a terminal, run this command from the folder containing input.mp4 and music.mp3, replacing those names with your actual file paths:

As an Amazon Associate I earn from qualifying purchases.

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
  • -i input.mp4 supplies the video and its existing audio; -i music.mp3 supplies the separate music.
  • [1:a:0]volume=0.25[music] lowers the music input before mixing. The value is a starting point, not a universal speech-to-music setting.
  • amix=inputs=2 combines the two audio streams. duration=first makes the mixed audio end with the first audio input, which here is the video’s original audio.
  • -map 0:v:0 selects the first video stream, and -map "[mix]" selects the filtered audio output.
  • -c:v copy copies the video stream without re-encoding it. -c:a aac -b:a 192k encodes the filtered audio as AAC at the specified bitrate.

This is an illustrative command based on FFmpeg’s documented filter and mapping behavior, not a tested recipe. FFmpeg’s official filter documentation describes amix as mixing multiple audio inputs into one output. A published FFmpeg Cookbook example also uses a filtered audio output alongside a separately mapped video stream.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the mix duration and ending

The duration option determines when the mixed audio ends:

#1 Best Overall
Audio-Technica ATH-M20x Professional Studio Monitor Headphones, Black | Closed-back design with 40mm drivers and 3m cable for monitoring, tracking and mixing
  • 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
  • duration=first: end when the first audio input ends. In the example, that is the video’s original audio.
  • duration=shortest: end when the shorter audio input ends. Use this if the music must not continue beyond a shorter original-audio stream.
  • duration=longest: let the longer audio input determine the mix end. Consider whether that would leave audio after the video ends.

The video stream can end before the mixed audio does. If you need the exported file to stop with the shortest stream, consider adding -shortest as an output option, then inspect the result to confirm that the ending is right. These duration behaviors and the option to stop output at the shortest stream are documented in the FFmpeg filter reference.

Adjust the music without losing the original sound

Change volume=0.25 to adjust the music independently before it is mixed with the original audio. There is no single correct value: the appropriate level depends on the recording, the music, and how prominent you want the music to be. Listen to the exported file, especially where speech begins or ends, and check that neither the speech nor the overall mix clips.

Rank #2
OneOdio Wired DJ Hi-Res Over-Ear Headphones for PC, Keyboard Guitar - Black | headphone with 50mm drivers, dual 3.5mm and 6.35mm jacks for studio monitoring, recording, podcasting, mixing and DJ use.
  • 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.

amix normalization is enabled by default. Its dropout_transition option controls how long volume renormalization takes when an input ends; the documented default is two seconds. Setting dropout_transition=0, as in the example, removes that transition. If you disable normalization, FFmpeg warns that uncontrolled input levels can cause heavy clipping. See the official documentation for amix before changing its normalization behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check the inputs and output

Confirm the video has an audio stream

The example expects the first input to contain audio at [0:a:0] and the music file to contain audio at [1:a:0]. If those streams do not exist, the filter cannot use them. Check the files’ streams before running the command. If the video has no audio, there is no original sound to preserve: mix the music input alone and map the resulting filtered audio instead.

Rank #3
Sony MDR7506 Professional Large Diaphragm Headphone
  • 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

Keep the container and codecs compatible

The example writes an MP4 container, copies the source video stream, and encodes the new audio as AAC. Stream-copying avoids re-encoding the video, but it is suitable only when the source video stream is compatible with the destination container and intended playback. The filtered audio cannot be copied as-is because it is newly created by the filter; it must be encoded.

Review the finished file

Play output.mp4 from beginning to end. Check that the original sound remains, the music level is appropriate, the audio and picture end where you intend, and the file plays in your target player before uploading it.

Rank #4
Audio-Technica ATH-M50X Professional Studio Monitor Headphones, Black, Professional Grade, Critically Acclaimed, with Detachable Cable
  • 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

Use music you are allowed to publish on YouTube

Mixing a track into a video does not grant permission to use it. Before uploading, check the track’s license, YouTube-use permissions, and any attribution requirement. YouTube says tracks in its Audio Library are royalty-free production music or sound effects, and that only tracks from that library are known to YouTube to be copyright-safe. Its guidance says Creative Commons tracks require attribution in the video description. YouTube also says it cannot give legal advice and is not responsible for issues with other music libraries. Read its current guidance, Use music and sound effects from the Audio Library, and check the selected track’s terms before publishing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or let it run in the cloud

FFmpeg prepares a finished video file; it does not keep a YouTube channel live by itself. If your next step is a 24/7 YouTube stream made from uploaded videos, StreamNeo is a cloud service from Yorker Media: upload a recording or build a playlist, add your YouTube stream key once, and go live. StreamNeo loops uploaded videos on YouTube, so nothing has to stay on at home. It does not stream from a camera or to other platforms.

Best Value
Wired Headphones, Over Ear Headphones for Studio Monitor & Mixing DJ
  • 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 automatically recovers if YouTube drops the stream.
  • Every slot streams the uploaded quality as-is, up to 4K 60fps, for one flat price per slot; there are no quality tiers or re-encoding.
  • The first day is free, with no card required. It is one free day per account.

A slot includes one always-on stream, 10 GB of storage per slot pooled across active slots, 24/7 looping and playlists, automatic recovery if YouTube drops the stream, and support from the StreamNeo team. The same product is on every plan; only the billing length changes. Monthly: $9.99 per month. Billing options also include a day, a week, six months, or a year, with cancellation available any time. UPI and cards are accepted in India; card checkout is available worldwide. For five or more slots, contact support. See StreamNeo or its pricing page. Start your free first day with StreamNeo.

Quick Recap

Bestseller No. 1
Audio-Technica ATH-M20x Professional Studio Monitor Headphones, Black | Closed-back design with 40mm drivers and 3m cable for monitoring, tracking and mixing
Audio-Technica ATH-M20x Professional Studio Monitor Headphones, Black | Closed-back design with 40mm drivers and 3m cable for monitoring, tracking and mixing
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
$59.00
Bestseller No. 3
Sony MDR7506 Professional Large Diaphragm Headphone
Sony MDR7506 Professional Large Diaphragm Headphone
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
$113.00
Bestseller No. 4

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

audio mixingbackground musicFFmpegvideo editingYouTube

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.