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

Simplify combining audio channels for > 2 channels #1

Open
james-trayford opened this issue Aug 10, 2021 · 2 comments
Open

Simplify combining audio channels for > 2 channels #1

james-trayford opened this issue Aug 10, 2021 · 2 comments
Assignees

Comments

@james-trayford
Copy link
Owner

james-trayford commented Aug 10, 2021

currently rely on ffmpeg-python wrapper to write surround sound wav files, but this may be overkill; requires writing of temporary files, and ffmpeg seems to scramble channel orders such that they need to be unscrambled using ad-hoc forder lists which had to be determined for each setup through trial and error and are now an extra property of the audio_channels object

Is it possible to:

  • find a simpler, dedicated library that will do this that doesn't need to invoke the ffmpeg library (wavio wont do this)
  • get ffmpeg to join this channels preserving the order they are fed in
@james-trayford james-trayford self-assigned this Aug 10, 2021
@JosephHinz
Copy link
Collaborator

Hi James,

Here is the error message that I'm getting from the save_combined function-

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-10-1a20b17354ea> in <module>
      1 display_sonification(soni_M_neg, color='C1')
----> 2 soni_M_neg.save_combined('<directory/to/filename.wav>')

c:\users\josep\strauss\src\strauss\sonification.py in save_combined(self, fname, ffmpeg_output)
    111         print("Joning temporary .wav files...")
    112         (
--> 113             ff.filter(inputs, 'join', inputs=len(inputs), channel_layout=self.channels.setup)
    114             .output(fname)
    115             .overwrite_output()

~\anaconda3\lib\site-packages\ffmpeg\_run.py in run(stream_spec, cmd, capture_stdout, capture_stderr, input, quiet, overwrite_output)
    311     Returns: (out, err) tuple containing captured stdout and stderr data.
    312     """
--> 313     process = run_async(
    314         stream_spec,
    315         cmd,

~\anaconda3\lib\site-packages\ffmpeg\_run.py in run_async(stream_spec, cmd, pipe_stdin, pipe_stdout, pipe_stderr, quiet, overwrite_output)
    282     stdout_stream = subprocess.PIPE if pipe_stdout or quiet else None
    283     stderr_stream = subprocess.PIPE if pipe_stderr or quiet else None
--> 284     return subprocess.Popen(
    285         args, stdin=stdin_stream, stdout=stdout_stream, stderr=stderr_stream
    286     )

~\anaconda3\lib\subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
    856                             encoding=encoding, errors=errors)
    857 
--> 858             self._execute_child(args, executable, preexec_fn, close_fds,
    859                                 pass_fds, cwd, env,
    860                                 startupinfo, creationflags, shell,

~\anaconda3\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)
   1309             # Start the process
   1310             try:
-> 1311                 hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
   1312                                          # no special security
   1313                                          None, None,

FileNotFoundError: [WinError 2] The system cannot find the file specified

@james-trayford
Copy link
Owner Author

james-trayford commented Oct 25, 2021

@JosephHinz thanks Joseph, interesting, perhaps it's a platform issue (I'm on mac, see e.g. https://stackoverflow.com/questions/45131495/the-system-cannot-find-the-file-specified-with-ffmpeg), I'll look into it.

For the non-surround sound applications you're looking at, you can use the new save_stereo method instead for now.

You can get these code changes by rebasing your fork onto the main branch of the original repo (see my email from last week).

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

No branches or pull requests

2 participants