Skip to content

Conversation

MoSal
Copy link
Contributor

@MoSal MoSal commented Sep 29, 2025

I've seen this come up the other day, and it piqued my interest. It's in a "WORKS FOR ME" state. But I'm not familiar with this filter code. Feedback and/or testing would be appreciated.


Implement ffscaletempo audio filter, which uses atempo or ascale
form libavfilter for setting the tempo.

Users (myself included) seem to be always looking for alternative tempo
scalers to try, and this provides a faster implementation (or two), and
may prove useful beyond performance/speed.

atempo is picked as a default, and as a fall-back if ascale is not
available.

Copy link

github-actions bot commented Sep 29, 2025

@sfan5
Copy link
Member

sfan5 commented Sep 29, 2025

Why not just use -af atempo=1.2 directly?

@MoSal
Copy link
Contributor Author

MoSal commented Sep 29, 2025

@sfan5 Because of the timestamps/sync!

@kasper93
Copy link
Member

nitpick about naming, I would rather use lavfi prefix, instead of ff.

@MoSal
Copy link
Contributor Author

MoSal commented Sep 30, 2025

nitpick about naming, I would rather use lavfi prefix, instead of ff.

That can be changed. But I will wait for more feedback (if any) first.

I didn't choose lavfi as a prefix from the start because I was concerned users may confuse it for the non-existing lavfi=scaletempo (It would be even worse if it existed).

@kasper93
Copy link
Member

kasper93 commented Sep 30, 2025

The point is ffmpeg is CLI tool, which is carried to the project name, but you are not really using ffmpeg here. But whatever really.

Scales audio tempo using ``atempo`` or ``ascale`` filters from FFmpeg's
libavfilter.

If ``ascale`` (Librempeg only) is not available in the loaded
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of mentioning home grown ffmpeg forks, just say it accepts filters like atempo so you don't have to go around documenting every fork that implements a pitch correction filter in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I opted to support specific filters because I can, and did, test them.
  • Non filter-specific support will require making both the filter name and filter tempo argument exposed to users. ascale and atempo just happened to use the same argument, and if they didn't, it's a minor code change. Non filter-specific support would add too much flexibility, complexity, and as a result non-reliability, IMHO.
  • This filter obviously doesn't add build-time or run-time dependency on librempeg. It just optionally supports internally a filter implemented there if available at run-time, like you can optionally pass such filters with lavfi=<some_filter>.

@MoSal
Copy link
Contributor Author

MoSal commented Sep 30, 2025

Renamed to lavfi-tempo.

 Implement `lavfi-tempo` audio filter, which uses `atempo` or `ascale`
 form libavfilter for setting the tempo.

 Users (myself included) seem to be always looking for alternative tempo
 scalers to try, and this provides a faster implementation (or two), and
 may prove useful beyond performance/speed.

 `atempo` is picked as a default, and as a fall-back if `ascale` is not
 available.

Signed-off-by: Mohammad AlSaleh <[email protected]>
@MoSal
Copy link
Contributor Author

MoSal commented Oct 2, 2025

Simplified the code so the out frame just gets its PTS from the in frame directly, so no special handling is needed in case of pts jumps, and no filter resets are needed if the speed changes.

This assumes "1 frame in, 1 frame out" between pins will always hold true, which seems to be the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants