How to Use the amovie Filter in FFmpeg

The amovie filter in FFmpeg is a powerful tool designed to load audio streams from external media files directly into an active audio filtergraph. This article provides a straightforward guide on how to use the amovie filter, detailing its basic syntax, explaining common use cases like audio mixing, and presenting practical, ready-to-use command examples.

Understanding the amovie Filter

Unlike standard FFmpeg inputs declared with the -i option, the amovie filter acts as an audio source inside a filtergraph (typically using -filter_complex). It reads an audio stream from a specified file and outputs it as a temporary stream that can be manipulated by subsequent filters. This is highly useful when you need to dynamically inject, mix, or process external audio tracks during complex editing workflows.

Basic Syntax

The basic syntax for the amovie filter is:

amovie=filename[out]

You can customize the filter behavior using optional parameters:

Practical Examples

1. Mixing External Audio with an Existing Video’s Audio

To mix background music from an external MP3 file into a video file that already has an audio track, you can combine amovie with the amix filter inside -filter_complex:

ffmpeg -i input_video.mp4 -filter_complex "amovie=background.mp3[bg]; [0:a][bg]amix=inputs=2:duration=first[out]" -map 0:v -map "[out]" -c:v copy output.mp4

2. Delaying the Start of External Audio Using Seek Point

If you want to use an external audio track but start playing it from the 15-second mark of that audio file, use the seek_point parameter:

ffmpeg -i input_video.mp4 -filter_complex "amovie=audio.wav:seek_point=15[bg]; [0:a][bg]amix=inputs=2[out]" -map 0:v -map "[out]" output.mp4

3. Replacing Video Audio Entirely

You can also use the amovie filter to completely replace the audio of a video file with an external audio source:

ffmpeg -i input_video.mp4 -filter_complex "amovie=new_audio.ogg[aud]" -map 0:v -map "[aud]" -c:v copy output.mp4

This command ignores the original video’s audio track, streams the audio from new_audio.ogg via the amovie source, and maps it directly alongside the copied video stream (-c:v copy).