Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffmpeg export #2309

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft

ffmpeg export #2309

wants to merge 14 commits into from

Conversation

yohannd1
Copy link
Contributor

@yohannd1 yohannd1 commented Dec 25, 2024

An attempt at supporting custom format export via ffmpeg, using the fact that this command works:

cat abc.wav | ffmpeg -f wav -i pipe:0 -f mp3 out.mp3

The idea then is to open a ffmpeg child process and write the export data (which would be written to a .wav file) to it, without needing to link against ffmpeg's libraries. And it effectively makes it optional!

Progress:

  • Initial UI changes (c03dd77)
  • Functional linux fork-pipe-dup2-exec implementation (ef90209)
  • Basic format support (MP3/FLAC/OGG/M4A/OPUS)
  • Detect whether ffmpeg is in PATH
  • Support MacOS
  • Support Windows
  • Custom ffmpeg path and flags (options in the export dialog)
  • (Maybe) Support adding persistent export formats via Lua (will need some major refactoring, and depends on the scripting branch)

@yohannd1
Copy link
Contributor Author

I'm kind of second-guessing this because I noticed libsndfile (already used) supports a few file formats, but I suppose ffmpeg has way more options so this is still useful.

Oh my fucking god this was so goddamn hard to implement. But it's here.

I don't know how I was so lucky but I came across this:

https://stackoverflow.com/questions/53734902/why-child-process-is-waiting-while-using-fork-and-pipes-for-stdin-from-parents

which made me realize stuff can go bad if I do not close the file
descriptors at every possible moment. In this case, I had to close as
many unrelated ends of stdinPipe as possible so the subprocess could
figure out the export was finished
This was a nightmare :)

I did learn how poll() works though. That's nice.

But I had to go through so much to find that out lol... an entire
afternoon.
the feature is still not implemented, but at least now it compiles with
a message saying it's not yet supported
@tildearrow tildearrow closed this Dec 30, 2024
@tildearrow tildearrow reopened this Dec 30, 2024
@LTVA1
Copy link
Contributor

LTVA1 commented Jan 4, 2025

The problem with libsndfile is that it's not easy to statically link libflac, libogg, libvorbis and whatever MP3 requires. I and others tried multiple times and it just doesn't compile. So maybe ffmpeg may be a workaround. You coul even try to enable Furnace to support other formats like flac and mp3 by issuing a command when user opens file so that ffmpeg converts it to wav which Furnace can work with

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants