lossless-cut icon indicating copy to clipboard operation
lossless-cut copied to clipboard

Delay or advance (shift/sync) individual tracks (+- seconds)

Open zaza42 opened this issue 5 years ago • 13 comments

Please add an option for setting audio delay, a.k.a. changing a/v sync!

Edit by @mifi :

Seems this can be done with -itsoffset:

  • https://superuser.com/questions/982342/in-ffmpeg-how-to-delay-only-the-audio-of-a-mp4-video-without-converting-the-au
  • https://trac.ffmpeg.org/wiki/UnderstandingItsoffset
  • https://wjwoodrow.wordpress.com/2013/02/04/correcting-for-audiovideo-sync-issues-with-the-ffmpeg-programs-itsoffset-switch/

zaza42 avatar Nov 04 '19 16:11 zaza42

Then we need to -ss differently for audio vs video. Not sure if this is easy. Maybe something like this: https://stackoverflow.com/questions/55147398/how-to-specify-an-offset-and-a-seek-position-for-a-video-stream-of-a-mp4-contain

Update: https://wjwoodrow.wordpress.com/2013/02/04/correcting-for-audiovideo-sync-issues-with-the-ffmpeg-programs-itsoffset-switch/

mifi avatar Feb 11 '20 16:02 mifi

@mifi : Yes, this is what i exactly use.

Another solution with small tempfile: https://superuser.com/a/1307386/607525

zaza42 avatar Feb 12 '20 06:02 zaza42

Searched exactly the same. My use case: I have screencast without audio and audio corresponded to screencast. Audio begins with several seconds of silence and should be synced with video before merging. It will be super-nice to have this feature. Sometimes audio also have a little bit high speed that video (several seconds after several hours) and should be scaled but this is not so common case I think.

chasylexus avatar Jun 08 '20 12:06 chasylexus

https://wjwoodrow.wordpress.com/2013/02/04/correcting-for-audiovideo-sync-issues-with-the-ffmpeg-programs-itsoffset-switch/

mifi avatar Dec 11 '20 15:12 mifi

I need this option very much ! I often shot badminton matches, each time result in mp4 files usually 40GB+ per file. However, I used bluetooth audio devices, so that audio is 200ms later than video. And I need to cut each file into 200+ segments for later use.
I used LosslessCut to cut the original file, but in each segment the audio is still delayed 200ms. The solution I'm now using is that first I use mkvtoolnix to create a temp file, also 40GB+, and cut the mkv file in LosslessCut. This procedure really costs too much time and disk space. So I wish LosslessCut could provide an option to delay an audio track some miliseconds, with a positive or negative number.

Binger-cn avatar Aug 16 '21 03:08 Binger-cn

FYI @gyarmish posted a manual workaround for adjusting individual tracks, see https://github.com/mifi/lossless-cut/issues/929#issue-1053948979

mifi avatar Jan 11 '22 16:01 mifi

Thanks for that mention mifi.

In addition to its usefulness - part of the reason for the post was to show how it can be implemented in a new release - its quite tedious manually but it can be automate this behind the scenes using the standard lossless functions.

Imagine having to do that for multiple short videos. It will get done but but if those steps can be programmed in it would be very useful.

gyarmish avatar Jan 11 '22 17:01 gyarmish

Yes if I cannot find a way for ffmpeg to shift the offsets, then extracting, cutting and re-importing individual tracks like you outlined could be a workaround however I would imagine that it's much slower (more CPU/resources) than letting ffmpeg do it internally

mifi avatar Jan 12 '22 05:01 mifi