mirror of
https://github.com/soimort/you-get.git
synced 2025-01-24 05:55:02 +03:00
Fallback to re-encoding audio when ffmpeg quits with error
This commit is contained in:
parent
0aafca6de4
commit
f07e909a72
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import logging
|
||||
import os.path
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from ..util.strings import parameterize
|
||||
@ -61,7 +61,23 @@ def ffmpeg_concat_av(files, output, ext):
|
||||
if os.path.isfile(file): params.extend(['-i', file])
|
||||
params.extend(['-c', 'copy'])
|
||||
params.append(output)
|
||||
return subprocess.call(params, stdin=STDIN)
|
||||
if subprocess.call(params, stdin=STDIN):
|
||||
print('Merging without re-encode failed.\nTry again re-encoding audio... ', end="", flush=True)
|
||||
try: os.remove(output)
|
||||
except FileNotFoundError: pass
|
||||
params = [FFMPEG] + LOGLEVEL
|
||||
for file in files:
|
||||
if os.path.isfile(file): params.extend(['-i', file])
|
||||
params.extend(['-c:v', 'copy'])
|
||||
if ext == 'mp4':
|
||||
params.extend(['-c:a', 'aac'])
|
||||
params.extend(['-strict', 'experimental'])
|
||||
elif ext == 'webm':
|
||||
params.extend(['-c:a', 'opus'])
|
||||
params.append(output)
|
||||
return subprocess.call(params, stdin=STDIN)
|
||||
else:
|
||||
return 0
|
||||
|
||||
def ffmpeg_convert_ts_to_mkv(files, output='output.mkv'):
|
||||
for file in files:
|
||||
|
Loading…
Reference in New Issue
Block a user