edited cmdline

This commit is contained in:
nin0dev 2024-06-25 14:34:41 -04:00
parent 174e0564a7
commit e21718181e

View file

@ -57,9 +57,9 @@ async def merge(request: aiohttp.web.Request):
stderr=asyncio.subprocess.PIPE stderr=asyncio.subprocess.PIPE
) )
response = web.StreamResponse(status=206, reason='OK', headers={ response = web.StreamResponse(status=206, reason='OK', headers={
'Content-Type': 'video/mp4', 'Content-Type': 'application/octet-stream',
'Transfer-Encoding': 'chunked', 'Transfer-Encoding': 'chunked',
'Accept-Ranges': 'bytes' 'Content-Disposition': 'inline'
}) })
await response.prepare(request) await response.prepare(request)
try: try:
@ -69,9 +69,10 @@ async def merge(request: aiohttp.web.Request):
break break
await response.write(chunk) await response.write(chunk)
except Exception as e: except Exception as e:
print(f"Error streaming FFmpeg output: {e}") print(f"Error streaming FFmpeg output: {e}")
finally: #finally:
await response.write_eof() #await response.write_eof()
else: else:
# Likely to be chromium browser, so to avoid browser shitting itself we download file # Likely to be chromium browser, so to avoid browser shitting itself we download file
job_id = f"{request.rel_url.query["id"]}_{request.rel_url.query["audio_itag"]}_{request.rel_url.query["video_itag"]}" job_id = f"{request.rel_url.query["id"]}_{request.rel_url.query["audio_itag"]}_{request.rel_url.query["video_itag"]}"
@ -79,11 +80,9 @@ async def merge(request: aiohttp.web.Request):
return web.FileResponse( return web.FileResponse(
path=f"{job_id}.mp4" path=f"{job_id}.mp4"
) )
cmdline = f"ffmpeg -i \"https://eu-proxy.poketube.fun/latest_version?id={video_id}&itag={audio_itag}&local=true\" -i \"https://eu-proxy.poketube.fun/latest_version?id={video_id}&itag={video_itag}&local=true\" -c copy -f mp4 -movflags frag_keyframe+empty_moov {job_id}.mp4" cmdline = f"ffmpeg -i \"https://eu-proxy.poketube.fun/latest_version?id={video_id}&itag={audio_itag}&local=true\" -i \"https://eu-proxy.poketube.fun/latest_version?id={video_id}&itag={video_itag}&local=true\" -c:v copy -f mp4 -movflags frag_keyframe+empty_moov {job_id}.mp4"
process = await asyncio.create_subprocess_shell( process = await asyncio.create_subprocess_shell(
cmdline, cmdline
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE
) )
await process.wait() await process.wait()
if process.returncode != 0: # Log or handle the error if process.returncode != 0: # Log or handle the error