How to combine .mp4 video with .wav audio with offset in ffmpeg from command line?

I have a mp4 TV clip containing audio and video, as well as a WAV audio track.

I am trying to combine them into ffmpeg and then play online using a flash player (which can only accept h264 format)

What is the best ffmpeg team for this? My inputs are MP4 video, WAV audio and the offset in seconds, the time that the audio comment starts relative to the start of the mp4 video.

I tried

ffmpeg -i input_audio.wav -i input_vid.mp4 -vcodec copy output.mp4 

and

 ffmpeg -vcodec copy -ss offset -i input_audio.wav -i input_video.mp4 output.mp4 

the bottom one does what I want and outputs the h264 video which is good for flash players. Is there a way to do this from the command line in ffmpeg?

+7
source share
1 answer

In the ffmpeg audio file, audio recording can be delayed using the -itsoffset option as follows:

 ffmpeg -i input_vid.mp4 -itsoffset 00:00:05.0 -i input_audio.wav -vcodec copy -acodec copy output.mp4 

To change video or audio codecs, specify them in the -vcodec and -acodec . This command will output video using h264 and mp3:

 ffmpeg -i input_vid.mp4 -itsoffset 00:00:05.0 -i input_audio.wav -vcodec libx264 -acodec libmp3lame output.mp4 

See audio or video delay for more information.

+12
source

All Articles