Issue #7070 has been updated by jonforums (Jon Forums).


Given your CRT `popen` and Java `Process` experiments, does a more verbose `IO.popen` (non-shell) snippet reliably work?

It's clever that you're parsing ffmpeg's stderr to enum dshow devices, but is the stderr redirect to stdout plus ffmpeg's "immediate exit request" (??) too much for cmd.exe? Wonder if cmd.exe is somehow inconsistently corrupting the streams rather than ruby being the problem. But then your `popen` (documented to use the command processor) sample with redirects works.

Interesting...maybe Hiroshi's already on it ;)
----------------------------------------
Bug #7070: sometimes backticks can fail to return data
https://bugs.ruby-lang.org/issues/7070#change-29766

Author: rogerdpack (Roger Pack)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 1.9.3p194 (2012-04-20) [i386-mingw32]


Basically, if you have ffmpeg for windows, ex: http://ffmpeg.zeranoe.com/builds


Then run it like this:

 enum = `ffmpeg.exe -list_devices true -f dshow -i dummy 2>&1`

"every so often" the value returned is "" (presumably in error).

Example:

39 times you'll get this:

>>  enum = `temp\\ffmpeg.exe -list_devices true -f dshow -i dummy 2>&1`
=> "ffmpeg version N-44123-g5d55830 Copyright (c) 2000-2012 the FFmpeg developers\n  built on Sep  2 2012 20:23:29 with gcc 4.7.1 (GCC)\n  configuration: --enable-gpl --enable-version3 --disable-pthreads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass --enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib\n  libavutil      51. 70.100 / 51. 70.100\n  libavcodec     54. 55.100 / 54. 55.100\n  libavformat    54. 25.104 / 54. 25.104\n  libavdevice    54.  2.100 / 54.  2.100\n  libavfilter     3. 15.102 /  3. 15.102\n  libswscale      2.  1.101 /  2.  1.101\n  libswresample   0. 15.100 /  
 0. 15.100\n  libpostproc    52.  0.100 / 52.  0.100\n[dshow @ 003cc3a0] DirectShow video
 devices\n[dshow @ 003cc3a0]  \"screen-capture-recorder\"\n[dshow @ 003cc3a0] DirectShow audio devices\n[dshow @ 003cc3a0]  \"Microphone (USB Audio Device)\"\n[dshow @ 003cc3a0]  \"virtual-audio-capturer\"\ndummy: Immediate exit requested\n"
irb(main):036:0>  enum = `temp\\ffmpeg.exe -list_devices true -f dshow -i dummy 2>&1`

then the 40th will be
>>  enum = `temp\\ffmpeg.exe -list_devices true -f dshow -i dummy 2>&1`
=> ""

Running using C's "popen" seems to work reliably.
https://gist.github.com/3784971
I would note that jruby seems to suffer from the same difficulty for whatever reason.  Running it with other executables 
Thanks!


-- 
http://bugs.ruby-lang.org/