Skip to content

Commit

Permalink
fix: ffmpeg v6 does not support VFR mode with a fixed framerate
Browse files Browse the repository at this point in the history
This change keeps the existing VFR behaviour when the framerate is not set.

Note vsync=2 is the old syntax for pfs_mode=vfr.
  • Loading branch information
rprieto committed Nov 27, 2023
1 parent b43aee9 commit fdfccd7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/video/ffargs.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ exports.prepare = function (source, target, options) {
// output framerate
if (options.framerate !== 0) {
args.push('-r', options.framerate || DEFAULT_VIDEO_FPS)
} else {
args.push('-fps_mode', 'vfr')
}

// misc options
args.push('-vsync', '2', '-movflags', '+faststart')
args.push('-movflags', '+faststart')

// remove metadata if required
if (options.keepMetadata) {
Expand Down
9 changes: 8 additions & 1 deletion test/unit/ffargs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,25 @@ describe('ffargs', () => {
const args = ffargs.prepare('source.mts', 'target.mp4', {})
const str = args.join(' ')
should(str).match(/-r 25/)
// these are not compatible with -r anymore with ffmpeg v6
// we simply default to -fps_mode=auto
should(str).not.match(/-vsync/)
should(str).not.match(/-fps_mode/)
})

it('can specify a value', () => {
it('can specify a framerate value', () => {
const args = ffargs.prepare('source.mts', 'target.mp4', { framerate: 60 })
const str = args.join(' ')
should(str).match(/-r 60/)
should(str).not.match(/-vsync/)
should(str).not.match(/-fps_mode/)
})

it('keeps the source framerate if set to 0', () => {
const args = ffargs.prepare('source.mts', 'target.mp4', { framerate: 0 })
const str = args.join(' ')
should(str).not.match(/-r/)
should(str).match(/-fps_mode vfr/)
})
})
})

0 comments on commit fdfccd7

Please sign in to comment.