MarshalX / tgcalls

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

Output file not content data #65

Closed kvmukhin closed 3 years ago

kvmukhin commented 3 years ago

Output file has a not null size, but after conversion, when listening to silence Convert cmd: ffmpeg -f s16le -ac 2 -ar 48000 -acodec pcm_s16le -i output.raw clear_output.mp3

MarshalX commented 3 years ago

Can u show ur code? Did u try run recorder example?

kvmukhin commented 3 years ago

I`m use example - https://github.com/MarshalX/tgcalls/blob/main/examples/playout.py (with small edits) and my sound file mp3 (convert ffmpeg -i input.mp3 -f s16le -ac 2 -ar 48000 -acodec pcm_s16le input.raw) In telegram music play ok

MarshalX commented 3 years ago

What is the file size? Is the duration consistent (after converting) with reality?

kvmukhin commented 3 years ago

Yes. Size and duration simile real.

MarshalX commented 3 years ago

Can you reproduce it with 100% probability?

kvmukhin commented 3 years ago

yes, i tried different input files always 'output' file after convert have size and not null duration, but listen only silence. may be example have error?

MarshalX commented 3 years ago

the example implementation is correct. can you send a log file?

kvmukhin commented 3 years ago

My implementation:


import asyncio
import pytgcalls
import pyrogram

API_HASH = None
API_ID = None
CHAT_ID = ''
INPUT_FILENAME = 'input1.raw'
OUTPUT_FILENAME = 'output.raw'

async def end_track(gc: pytgcalls.GroupCall, filename: str):
    print(f'Track ended {filename}')
    gc.input_filename = 'input.raw'
    print(f'Track load {gc.input_filename}')

async def main(client):
    await client.start()
    while not client.is_connected:
        await asyncio.sleep(1)

    group_call = pytgcalls.GroupCall(client, INPUT_FILENAME, play_on_repeat=False)
    group_call.on_playout_ended(end_track)
    await group_call.start(CHAT_ID)

    await pyrogram.idle()

if __name__ == '__main__':
    pyro_client = pyrogram.Client(
        os.environ.get('SESSION_NAME', 'pytgcalls'),
        api_hash=os.environ.get('API_HASH', API_HASH),
        api_id=os.environ.get('API_ID', API_ID)
    )

    loop = asyncio.get_event_loop()
    loop.run_until_complete(main(pyro_client))```
MarshalX commented 3 years ago

My implementation:

import asyncio
import pytgcalls
import pyrogram

API_HASH = None
API_ID = None
CHAT_ID = ''
INPUT_FILENAME = 'input1.raw'
OUTPUT_FILENAME = 'output.raw'

async def end_track(gc: pytgcalls.GroupCall, filename: str):
    print(f'Track ended {filename}')
    gc.input_filename = 'input.raw'
    print(f'Track load {gc.input_filename}')

async def main(client):
    await client.start()
    while not client.is_connected:
        await asyncio.sleep(1)

    group_call = pytgcalls.GroupCall(client, INPUT_FILENAME, play_on_repeat=False)
    group_call.on_playout_ended(end_track)
    await group_call.start(CHAT_ID)

    await pyrogram.idle()

if __name__ == '__main__':
    pyro_client = pyrogram.Client(
        os.environ.get('SESSION_NAME', 'pytgcalls'),
        api_hash=os.environ.get('API_HASH', API_HASH),
        api_id=os.environ.get('API_ID', API_ID)
    )

    loop = asyncio.get_event_loop()
    loop.run_until_complete(main(pyro_client))```

U don’t pass output filename to group call constructor. If u want to record u should pass it)

kvmukhin commented 3 years ago

log: https://pastebin.com/v3buyFgN

kvmukhin commented 3 years ago

My implementation:

import asyncio
import pytgcalls
import pyrogram

API_HASH = None
API_ID = None
CHAT_ID = ''
INPUT_FILENAME = 'input1.raw'
OUTPUT_FILENAME = 'output.raw'

async def end_track(gc: pytgcalls.GroupCall, filename: str):
    print(f'Track ended {filename}')
    gc.input_filename = 'input.raw'
    print(f'Track load {gc.input_filename}')

async def main(client):
    await client.start()
    while not client.is_connected:
        await asyncio.sleep(1)

    group_call = pytgcalls.GroupCall(client, INPUT_FILENAME, play_on_repeat=False)
    group_call.on_playout_ended(end_track)
    await group_call.start(CHAT_ID)

    await pyrogram.idle()

if __name__ == '__main__':
    pyro_client = pyrogram.Client(
        os.environ.get('SESSION_NAME', 'pytgcalls'),
        api_hash=os.environ.get('API_HASH', API_HASH),
        api_id=os.environ.get('API_ID', API_ID)
    )

    loop = asyncio.get_event_loop()
    loop.run_until_complete(main(pyro_client))```

U don’t pass output filename to group call constructor. If u want to record u should pass it)

Oh) i deleted 'OUTPUT_FILENAME' because file grow. I can send early get 'output' file

MarshalX commented 3 years ago

Are you sure that the other members of the voice chat said something? To get it on the record. the bot does not record itself ofc)

kvmukhin commented 3 years ago

It explains everything :) Thx)