beek
beek

Reputation: 3750

FFMpeg Shorten Audio Input

I'm trying to syncronise some audio with video - the audio is recorded via an App in the M4U format, at the same time as the recording starts 2 cameras are triggered and start recording. When the recording stops both the audio and cameras stop recording. Now these are out by quite a bit, like at least a second. The file time lengths are the same, but the audio clearly starts recording earlier then the video.

I'm trying to syncronise these and I can do it manually in Audacity, but I'd like to try and get it close via FFMEG.

I've been having a good look around and can find commands for delaying the start of the audio track, but not cutting off the first few seconds of the Audio. I'm trying something like this

ffmpeg -framerate 24 -i .\seq\%%04d.jpg -itsoffset -3 -i audio.m4u -map 0:v -map 1:a -c:v libx264  -pix_fmt yuv420p -c:v libx264 -crf 23 -profile:v high -movflags faststart -b 5000k -shortest out.mp4

Any clues how to remove the first few seconds form the audio input?

Upvotes: 0

Views: 142

Answers (1)

Gyan
Gyan

Reputation: 93018

The atrim filter does just that:

ffmpeg -framerate 24 -i .\seq\%%04d.jpg -i audio.m4u -map 0:v -map 1:a -af atrim=3,asetpts=N/SR/TB -c:v libx264  -pix_fmt yuv420p -c:v libx264 -crf 23 -profile:v high -movflags faststart -shortest out.mp4

The asetpts is added to reset the timestamps of the trimmed audio.

Upvotes: 1

Related Questions