nschlia / ffmpegfs

FUSE-based transcoding filesystem with video support from many formats to FLAC, MP4, TS, WebM, OGG, MP3, HLS, and others.
https://nschlia.github.io/ffmpegfs/
GNU General Public License v3.0
196 stars 14 forks source link

Splitting FLAC Into Tracks Without Transcoding? #124

Open Martin2112 opened 2 years ago

Martin2112 commented 2 years ago

Hi,

I'm not saying this is a bug as I might be doing something wrong but I'd expect to be able to split album FLAC files into tracks without transcoding with something like:

/usr/local/bin/ffmpegfs \
        -f \
        --log_stderr \
        --log_maxlevel=DEBUG \
        --autocopy=MATCH \
        --prebuffer_size=2M \
        --cachepath=/var/cache \
        --min_diskspace=5G \
        /export/cdrip/flac \
        /export/cdrip/flactrack \
        -o allow_other,ro,desttype=flac

However, it seems to be behaving strangely. When I look at the directory:

ls -l /export/cdrip/flactrack/Music/Rush/Rush\ -\ Power\ Windows.flac.tracks/
total 0
-rwxr--r--. 1 martin martin 0 Mar  7 18:28 '01. Rush - The Big Money [05-36.226].flac'
-rwxr--r--. 1 martin martin 0 Mar  7 18:28 '02. Rush - Grand Designs [05-05.240].flac'
-rwxr--r--. 1 martin martin 0 Mar  7 18:28 '03. Rush - Manhattan Project [05-05.000].flac'
-rwxr--r--. 1 martin martin 0 Mar  7 18:28 '04. Rush - Marathon [06-09.160].flac'
-rwxr--r--. 1 martin martin 0 Mar  7 18:28 '05. Rush - Territories [06-19.466].flac'
-rwxr--r--. 1 martin martin 0 Mar  7 18:28 '06. Rush - Middletown Dreams [05-15.466].flac'
-rwxr--r--. 1 martin martin 0 Mar  7 18:28 '07. Rush - Emotion Detector [05-10.333].flac'
-rwxr--r--. 1 martin martin 0 Mar  7 18:28 '08. Rush - Mystic Rhythms [06-01.880].flac'

When I try to play these files in VLC they usually remain empty and I get an error. I can see some activity in the debug log. Sometimes it seems to work and I see a transcoding thread running in the debug output, which wasn't expected.

Also when restarting the files go back to zero bytes, should the cache not have provided file size for these? E.g. after this:

2022-03-14 17:55:23 DEBUG  : [/export/cdrip/flac/Music/Rush/Rush - Power Windows.flac.tracks/01. Rush - The Big Money [05-36.226].flac] Preparing next file: /export/cdrip/flac/Music/Rush/Rush - Power Windows.flac.tracks/02. Rush - Grand Designs [05-05.240].flac
2022-03-14 17:55:23 DEBUG  : [/var/cache/ffmpegfs/export/cdrip/flactrack/export/cdrip/flac/Music/Rush/Rush - Power Windows.flac.tracks/01. Rush - The Big Money [05-36.226].flac.cache.flac] Reading cache file.

The file still shows up as zero bytes. The cache is populated:

[root@zen martin]# ls -l /var/cache/ffmpegfs/export/cdrip/flactrack/export/cdrip/flac/Music/Rush/Rush\ -\ Power\ Windows.flac.tracks/
total 286096
-rw-r--r--. 1 martin martin 38786328 Mar 14 17:55 '01. Rush - The Big Money [05-36.226].flac.cache.flac'
-rw-r--r--. 1 martin martin 35401186 Mar 14 17:30 '02. Rush - Grand Designs [05-05.240].flac.cache.flac'
-rw-r--r--. 1 martin martin 33297260 Mar 14 17:24 '03. Rush - Manhattan Project [05-05.000].flac.cache.flac'
-rw-r--r--. 1 martin martin 40590110 Mar 14 17:23 '04. Rush - Marathon [06-09.160].flac.cache.flac'
-rw-r--r--. 1 martin martin 39808072 Mar 14 17:24 '05. Rush - Territories [06-19.466].flac.cache.flac'
-rw-r--r--. 1 martin martin 34131653 Mar 14 17:24 '06. Rush - Middletown Dreams [05-15.466].flac.cache.flac'
-rw-r--r--. 1 martin martin 33206500 Mar 14 17:24 '07. Rush - Emotion Detector [05-10.333].flac.cache.flac'
-rw-r--r--. 1 martin martin 37395713 Mar 14 17:28 '08. Rush - Mystic Rhythms [06-01.880].flac.cache.flac'

If I change desttype to 'mp3' then everything seems to work properly, though with delays for transcoding.

nschlia commented 2 years ago

Cue sheets without transcoding are not implemented. This one totally escaped me, --autocopy=MATCH should not trigger copy when a cue sheet exists. I'll add a check and automatically transcode in that case. It could even be possible to retrack without transcoding, but this is rather complicated: For mp3 it would require at least partially recoding (at the start end of of tracks), not sure what FLAC requires, that'll be an enhancement.

As a work around you should remove the autocopy parameter and set --recodesame=YES instead.

Martin2112 commented 2 years ago

OK thanks. I'll try making those changes.

From what I understand from the FLAC spec it would be the same process as MP3 as the offsets are in terms of decoded frames.

Martin2112 commented 2 years ago

That does work better. I still have issues where some FLAC files produce zero length tracks. While looking into that I came across another CUE sheet parsing issue. I'll create an issue for that and try to propose a fix.

nschlia commented 2 years ago

That does work better. I still have issues where some FLAC files produce zero length tracks. While looking into that I came across another CUE sheet parsing issue. I'll create an issue for that and try to propose a fix.

Thanks. Looking forward to it.