Question

I need to implement two features:

  1. replace the audio in the movie
  2. mix the current audio with a new one

Solution for 1:

ffmpeg -i music_url -i video_url -codec copy -y -shortest output_video

Solution for 2:

ffmpeg -i video_url -i music_url -filter_complex amix=duration=shortest -y output_video

But there are a few problems with 2nd:

  • Video is lower quality
  • audio is cut the the shortest one, but video stays the same
  • takes longer that copy streams

Any hints?

EDIT:

ffmpeg -i vid -i music -filter_complex amix=duration=shortest -shortest -y out_v

Seems it's not possible to stream copy video and filter audio. Need to figure out how to keep the video with the same quality, because the default behaviour lowers it.

Was it helpful?

Solution

It's not possible to filter stream and copy it, but in this case I copy video and filter audio. Solution:

ffmpeg -i v -i m -filter_complex amix=duration=shortest -vcodec copy -shortest -y out_v

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top