MarshalX / tgcalls

Voice chats, private incoming and outgoing calls in Telegram for Developers
https://t.me/tgcallslib
GNU Lesser General Public License v3.0
516 stars 91 forks source link

Sound playback Caton #93

Closed hdcola closed 3 years ago

hdcola commented 3 years ago

My environment: macOS 11.4 Python 3.9.5 tgcalls 0.0.16 pytgcalls 0.0.23 Pyrogram 1.2.9

I transcoded the m4a file into raw by ffmp3g, and there is no problem with using audacity to listen to the sound. The following settings are used when importing audacity:

image

If I use pytgcall to play, I can clearly hear a pause of a few microseconds. I don't know what is wrong with my environment? Or is this a known issue?

MarshalX commented 3 years ago

What command did you use to transcode the file?

hdcola commented 3 years ago

What command did you use to transcode the file?

ffmpeg.input(file_path).output(
    out,
    format='s16le',
    acodec='pcm_s16le',
    ac=2,
    ar='48k',
    loglevel='error'
).overwrite_output().run_async()
MarshalX commented 3 years ago

And how did you try to play this file?

hdcola commented 3 years ago

And how did you try to play this file?

https://github.com/hdcola/chstockbot/blob/main/musicbot/services/callsmusic/callsmusic.py

Here is my service for playing music. Directly call the set_stream function inside

MarshalX commented 3 years ago

And how did you try to play this file?

https://github.com/hdcola/chstockbot/blob/main/musicbot/services/callsmusic/callsmusic.py

Here is my service for playing music. Directly call the set_stream function inside

Do you try to run example from main readme of this lib with your transcoded file? If not, you should try

hdcola commented 3 years ago

And how did you try to play this file?

https://github.com/hdcola/chstockbot/blob/main/musicbot/services/callsmusic/callsmusic.py Here is my service for playing music. Directly call the set_stream function inside

Do you try to run example from main readme of this lib with your transcoded file? If not, you should try

I used this sample code

https://github.com/MarshalX/tgcalls/blob/main/examples/player_as_smart_plugin.py

Still the same problem reproduced. Could it be the version of Python or some other lib?

MarshalX commented 3 years ago

And how did you try to play this file?

https://github.com/hdcola/chstockbot/blob/main/musicbot/services/callsmusic/callsmusic.py Here is my service for playing music. Directly call the set_stream function inside

Do you try to run example from main readme of this lib with your transcoded file? If not, you should try

I used this sample code

https://github.com/MarshalX/tgcalls/blob/main/examples/player_as_smart_plugin.py

Still the same problem reproduced. Could it be the version of Python or some other lib?

It sounds so strange. Do u have the m1 mac?

hdcola commented 3 years ago

It sounds so strange. Do u have the m1 mac?

My Mac is an Intel Core i5 CPU, not a new M1 CPU

MarshalX commented 3 years ago

It sounds so strange. Do u have the m1 mac?

My Mac is an Intel Core i5 CPU, not a new M1 CPU

I have no idea how to help you(

hdcola commented 3 years ago

Thank you very much for your reply. I will continue to observe the performance on different machines. The environment I will eventually run on will be Raspberry Pi. I don’t know what the effect will be.

hdcola commented 3 years ago

I have now tried two different Macs. This problem occurs with different versions of Python, maybe because of MacOS?

MarshalX commented 3 years ago

I have now tried two different Macs. This problem occurs with different versions of Python, maybe because of MacOS?

What version of macos do you use?

hdcola commented 3 years ago

What version of macos do you use?

all is 11.4 (macOS Big Sur)

MarshalX commented 3 years ago

What version of macos do you use?

all is 11.4 (macOS Big Sur)

me too

hdcola commented 3 years ago

I began to suspect that there was a problem with ffmpeg or something in my code, because after I deployed it to heroku, it still appeared intermittent.

hdcola commented 3 years ago

Much better after using linux and replacing a Server with a better CPU. On closer inspection, I think it's a problem of ffmpeg cpu overuse. Maybe consider a real time decoding solution. Thanks for the previous help