Skip to content

libobs/util: Implement error reader for ffmpeg posix pipe - #3459

Closed
eric wants to merge 1 commit into
obsproject:masterfrom
eric:provide-stderr-for-pipe-posix
Closed

eric wants to merge 1 commit into
obsproject:masterfrom
eric:provide-stderr-for-pipe-posix

Conversation

@eric

@eric eric commented Sep 12, 2020 •

Copy link
Copy Markdown
Contributor

Description

Transition from using popen() to using posix_spawn() to provide a way
to read stderr from ffmpeg.

Fixes #9665

Motivation and Context

The Windows implementation of os_process_pipe provides an os_process_pipe_read_err() function to return stderr from the remux process but it has not been implemented for POSIX operating systems. This uses the standard way of extending popen() to take more control over process creation.

How Has This Been Tested?

I've tested this with another fix (coming soon) to use an srt:// URL as a custom stream destination and then saw that the error response was displayed in the dialog box.

I also tested starting and stopping recordings and saw no difference in behavior.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist:

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

@WizardCM WizardCM added kind/bug Categorizes issue or PR as related to a bug. kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. labels Sep 12, 2020
@eric
eric force-pushed the provide-stderr-for-pipe-posix branch 3 times, most recently from 4e10a78 to 31a4a16 Compare September 12, 2020 17:17
Transition from using popen() to using fork()/dup2()/execl() to provide a way
to read stderr from ffmpeg.
@eric
eric force-pushed the provide-stderr-for-pipe-posix branch from efe8791 to 6a73238 Compare September 12, 2020 18:43
@eric

eric commented Sep 12, 2020

Copy link
Copy Markdown
Contributor Author

I discovered that using read()/write() introduced some changes in behavior from using fread()/fwrite(). When I would try to attach a debugger to the obs-ffmpeg-mux process while using read()/write() it would cause the mux process to terminate.

I was unable to identify what the difference was that was causing the issue, but when using fdopen() to turn the file descriptors back into FILE * objects, the issue went away.

@eric

eric commented Sep 12, 2020

Copy link
Copy Markdown
Contributor Author

As part of my investigation, I also moved from using pipe()/dup2()/fork() to using posix_spawn(), which is the newer way of spawning processes on a POSIX system.

Comment thread libobs/util/pipe-posix.c
pipe.read_pipe = *type == 'r';
process_pipe.read_pipe = *type == 'r';

int mainfds[2], errfds[2];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code style: Use two separate lines for declaration. I guess the arrays are initialised with zeroes by default, so additional initialisation is not necessary.

@eric

eric commented Jan 2, 2024

Copy link
Copy Markdown
Contributor Author

I am not using OBS anymore and am unlikely to continue work on this. If @PatTheMav or anyone else would like to pick this up, please feel free.

@PatTheMav

Copy link
Copy Markdown
Member

Closing in favour of #10070.

@PatTheMav PatTheMav closed this Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug. kind/enhancement Enhancements are not bugs or new features but can improve usability or performance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OBS Studio silently fails to write to paths that become read-only during recordings

4 participants