0

I'm trying hard for more than a day to fit an audio into a video, which is almost an hour long and the audio is just 2-3 minutes shorter than that. The video has it'0s own audio but I don't want it since the external audio I got has more quality and more channels.

The video has a 25 fps framerate while the external audio has 23.976. I've tried ffmpeg but to no avail. Also the audio stretching has to be precise so the sound match people's lips. Is there a way to tell ffmpeg "see this video duration? stretch the audio to that exact duration to the second (or milisecond) and embed it" ?

I've tried MP4box, Avidemux, Handbrake and now FFmpeg (pretty complicated), and my head is exploding :P Anyone that can help me on this? I can't believe it can't be done

Thanks in advance

  • What ffmpeg command have you tried? – Gyan Mar 22 '17 at 19:50
  • I tried this: `ffmpeg -i x:\video.mp4 X:\external_audio.m4a -c:a aac -strict -2 -b:a 128k -af atempo=0.95 output.mp4` But it never gets the time right, besides it's recompressing the audio again but I can remove the encoding part later – Pedro Coimbra Mar 22 '17 at 20:30
  • You should probe the specific duration for both the audio and video streams and supply that as a rational number to the atempo. `ffprobe -show_entries stream=duration -of compact -v 0 video.mp4` and also run that for the m4a. Add `-map 0:v -map 1:a` to the ffmpeg command. – Gyan Mar 22 '17 at 20:51
  • Ok, didn't know that. I tried that and as expected, the external audio has a 100-and-something less seconds than the video (3623 vs 3745). Sould I divide them like 3623 / 3745 and do `-atempo=0.9674233` ? (This damn editor keeps considering 'enter' as a send button, just like facebook.) – Pedro Coimbra Mar 22 '17 at 22:13
  • Thanks for your help so far by the way :-) – Pedro Coimbra Mar 22 '17 at 22:17
  • Yes, try with that value. – Gyan Mar 23 '17 at 04:38
  • @Mulvya I'm running into dificulties here. With the _-atempo_ the incremental out-of-sync is now corrected, but there's still a fixed delay of 1 sec, which I tried to fix with the `-itsoffset=00:00:1.0`, but now it took more than 2 hours to encode, and the delay remains. I thought the longer time was because of _itsoffset_, but even without that option it still takes forever, and it didn't yesterday with other _-atempo_ tries I did. Today I tried without the itsoffset: `ffmpeg -i "original_video.mp4" -i "external_audio.wav" -af atempo=0.9674233 -c:a aac -strict -2 -b:a 128k output.mp4` – Pedro Coimbra Mar 23 '17 at 20:03
  • ...and considering the time it took, it's like it's encoding the video too. Some or the switches may be in the wrong order. So, can you please paste here an example that can: 1) join a mp4 video with an external audio (either a WAV with encoding options, or an M4A just for embedding) 2) from the mp4, copy the video stream only (I want the external audio only) 3) use the _-af atempo=_ and the _-itsoffset=_ – Pedro Coimbra Mar 23 '17 at 20:04
  • Sorry for that but I'm really getting fed up with this thing (I was even before I posted this here), and it's taking me too many hours of my life and I'm on the brink of deleting this whole thing and not turn on the computer again in the next weeks :P – Pedro Coimbra Mar 23 '17 at 20:06
  • To skip re-encoding video, add `-c:v copy`. – Gyan Mar 24 '17 at 03:03
  • I'll try that (busy day, I could only reply now) Thanks – Pedro Coimbra Mar 24 '17 at 19:20
  • @Mulvya Thank you very much, it worked :) – Pedro Coimbra Mar 28 '17 at 18:23

0 Answers0