Audio distortion when split

Windows 10 with Shotcut version 21.06.29

I made a sine wave in Audacity and exported it as FLAC. I imported it in Shotcut, put it on an audio track, split it in 10 places, then exported it using the FLAC preset. It is distorted in many places, and the waveform is visibly distorted in some places when put back into Audacity to analyze it.

Also this is unrelated to splitting audio, but the file was inexplicably 48 ms longer whether it was split or not.

Reproduced. There appears to be an issue with FLAC reading. FLAC writing seems to be fine.

Test methodology (21.06.29 on Linux Mint):

  1. Create a new timeline. (I used 1080p 29.97fps.) Then, File > Open Other > Audio Tone > 1000Hz @ -6 dB. Trim down to five seconds in Source, then export as both FLAC and WAV. These exports are perfect, suggesting that FLAC writing is fine.

  2. Create a new timeline. Bring in the WAV file from Step 1 and split it every half second. Export as both FLAC and WAV. Both exports will have a single discontinuity at the half-second mark. The rest is perfect. The discontinuity persists even with non-fractional frame rates, so that’s a separate issue.

  3. Create a new timeline. Bring in the FLAC file from Step 1 and split it every half second. Export as both FLAC and WAV. Both exports have many discontinuities, and not just at the half-second marks. The only difference compared to Step 2 is the use of FLAC as a source rather than WAV. So I’m guessing there is a problem with FLAC reading or seeking.

“FLAC” means I tested the FLAC codec in both Matroska .mka and raw .flac containers. Same issues with both.

An image of a discontinuity, predictably at 2.002ms given the 29.97fps, shown in Ocenaudio:

What is the audio sampling rate of the source file and the export file? If a sampling rate conversion is occurring, there will be discontinuities at cut points.

I was using 48 kHz for the project rate and export sample rate in Audacity, and 48 kHz in Shotcut.

Same here… 48kHz all the way through to eliminate variables.

When I follow the instructions, I see and hear a discontinuity at exactly the split points, but no where else. I use audacity to inspect the export file:

image

Audacity uses ffmpeg to convert (import) the .mka file from Shotcut.

I think that a discontinuity at the split point is expected since seeking in FLAC is not sample accurate. But your report that you hear discontinuity in spots that are not a split point?

When I listen to the exported FLAC file, I can hear about 12 discontinuities, some at irregular intervals. I heard one between the 1.5s and 2.0s marks, zoomed in, and quickly found an example at 1.835ms:

EDIT: This was exported from a .flac source, not a .mka source, which I now know makes a difference. This blip will not exist with .mka sources.

I was under the impression that FLAC in a raw .flac container may not be sample accurate, but I thought FLAC in Matroska would have PTS available for accuracy. (I didn’t deeply research it… I kinda assumed.) If this isn’t the case, then what about adding “FLAC isn’t sample accurate” to the Shotcut FAQ due to its popularity? And possibly offering to convert to edit-friendly on import?

Sorry for the confusion… I see a difference now.

Solid tone project > Export as FLAC in Matroska container > New project > Import that .mka file > Split > Export → Blips only at the half-second marks

Solid tone project > Export as FLAC in raw .flac container > New project > Import that .flac file > Split > Export → Many blips at irregular intervals

So it seems that FLAC in Matroska is more accurate than raw .flac, but neither seeks perfectly. If the OP was importing .flac files from other editors, then this could account for discontinuities at places other than the split points.

By “raw .flac”, I mean changing the Format to flac in the Export panel.

I tried tests with some other formats. Most audio formats will have some discontinuities. AC3 seems to do the best.

This was not my experience. In my testing, .flac and .mka behaved the same. They only had discontinuities at the split and nowhere else. Maybe I am still not recreating the same circumstance.

In my testing many formats behave the same. So it would become a list.