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

Customize ffmpeg options when mounting ffmpegfs #155

Open ToxicFrog opened 5 months ago

ToxicFrog commented 5 months ago

I use ffmpeg with libopenmpt, which supports -subsong N as a command line option to select a specific subsong from files that contain more than one, or -subsong all to decode/probe all subsongs in sequence. The default, however, is to only read the first subsong, which means that when using ffmpegfs with (e.g.) UMX files that contain multiple subsongs, accessing the transcoded version only gives you the first one.

I don't know if the ffmpeg API used by ffmpegfs makes it possible to specify options like that, but if it does, being able to do so (e.g. -o ffmpeg_opts=subsong=all or similar) would help not just with these files, but with any ffmpegfs usage that requires additional options to ffmpeg to function properly.

For subsong support specifically, I think a more elegant solution would be for each subsong to appear as a separate file, but as far as I know libopenmpt is the only decoder that supports subsongs, so that would likely be significant effort for a very niche use case, while ffmpeg_opts would be more generally useful.

nschlia commented 5 months ago

I haven't seen MOD files since the 90s. Unbelievable, they still exist... I should have kept the ones I had back then. The FFmpeg library seems to be able to decode them, at least all UMX, MOD, XM files I found. But I could not get an UMX file with subsongs. Could provide me with one (of course it must be royalty free) or where to download some?

ToxicFrog commented 5 months ago

2nd_reality.s3m contains four subsongs:

$ for i in -1 0 1 2 3; do ffprobe -subsong $i 2nd_reality.s3m; done |& grep Duration:
  Duration: 00:09:43.56, bitrate: 5 kb/s
  Duration: 00:07:49.88, bitrate: 6 kb/s
  Duration: 00:00:23.28, bitrate: 133 kb/s
  Duration: 00:00:19.68, bitrate: 158 kb/s
  Duration: 00:01:10.72, bitrate: 44 kb/s

There's some others on modarchive.org that use subsongs, although they don't seem to be marked on the website; the only way to find out is to download them and check. Here's all the ones from the Revered Modules list that I know have subsongs, if you need more test material:

$ for i in *; do ffprobe -subsong 1 "$i" &>/dev/null && echo "$i"; done ``` 16beat-intromodul800.mod 2nd_reality.s3m A94FINAL.S3M acidgod.mod _almages.it ASTRAY.S3M bacter_vs_saga_musix_-_whiskey_drops.it bejeweltwt6010.mo3 bookworm.it cannona.it crystald.s3m CTGOBLIN.S3M deep_in_her_eyes_-_remake.it ek-depth.it ferrari.it fishtro.s3m goluigi_-_hi_police_guy.it ko0x_-_go_with_the_flow.mptm m5v-alch.it MECH8.S3M menutune.s3m miarabia.s3m m-stomp.s3m NOFACE.S3M paranoid.it party_1992_intromusic.s3m PM_NOVA.S3M projectx.mod purple_motion_-_death_rally_-_hard_metal.s3m razor-ub.it saga_musix_-_a_winters_night_dream.it saga_musix_-_snowflakes.it saga_musix_vs_teasy_-_reptile_in_jamaica.it skaven-fourth_symmetriad.it snake-music-2.mod spx-bubbles.it universal_network_2.xm v17-revengeofcats.it vince_kaichan_-_shangri_la_dreaming.mptm WHEN.S3M w-tm.it ```

Also, if you have a copy of Deus Ex (the 2000 original) for PC, you can just copy the UMX files off the CD; most of them have a bunch of subsongs containing different variations played in different situations (idle, conversation, action, death, etc). I don't know offhand if other Unreal Engine games (UT99, Wheel of Time, Undying...) use this capability or not, since I don't have the UMXs handy for those.

nschlia commented 5 months ago

Looks like the FFmpeg API does support libopenmpt, see https://ffmpeg.org/ffmpeg-all.html#toc-libopenmpt So, without requiring a new external library, it should be possible to support multi track mods... I would implement that like for audio files containing multiple tracks and a cue file - you will see the subsongs as seperate virtual files in the output folder.

ToxicFrog commented 5 months ago

Yeah, I mentioned that in the original report -- the issue is that (unless you use a patched version of libopenmpt) it defaults to only reading the first subsong, and ffmpegfs always opens it with the defaults.

If it could work the same way as multitrack files with CUEs that would be fantastic.