I am trying to trim a video shoot on an iPhone.
When I execute:
ffmpeg -i IMG_8555.MOV \
-filter_complex " \
[0:v] select='between(t,448.856,1279.240)', setpts=N/FR/TB; \
[0:a] aselect='between(t,448.856,1279.240)', asetpts=N/SR/TB \
" \
output.mov
the output audio is out of sync - audio is faster (noticeable towards the end of the output video).
I noticed that the outputs frame rate is 29.97 while the inputs is 29.98.
So I did some experimenting and changed setpts to setpts=N/29.98/TB;
but still the video is falling behind.
So I changed it even more to setpts=N/30.00/TB;
- then it feels almost ok.
I tired adding -vsync 1 - no luck
I tried adding -async 1 - no luck
I tried adding -async 7000 - no luck
edit: If i put setpts=N/29.99/TB then it is ideal.
Any ideas how can I make it always synced (no matter what is the input)?
Try this:
ffmpeg -ss 448.86 -to 1279.240 -i IMG_8555.MOV output.mov
<addendum>
If you have more cuts, then you can try one of the following 2 approaches:
ffmpeg -ss 0 -to 1 -i IMG_8555.MOV \
-ss 4 to 5 -i IMG_8555.MOV \
...
-ss 448.86 -to 1279.240 -i IMG_8555.MOV \
-filter_complex [0:v][0:a][1:v][1:a]...[99:v][99:a]concat
output.mov
concat
demuxer. First create a concat file, name it say IMG_8555_trim.ffconcat
and save it on the same folder as the video fileffconcat version 1.0
file IMG_8555.MOV
inpoint 0
outpoint 1
file IMG_8555.MOV
inpoint 4
outpoint 5
...
file IMG_8555.MOV
inpoint 448.86
outpoint 1279.240
then run
ffmpeg -i IMG_8555_trim.ffconcat output.mov