This commit is contained in:
soju6jan
2022-10-02 20:18:05 +09:00
parent b9c3aac91f
commit 29930fdef7
150 changed files with 53982 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
import os, sys, traceback, subprocess, json, platform, time
import shutil
from . import logger
class SupportFfmpeg(object):
@classmethod
def download_m3u8(cls, config):
try:
if config.get('proxy') == None:
if config.get('headers') == None:
command = [config.get('ffmpeg_path'), '-y', '-correct_ts_overflow', '0', '-i', config['url'], '-c', 'copy', '-bsf:a', 'aac_adtstoasc']
else:
headers_command = []
for key, value in config.get('headers').items():
if key.lower() == 'user-agent':
headers_command.append('-user_agent')
headers_command.append(value)
pass
else:
headers_command.append('-headers')
headers_command.append('\'%s:%s\''%(key,value))
command = [config.get('ffmpeg_path'), '-y', '-correct_ts_overflow', '0'] + headers_command + ['-i', config['url'], '-c', 'copy', '-bsf:a', 'aac_adtstoasc']
else:
command = [config.get('ffmpeg_path'), '-y', '-correct_ts_overflow', '0', '-http_proxy', config.get('proxy'), '-i', config['url'], '-c', 'copy', '-bsf:a', 'aac_adtstoasc']
filename = str(int(time.time())) + '.mp4'
tmp = config.get('tmp_dir')
if tmp == None:
tmp = os.getcwd()
tmp_filepath = os.path.join(tmp, filename)
command.append(tmp_filepath)
logger.debug(' '.join(command))
from . import SupportSubprocess
ret = SupportSubprocess.execute(command, timeout=10)
logger.error(ret)
if os.path.exists(tmp_filepath):
shutil.move(tmp_filepath, config.get('output_filepath'))
except Exception as e:
logger.error(f'Exception:{str(e)}', )
logger.error(traceback.format_exc())
logger.error('command : %s', command)