Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1003251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:57:05+00:00 2026-05-16T07:57:05+00:00

I am trying to read binary data from sys.stdin using Python 2.7 on Windows

  • 0

I am trying to read binary data from sys.stdin using Python 2.7 on Windows XP. The binary data is a WAV file decoded by foobar2000. Normally, this data is sent to a command-line encoder such as lame.exe on stdin, where it is processed and written to an output file whose name is provided in the command-line arguments. I am trying to intercept the WAV data that is output and send it to another file. However, I can only get a few KB from stdin before the pipeline apparently collapses, and so I am left with only a very short (about 75 KB) WAV file, instead of the several tens of megabytes that I am expecting. What might be causing this? I have been careful to open both sys.stdin and the output file as binary files.

from __future__ import print_function
import os
import os.path
import sys

sys.stdin = os.fdopen(sys.stdin.fileno(), 'rb', 0) # Make sys.stdin binary

wave_fname = os.path.join(os.environ['USERPROFILE'], 'Desktop',
    'foobar_test.wav')

try:
    os.remove(wave_fname)
except Exception:
    pass

CHUNKSIZE = 8192
wave_f = open(wave_fname, 'wb')
try:
    bytes_read = sys.stdin.read(CHUNKSIZE)
    while bytes_read:
        for b in bytes_read:
            wave_f.write(b)
        bytes_read = sys.stdin.read(CHUNKSIZE)
finally:
    pass
wave_f.close()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T07:57:06+00:00Added an answer on May 16, 2026 at 7:57 am

    Suggestion: maybe you need to use msvcrt.setmode(fd, flags) where fd is sys.stdin.fileno()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 513k
  • Answers 513k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer System.Timers.Timer is a horrible class. There is no good way… May 16, 2026 at 5:59 pm
  • Editorial Team
    Editorial Team added an answer There is always the choice between usabiity and secutity. The… May 16, 2026 at 5:58 pm
  • Editorial Team
    Editorial Team added an answer Download the commons-lang-2.5-bin.zip Extract it, and find the commons-lang-2.5.jar Add… May 16, 2026 at 5:58 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Using Python (3.1 or 2.6), I'm trying to read data from binary data files
I'm trying to read binary data from a specific offset. I write the data
i'd like to read binary data from a blob, using the Stream interface around
I'm trying to pull some binary data from a database and write them to
I'm trying to read a binary file with the following code: open(F, <$file) ||
I'm trying to upload a file via URLConnection, but I need to read/write it
I am trying to download a file I have uploaded to an image field
I am having problems trying to serialise a vector (std::vector) into a binary format
I'm using boost::iostreams::gzip_decompressor with boost::iostreams::filterimg_streambuf to read gzip files. some of my files have
I tried to read a REG_BINARY value of the Windows registry, but I don't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.