ffmpeg recompile video and voice

0

I am using Ubuntu vivid on my laptop and I want to recompile audio and voice with delayed audio. Movie was late comparing to audio. I demuxed voice.aac and video.h264 from orginal video. I know that it is possible via editing aac but this file doesnt need any mod for aac. Just wanna delay audio.

makgun

Posted 2015-07-01T15:31:56.320

Reputation: 305

Answers

1

The -itsoffset option should do what you want:

-itsoffset offset (input)

Set the input time offset.

offset must be a time duration specification, see (ffmpeg-utils) the Time duration section in the ffmpeg-utils(1) manual.

The offset is added to the timestamps of the input files. Specifying a positive offset means that the corresponding streams are delayed by the time duration specified in offset.

So

$ ffmpeg -i video.h264 -itsoffset 1.0 -i voice.aac -map 0:a -map 1:v -c copy remuxed.mp4

should give an audio delay of 1 second. However, there might be container issues here, since ffmpeg is having to figure everything out from scratch.

What's better is if you do it using the original file:

 $ ffmpeg -i orig.mkv -itsoffset 1.0 -i orig.mkv -map 0:a -map 1:v -c copy remuxed.mkv

This applies a delay of 1 second (per the option to -itsoffset) to input 0, and no delay to input 1. The -map options specify to take the (delayed) audio from input 0 and the (non-delayed) video from input 1.

Hope that's clearer!


(If you wanted to delay the video instead, change the -map options:

 $ ffmpeg -i orig.mkv -itsoffset 1.0 -i orig.mkv -map 0:v -map 1:a -c copy remuxed.mkv

which specifies to take the delayed video, and the non-delayed audio)

bertieb

Posted 2015-07-01T15:31:56.320

Reputation: 6 181

Man this is what I need. I will try it when I go to home – makgun – 2015-07-01T16:05:07.107

Hope it works- I haven't tested. You may need to transcode rather than mux, but hopefully not! – bertieb – 2015-07-01T16:15:09.100

@makgun I have updated the answer with a better and tested option, assuming you still have the original file :) – bertieb – 2015-07-01T16:27:36.467

Thanks man this is more usefull than I need to use (at least I think like that) . And map 0:a means that is 0 second delayed Audio? And map 2:v means that is 2 seconds delayed Video? – makgun – 2015-07-01T16:44:19.740

1@makgun The delay is specified as the option to -itsoffset, 1.0 for 1 second, 0.125 for and 8th of a second etc. I have updated the answer to clarify this. – bertieb – 2015-07-01T17:36:26.917

1@bertleb thaks for usefull answer Ive learnt it as well. Now I can watch it without using special video player. – makgun – 2015-07-01T18:26:50.257

@bertleb Do you know how can rotate a video x degree (clockwise) I tried ffmpeg -i in.mp4 -vf "transpose=1" out.mp4 . But this option is so slow And then I added -c copy like ffmpeg -i in.mp4 -cc copy -vf "transpose=1" out.mp4. But again it is so slow. I think it re-encode it. Is there any option to make this fastly? – makgun – 2015-07-01T23:08:34.990

1Glad you got the answer to work :) Remember you can mark an answer as accepted by clicking the grey tick- no pressure though! About rotating, it is better to ask that as a separate question to avoid extended discussion in comments :) – bertieb – 2015-07-02T08:15:35.520