Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-encode flac files in order to preserve duration #1809

Closed
mifi opened this issue Dec 6, 2023 · 6 comments
Closed

Re-encode flac files in order to preserve duration #1809

mifi opened this issue Dec 6, 2023 · 6 comments

Comments

@mifi
Copy link
Owner

mifi commented Dec 6, 2023

When trimming flac files using copy the duration doesn't get updated and remains as the original. Only happens with flac audio files. This is a bug in ffmpeg that seems will not be fixed. So we could workaround it by re-encoding flac (because it is lossless even when encoding, even though slower)

Originally posted by @hazerflac7 in #1320

@sahiljr-111
Copy link

This can be done by converting them to a different format and then back to FLAC.

  1. convert the FLAC file to a .wav -> ffmpeg -i original.flac -c:a pcm_s24le intermediate.wav
  2. trim the file -> ffmpeg -ss start_time -i intermediate.wav -to end_time -c:a pcm_s24le trimmed_intermediate.wav
  3. convert trimmed file to FLAC -> ffmpeg -i trimmed_intermediate.wav -c:a flac final_trimmed.flac

@Freso
Copy link

Freso commented Feb 19, 2024

Those specific commands would drop any metadata from the FLAC though, though I guess there are ways to add that back.

Is there an upstream (ffmpeg) issue/ticket for this?

@mifi
Copy link
Owner Author

mifi commented Feb 21, 2024

@sahiljr-111
Copy link

@Freso you can use additional options to copy the metadata from the original FLAC file to the final trimmed FLAC file

@mifi mifi changed the title Re-encode flac files Re-encode flac files in order to preserve duration Aug 7, 2024
@mifi mifi closed this as completed in e7d2caf Aug 27, 2024
@Gevaarlijk
Copy link

I've found an app called Audacity that cuts flacs the way it should without messing up the times.

@mifi
Copy link
Owner Author

mifi commented Aug 27, 2024

losslesscut can also do it now, if you want you can test it in the latest nightly build: https://github.com/mifi/lossless-cut/actions/runs/10585664608

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

No branches or pull requests

4 participants