Robert904 / pymumble

Mumble client implementation in Python (and a bit of cython)
GNU General Public License v3.0
32 stars 81 forks source link

Doesn't work with ffmpeg #2

Closed DavidVentura closed 10 years ago

DavidVentura commented 10 years ago

Hi. I want to stream this output to an rtmp server; for now at least I'd like to save it as an mp3

ENCODER ="ffmpeg -i - -c:a libmp3lame -ab 96k -ac 1 -ar 22050 -loglevel quiet -f mp3 out3.mp3"

doesn't do anything (the wav files are generated, but the mp3 is not)

ENCODER ="ffmpeg -i - -c:a libmp3lame -ab 96k -ac 1 -ar 22050 -loglevel quiet -f mp3 %s.mp3"
Traceback (most recent call last):
  File "mumblerecbot.py", line 340, in <module>
    recbot = MumbleRecBot()
  File "mumblerecbot.py", line 54, in __init__
    self.loop()
  File "mumblerecbot.py", line 243, in loop
    self.audio_file.write(base_sound)
  File "mumblerecbot.py", line 324, in write
    self.file_obj.write(data)
IOError: [Errno 32] Broken pipe

running

cat somefile.wav | ffmpeg -i - -c:a libmp3lame -ab 96k -ac 1 -ar 22050 -loglevel quiet -f mp3 out3.mp3

works as intended

Robert904 commented 10 years ago

Has mentionned, this is no wav format that is sent through the pipe when an encoder is specified, but raw audio (no headers). You must then specify the input raw format to ffmeg... I'm not used to ffmpeg options, but it should be something like : "ffmpeg -f s16le -ar 48000 -ac 2 -i - ..." with -f s16le for PCM signed 16bits little-endian, -ar for 48Khz sampling rate and -ac for 2 channels (stereo) Hope it solve the issue

DavidVentura commented 10 years ago

Now it works as intended to generate mp3 files (ffmpeg works) but what's not working is streaming to rtmp.

here the mp3 file was generated with mumblerecbot and works

ffmpeg -re -i mumble-20140504-1*mp3 -c:a libmp3lame -ab 96k -ac 1 -ar 22050 -f flv rtmp://ip:port/application

this in the constants.py (doesn't work either with -re or without it, it's needed for a file to live-stream it)

ffmpeg -f s16le -ar 48000 -ac 2 -re -i - -c:a libmp3lame -ab 96k -ac 1 -ar 22050 -loglevel quiet -f flv rtmp://107.170.84.207:1935/xorg/movie

It doesn't give any errors, it just doesn't stream anything. ATM I'm using a loopback device to record my mumble and stream it and this approach is way better

Robert904 commented 10 years ago

I'll try to add some debugging output for the external encoder this evening to help troubleshoot, but it seems to be a ffmpeg usage issue... can't help much about that...

What do you mean by "I'm using a loopback device to record my mumble and stream it and this approach is way better" ? You have a connected client that use a virtual soundcard as output ? The idea behind this client is to have some "added value" like an auto start/stop based on the number of connected clients, the subtitling/chaptering, the headless operation, but if you don't need any of those it is obvious that the official client will be more stable and less cpu intensive...

DavidVentura commented 10 years ago

FFmpeg works if I run it on a shell, if it reads a file or if I pipe something onto it, but it doesn't work with the recorder (works when outputting to a file, not when outputting to an rtmp server)

Right now I'm running a mumble server with a few clients and a 'bot' which is another computer running linux, with the mic muted and the output redirected to ffmpeg. This means I need to have a computer on with a GUI (for the mumble client) and the audio goes: client1->mumble server->client2(ffmpeg 'bot')->rtmp server (which is the same as the mumble server).

I think it'd be a lot better if I could use the server to record and stream to the rtmp server directly(headless).

Thanks a lot

On 5 May 2014 10:50, Robert904 notifications@github.com wrote:

I'll try to add some debugging output for the external encoder this evening to help troubleshoot, but it seems to be a ffmpeg usage issue... can't help much about that...

What do you mean by "I'm using a loopback device to record my mumble and stream it and this approach is way better" ? You have a connected client that use a virtual soundcard as output ? The idea behind this client is to have some "added value" like an auto start/stop based on the number of connected clients, the subtitling/chaptering, the headless operation, but if you don't need any of those it is obvious that the official client will be more stable and less cpu intensive...

— Reply to this email directly or view it on GitHubhttps://github.com/Robert904/pymumble/issues/2#issuecomment-42189475 .

We need only a little more code,and little more money,and little more time, and little more sleep but the world needs a lot more freedom

Robert904 commented 10 years ago

OK, indeed the problem was in my code. It was expecting a "%s" somewhere in the encoder string to insert a filename... What I just pushed :

Robert904 commented 10 years ago

and by the way as it is a "mumblerecbot" issue, unrelated to the pymumble library itself, I'll close it here, but feel free to open a new one in the other project...