Skip to content

Commit

Permalink
Add aresample flag to ffmpeg conversion command
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbreyfogle committed Oct 23, 2024
1 parent 394c849 commit 13c61ce
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion audiotools/core/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,14 @@ def load_from_file_with_ffmpeg(cls, audio_path: str, quiet: bool = True, **kwarg

ff = ffmpy.FFmpeg(
inputs={audio_path: None},
outputs={wav_file: None},
# For inputs that are m4a (and others?), the input audio can
# have samples that don't match the sample rate. This aresample
# option forces ffmpeg to read timing information in the source
# file instead of assuming constant sample rate.
#
# This fixes an issue where an input m4a file might be a
# different length than the output wav file
outputs={wav_file: "-af aresample=async=1000"},
global_options=global_options,
)
ff.run()
Expand Down

0 comments on commit 13c61ce

Please sign in to comment.