Skip to content

Merge video and audio with ffmpeg

u/pukkandan:

ffmpeg -i video.mp4 -i audio.m4a -c copy output.mp4

ChatGPT:

To merge a video file and an audio file using ffmpeg, you can follow these steps:

  1. Open your command prompt or terminal.
  2. Navigate to the directory where your video and audio files are located using the cd command.
  3. Use the ffmpeg command to merge the video and audio files. The basic syntax for merging is:

    ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -c:a aac output.mp4
    
    • Replace video.mp4 and audio.mp3 with the names of your video and audio files.
    • -c:v copy tells ffmpeg to copy the video stream without re-encoding it.
    • -c:a aac tells ffmpeg to use the aac audio codec for the output.
    • output.mp4 is the name of the merged file. You can replace it with any name you like.
  4. Press Enter to execute the command.

  5. Wait for ffmpeg to complete the merging process. This may take some time depending on the length and size of your video and audio files.
  6. Once the process is complete, check the output file to ensure that the video and audio have been merged successfully.

Note: The above command assumes that your input files have compatible codecs and parameters. If not, you may need to adjust the command to specify additional options such as the video bitrate, resolution, or audio sampling rate.