mifi / lossless-cut

The swiss army knife of lossless video/audio editing
https://losslesscut.app/
GNU General Public License v2.0
27.9k stars 1.35k forks source link

Problems splitting certain audio files #2140

Open Mrnofish opened 2 months ago

Mrnofish commented 2 months ago

The fewer issues I have to read, the more new features I will have time to implement, so I ask that you please try these things first

Operating System

Windows 10

Steps to reproduce

  1. Split audio file in one of the format mentioned below, three parts should be sufficient.
  2. Verify Integrity (under Windows I've used foobar2000)

Expected behavior

Split files should pass integrity checks.

Actual behavior

Depending on the format, various warnings are triggered. I've tested four:

Opus files have small differences (some millisecs) versus the reported lengths.

FLAC has the MD5 and length of the original file.

I didn't report this through the specific format form since it happens with at least two and possibly more formats. I haven't looked into ffmpeg to figure whether this is an issue with the build or version that LosslessCut is using, or perhaps it having a rough/incomplete implementation for audio splitting.

I've verified this happens both with 3.61 and 3.62.

Disabling Keyframe Cut eliminates the granulepos is nonsense warning but inaccurate lengths remain.

Share log from developer tools

No response

mifi commented 2 months ago

FLAC has the MD5 and length of the original file.

this is a bug in ffmpeg where it doesn't update the length when cutting. I've fixed it (upcoming version) with a workaround which is to actually re-encode the flac (which is lossless because flac is a lossless codec) see #1809

Disabling Keyframe Cut eliminates the granulepos is nonsense warning

that's interesting.

the OPUS problem is probably also a bug in ffmpeg, so not much that can be done here i think

Mrnofish commented 2 months ago

ffmpeg outputting partially broken files not being their problem is a pretty dizzying deflection. Is LosslessCut using the --copy option for Opus, too?

Are you aware of any library/tool that can rebuild Opus files? opustools doesn't seem to provide any.

mifi commented 2 months ago

ffmpeg outputting partially broken files not being their problem is a pretty dizzying deflection. Is LosslessCut using the --copy option for Opus, too?

i meant to say that there's not much i can do, because i don't know the internal implementation details of ffmpeg nor do i know much about the opus codec. but surely if someone wants to fix it, that would be great.

Is LosslessCut using the --copy option for Opus, too?

yes

Are you aware of any library/tool that can rebuild Opus files? opustools doesn't seem to provide any.

no

Mrnofish commented 2 months ago

Oh, I got that and wasn't blaming you ...that would be madness!

I was referring to the reply provided on the first ffmpeg ticket linked in #1809 which argues that, since the --copy option only copies stuff, then it's okay for the length of the output file to be incorrect, thus transferring the burden of detecting and solving any problem on the user and/or another piece of software. Never mind that splitting a file isn't making a straight copy.

Apologies for any confusion.

Since I assume you have a certain experience with ffmpeg bugs and reporting them, any chance that upstream would fix Opus related bugs if a ticket were to be opened?

mifi commented 2 months ago

Ahh ok, no worries.

TBH I haven’t reported too many bugs upstream but there are some other llc users who have done it in the past. If you’re able to find a simple ffmpeg command that can reproduce the problem with a small opus file, I’m sure it’s worth trying to report it. (Assuming it hasn’t already been reported like the flac issue)