obs-studio icon indicating copy to clipboard operation
obs-studio copied to clipboard

obs-ffmpeg: Disable audio if no audio in source

Open mvji opened this issue 2 years ago • 5 comments

Description

Disable media source audio output if source doesn't have audio.

Motivation and Context

Avoid to display audio mixer entry for media source without audio

Partially implement this idea : https://ideas.obsproject.com/posts/1125 And : https://ideas.obsproject.com/posts/797

How Has This Been Tested?

Mac os 11.6 Intel Test with media file with and without audio

  • File with audio still play audio
  • File without audio didn't display audio mixer entry anymore

Types of changes

  • Tweak (non-breaking change to improve existing functionality)

Checklist:

  • [x] My code has been run through clang-format.
  • [x] I have read the contributing document.
  • [x] My code is not on the master branch.
  • [x] The code has been tested.
  • [x] All commit messages are properly formatted and commits squashed where appropriate.
  • [x] I have included updates to all appropriate documentation.

mvji avatar Jul 30 '22 18:07 mvji

Similar to https://github.com/obsproject/obs-studio/commit/07b0786892c0acfdc83ab3cd6d111e651dfcf173, could we use the s->media.has_audio boolean to determine whether to enable audio? Disable audio mixer on source create, then let the _start function set the real value.

tt2468 avatar Jul 31 '22 00:07 tt2468

Similar to 07b0786, could we use the s->media.has_audio boolean to determine whether to enable audio? Disable audio mixer on source create, then let the _start function set the real value.

It's not possible to use has_audio in this function. Because in the _start function, video/audio decoder can be not start (it's started on another thread). If we call "obs_source_set_audio_active" in ffmpeg_source_start it's doesn't work properly. You can test by printing has video and has audio in this function, and the result will be inconsistent.

mvji avatar Jul 31 '22 18:07 mvji

IMO whether a source appears in the mixer should depend on the source capabilities, not on the internal situation of the source. The media source is by default audio-capable, so I should be able to set its volume regardless of whether a file is currently selected for playback or if such a file has no audio track.

This is especially important in cases where a media source doesn't exist in isolation (e.g. when scripting is involved or maybe even other plugins interacting with source types) and I'd rather have the user be able to set the volume to 0 (or mute the source) explicitly than relying on the state of an arbitrary media file.

@Warchamp7 WDYT

PatTheMav avatar Jan 27 '24 16:01 PatTheMav

While I agree with Pat's opinion, the obs_source_set_audio_active() method is already in use by other (mainly capture) sources to enable/disable audio when audio is available. As such, this isn't exactly bringing any new UX concepts to the table.

tt2468 avatar Jan 27 '24 19:01 tt2468

While I agree with Pat's opinion, the obs_source_set_audio_active() method is already in use by other (mainly capture) sources to enable/disable audio when audio is available. As such, this isn't exactly bringing any new UX concepts to the table.

Well as Fenrir mentioned in another PR:

I don't want sins of the past informing future decisions

Just because we didn't pay enough attention in the past should not mean we cannot re-evaluate that for any new change.

PatTheMav avatar Jan 27 '24 19:01 PatTheMav