timscaffidi / ofxVideoRecorder

A fast multi-threaded video recording extension using ffmpeg
Other
230 stars 97 forks source link

write to PIPE failed with error -> 32 - Broken pipe #42

Closed stephanschulz closed 8 years ago

stephanschulz commented 8 years ago

i have been using your addon for a while now. and it works very well. i have 4 separate OF apps running at the same time, all using the recorder.

things work well but once in a while i get

[notice ] ofxVideoRecorder: setupCustomOutput
[notice ] videoRecorder: start
[ error ] ofxVideoDataWriterThread: 12:02:37:528 - write to PIPE failed with error -> 32 - Broken pipe.
[ error ] ofxVideoDataWriterThread: 12:02:37:572 - write to PIPE failed with error -> 32 - Broken pipe.
[ error ] ofxVideoDataWriterThread: 12:02:37:636 - write to PIPE failed with error -> 32 - Broken pipe.
ffmpeg version 3.0 Copyright (c) 2000-2016 the FFmpeg developers
  built with Apple LLVM version 7.0.2 (clang-700.1.81)

would you know why?

here is what the print out usually looks like when the recording works correctly: https://gist.github.com/stephanschulz/471cdec81855ea5f122278b9e03b23df

and here when xcode crashes: https://gist.github.com/stephanschulz/b26a04dd892de55f6f8c124d0b6dd30e

here is the bash script that your addon generates:

cmd bash --login -c '/Applications/of_v0.9.3_osx_release/apps/zoom-pavilion/zoom_pavilion_faceTracker/bin/data/ffmpeg -y -an -r 24 -s 160x88 -f rawvideo -pix_fmt rgb24 -i /Applications/of_v0.9.3_osx_release/apps/zoom-pavilion/zoom_pavilion_faceTracker/bin/data/ofxvrpipe0 -r 24  -vcodec mpeg4 -b 800k -acodec pcm_s16le -ab 128k /Users/stephan/Desktop/recordings/2016-05-11-13-34-06-171_0.mov' &
timscaffidi commented 8 years ago

Hmm, the broken pipe may be happening if the ffmpeg instance has not started in time before the video or audio pipes start writing to it.

I think there needs to be an initialized flag that is set on the ffmpeg thread somehow after the command is started, then only when the ffmpeg thread is really up and running should the recorder allow you to add frames.

As a work-around, you may be able to add a small delay between calling setup and adding frames to ensure that this doesn't happen.

timscaffidi commented 8 years ago

@stephanschulz can you test out the branch bugfix-42? I added in a sleep to wait until the ffmpeg thread is running before starting the audio or video threads.

I could not replicate the issue so if you could test it out that would be great.

stephanschulz commented 8 years ago

great thanks. just installed the new addon. since this error does not happened all the time i will report back later, if or when it happens.

aferriss commented 7 years ago

FWIW I noticed that I get this error when I put a bad video codec in setVideoCodec. For instance 'mpeg' doesn't work, while 'mpeg4' does.