mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 21:45:02 +03:00
add ffmpeg_concat_mp4_to_mp4
This commit is contained in:
parent
f8ac919be1
commit
bc759b0a27
@ -444,8 +444,8 @@ def download_urls(urls, title, ext, total_size, output_dir = '.', refer = None,
|
||||
except:
|
||||
from .processor.ffmpeg import has_ffmpeg_installed
|
||||
if has_ffmpeg_installed():
|
||||
from .processor.ffmpeg import ffmpeg_concat_mp4_to_mpg
|
||||
ffmpeg_concat_mp4_to_mpg(parts, os.path.join(output_dir, title + '.mp4'))
|
||||
from .processor.ffmpeg import ffmpeg_concat_mp4_to_mp4
|
||||
ffmpeg_concat_mp4_to_mp4(parts, os.path.join(output_dir, title + '.mp4'))
|
||||
for part in parts:
|
||||
os.remove(part)
|
||||
else:
|
||||
|
@ -96,3 +96,31 @@ def ffmpeg_concat_flv_to_mp4(files, output = 'output.mp4'):
|
||||
return True
|
||||
else:
|
||||
raise
|
||||
|
||||
def ffmpeg_concat_mp4_to_mp4(files, output = 'output.mp4'):
|
||||
for file in files:
|
||||
if os.path.isfile(file):
|
||||
params = [FFMPEG, '-i']
|
||||
params.append(file)
|
||||
params += ['-c', 'copy', '-f', 'mpegts', '-bsf:v', 'h264_mp4toannexb']
|
||||
params.append(file + '.ts')
|
||||
|
||||
subprocess.call(params)
|
||||
|
||||
params = [FFMPEG, '-i']
|
||||
params.append('concat:')
|
||||
for file in files:
|
||||
f = file + '.ts'
|
||||
if os.path.isfile(f):
|
||||
params[-1] += f + '|'
|
||||
if FFMPEG == 'avconv':
|
||||
params += ['-c', 'copy', output]
|
||||
else:
|
||||
params += ['-c', 'copy', '-absf', 'aac_adtstoasc', output]
|
||||
|
||||
if subprocess.call(params) == 0:
|
||||
for file in files:
|
||||
os.remove(file + '.ts')
|
||||
return True
|
||||
else:
|
||||
raise
|
||||
|
Loading…
Reference in New Issue
Block a user