trackfs icon indicating copy to clipboard operation
trackfs copied to clipboard

mp3 support & fixes

Open izverev opened this issue 4 years ago • 6 comments

I've try to use ffmpegfs as you write in README, but cue support still in development, docker support not working without fixes, and I know python better than C++. So I've add mp3 support same as Andreas, with creating temporary file via mp3splt. I've changed, that virtual files always have .flac extension - now it takes from source file

Also fix situation when track have corrupted headers and Mutagen fails with Exception

this is my first pull request on github, so sorry if i'm wrong

izverev avatar Apr 08 '21 12:04 izverev

Hi izverev,

Thanks for the great contribution. I did not think about the use case of mp3 files that contain a full album. I was referring to ffmpegfs for transcoding flac/wav albums to mp3-tracks while splitting up. I think your solution fits nicely to trackfs and I'm mroe than happy to include it.

I did not find time to checkout out and test your code, but from quickly browsing your changes I believe you might have introduced a small bug: By now keeping the source-file extension from the original album file, wav-albums would now become wav-tracks. But since wav-tracks can't hold meta-data, trackfs compresses them into flac too. So the extension would in this case for have to remain .flac instead of .wav. Would you mind checking this?

I would also recommend to change version to 0.3.0. While your feature is not nessessarily a breaking change, it is still a significant addition that deserves a bigger version bump.

Let me know if you find time to do look into the topics. Otherwise I will try it myself, but this will take some time, as work currently doesn't leave me a lot of spare time.

Thanks again for your contribution Andreas

andresch avatar Apr 08 '21 16:04 andresch

Hi, Andreas

I was thinking about wav, but not checks if it will work with wav, because haven't such examples. I'm think you'r right and .wav virtual extension should be changed to .flac, I'll try to figure out, how to do it clearly

Also, unfortunately, I've catched some bugs with mp3splt while It works on my home server, so I need to test it little bit more But I'm happy to realize, that you like my Idea

Btw, why you not use ffmpeg-python, as acenko did before?

izverev avatar Apr 08 '21 16:04 izverev

Btw, why you not use ffmpeg-python, as acenko did before?

Two reasons:

  • I wanted to keep the container as small as possible (ffmpegfs is a quite huge package with tons of dependencies compared to flac)
  • I was hoping a would find a way to simply "extract" a track from an flac album without the need to re-encoding it as this would significantly increase the performance of trackfs. but unfortunately so far without success.

andresch avatar Apr 08 '21 17:04 andresch

  • I wanted to keep the container as small as possible (ffmpegfs is a quite huge package with tons of dependencies compared to flac)

one more reason, why I'm not like ffmpegfs, also they use debian as base in Dockerfile and I built it more than half an hour..))

  • I was hoping a would find a way to simply "extract" a track from an flac album without the need to re-encoding it as this would significantly increase the performance of trackfs. but unfortunately so far without success.

Unfortunately, I don't think it's possible, to figure out it we should look into FLAC compression algorithm. Maby it can works with wav...

izverev avatar Apr 08 '21 17:04 izverev

Unfortunately, I don't think it's possible, to figure out it we should look into FLAC compression algorithm. Maby it can works with wav...

I browsed a bit through the FLAC spec and from what I believe I understood a stream gets compressed in multiple independent chunks. So it might be possible to reuse most chunks and only re-compress the first and last chuck around the split points. But as I could not find any ready to use tool that does this already and the overall complexity of the task was exceeding my "time-budget" for this hobby-project I did not further look into evaluating if this might work.

andresch avatar Apr 08 '21 17:04 andresch

  • I've added FusePath.VEXTENSION dict for use virtual extensions
  • changed logic for subprocess.run from string to array arguments and removed shell=True to stdout=PIPE, it creates many problems with security (quotes in title, exclamation point and etc)
  • changed VERSION as asked before

TODO - rewrite wav extraction same as flac, maby refactor tags creation to separate function from TrackManager._extract_flac_track

Just start re-scanning all my music on Plex. will look if will be new bugs

izverev avatar Apr 12 '21 18:04 izverev