I have the following working code in first.py:
import os
os.system('cat python_better_than_java.wav')
which I can execute like this
python first.py | ffmpeg -y -f wav -i pipe:0 -f mp3 - >hi.mp3
this works.
I want do this in a pythonic way, so I edited first.py to this:
import sys
with open('python_better_than_java.wav', 'rb') as content_file:
content = content_file.read()
sys.stdout.write(content)
and executed it using:
python first.py | ffmpeg -y -f wav -i pipe:0 -f mp3 - >hi.mp3
but then it produces the following error:
pipe:0: Invalid data found when processing input
How can I reproduce cat in python?