mifi / editly

Slick, declarative command line video editing & API
MIT License
4.64k stars 295 forks source link

Timing Issue #192

Closed jnorthard closed 2 years ago

jnorthard commented 2 years ago

I'm attempting to sync slides to music and I'm noticing that the slides are showing up faster than what is desired from the duration settings. In the example below TEXT ONE & TEXT TWO show up in the desired time, but all of the others show up a few seconds before the desired time.

TEXT THREE is showing up at 26 seconds when it should be showing up at 28.3 seconds (19.6+2+2.1+4.6). Am I misunderstanding the duration setting or is the video rendering faster than the audio?

I've tried several versions of ffmpeg and the results are the same. I've also tried rendering on a PC and Mac with the same results.

{
  width: 600, height: 400, fps: 30,
  outPath: './test.mp4',
  audioFilePath: '3am.mp3',
  defaults: {
    layer: { fontPath: './assets/Patua_One/PatuaOne-Regular.ttf' },
  },
  clips: [
    { duration: 19.6, layers: [{ type: 'image', path: 'image.jpg', resizeMode: 'cover'  }]},
    { duration: 2, layers: [{ type: 'image', path: 'image.jpg', resizeMode: 'cover'  }, { type: 'title', text: 'TEXT ONE'}]},
    { duration: 2.1, layers: [{ type: 'image', path: 'image.jpg', resizeMode: 'cover' }, { type: 'title', text: 'TEXT TWO'}]},
    { duration: 4.6, layers: [{ type: 'image', path: 'image.jpg', resizeMode: 'cover'  }]},
    { duration: 4.1, layers: [{ type: 'image', path: 'image.jpg', resizeMode: 'cover' }, { type: 'title', text: 'TEXT THREE'}]},
    { duration: 4.9, layers: [{ type: 'image', path: 'image.jpg', resizeMode: 'cover'  }]},
    { duration: 4.2, layers: [{ type: 'image', path: 'image.jpg', resizeMode: 'cover' }, { type: 'title', text: 'TEXT FOUR'}]},
    { duration: 3, layers: [{ type: 'image', path: 'image.jpg', resizeMode: 'cover'  }]},
    { duration: 3.8, layers: [{ type: 'image', path: 'image.jpg', resizeMode: 'cover' }, { type: 'title', text: 'TEXT FIVE'}]},
    { duration: 4.6, layers: [{ type: 'image', path: 'image.jpg', resizeMode: 'cover' }, { type: 'title', text: 'TEXT SIX'}]},
  ],
}
mifi commented 2 years ago

Hi! I think the reason why you're seeing this behaviour is because of transitions. e.g. transitions will cut into the clips durations, so your calculation needs to add the transition times.

you can set defaults.transition to null to disable all transitions.

jnorthard commented 2 years ago

Brilliant - thank you!