testing #3
This commit is contained in:
parent
8efa116b24
commit
ae010f6b14
@ -21,11 +21,11 @@ SIGINT: int = 2
|
|||||||
|
|
||||||
app = Client(SESSION_NAME, API_ID, API_HASH)
|
app = Client(SESSION_NAME, API_ID, API_HASH)
|
||||||
call_py = PyTgCalls(app)
|
call_py = PyTgCalls(app)
|
||||||
FFMPEG_PROCESSES = {}
|
FFMPEG_PROCESS = {}
|
||||||
|
|
||||||
def raw_converter(dl, song, video):
|
def raw_converter(dl, song, video):
|
||||||
return subprocess.Popen(
|
return subprocess.Popen(
|
||||||
['ffmpeg', '-i', dl, '-f', 's16le', '-ac', '1', '-ar', '48000', song, '-y', '-f', 'rawvideo', '-r', '20', '-pix_fmt', 'yuv420p', '-vf', 'scale=854:480', video, '-y'],
|
['ffmpeg', '-i', dl, '-f', 's16le', '-ac', '1', '-ar', '48000', song, '-y', '-f', 'rawvideo', '-r', '20', '-pix_fmt', 'yuv420p', '-vf', 'scale=1280:720', video, '-y'],
|
||||||
stdin=None,
|
stdin=None,
|
||||||
stdout=None,
|
stdout=None,
|
||||||
stderr=None,
|
stderr=None,
|
||||||
@ -34,7 +34,7 @@ def raw_converter(dl, song, video):
|
|||||||
|
|
||||||
def youtube(url: str):
|
def youtube(url: str):
|
||||||
try:
|
try:
|
||||||
params = {"format": "best[height=?480]/best", "noplaylist": True}
|
params = {"format": "best[height=?720]/best", "noplaylist": True}
|
||||||
yt = YoutubeDL(params)
|
yt = YoutubeDL(params)
|
||||||
info = yt.extract_info(url, download=False)
|
info = yt.extract_info(url, download=False)
|
||||||
return info['url']
|
return info['url']
|
||||||
@ -69,7 +69,7 @@ async def startvideo(client, m: Message):
|
|||||||
await m.reply("failed to get video data")
|
await m.reply("failed to get video data")
|
||||||
return
|
return
|
||||||
process = raw_converter(livelink, f'audio{chat_id}.raw', f'video{chat_id}.raw')
|
process = raw_converter(livelink, f'audio{chat_id}.raw', f'video{chat_id}.raw')
|
||||||
FFMPEG_PROCESSES[chat_id] = process
|
FFMPEG_PROCESS[chat_id] = process
|
||||||
msg = await m.reply("🔁 **starting video streaming...**")
|
msg = await m.reply("🔁 **starting video streaming...**")
|
||||||
await asyncio.sleep(10)
|
await asyncio.sleep(10)
|
||||||
try:
|
try:
|
||||||
@ -144,7 +144,7 @@ async def startvideo(client, m: Message):
|
|||||||
async def stopvideo(client, m: Message):
|
async def stopvideo(client, m: Message):
|
||||||
chat_id = m.chat.id
|
chat_id = m.chat.id
|
||||||
try:
|
try:
|
||||||
process = FFMPEG_PROCESSES.get(chat_id)
|
process = FFMPEG_PROCESS.get(chat_id)
|
||||||
if process:
|
if process:
|
||||||
try:
|
try:
|
||||||
process.send_signal(SIGINT)
|
process.send_signal(SIGINT)
|
||||||
|
Loading…
Reference in New Issue
Block a user