mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-24 12:15:40 +01:00
remux only if file is not mp4
This commit is contained in:
parent
cf7380211f
commit
4f6c4821d7
@ -17,36 +17,38 @@ class postprocess(object):
|
|||||||
|
|
||||||
def remux(self):
|
def remux(self):
|
||||||
if self.detect is None:
|
if self.detect is None:
|
||||||
log.error("Cant detect ffmpeg or avconv. cant mux files without it")
|
log.error("Cant detect ffmpeg or avconv. Cant mux files without it.")
|
||||||
return
|
return
|
||||||
if self.stream.finished is False:
|
if self.stream.finished is False:
|
||||||
return
|
return
|
||||||
orig_filename = self.stream.options.output
|
|
||||||
new_name = "{0}.mp4".format(os.path.splitext(self.stream.options.output)[0])
|
if self.stream.options.output.endswith('.mp4') is False:
|
||||||
|
orig_filename = self.stream.options.output
|
||||||
log.info("Muxing %s into %s", orig_filename, new_name)
|
new_name = "{0}.mp4".format(os.path.splitext(self.stream.options.output)[0])
|
||||||
tempfile = "{0}.temp".format(self.stream.options.output)
|
|
||||||
name, ext = os.path.splitext(orig_filename)
|
log.info("Muxing %s into %s", orig_filename, new_name)
|
||||||
arguments = ["-c", "copy", "-copyts", "-f", "mp4"]
|
tempfile = "{0}.temp".format(self.stream.options.output)
|
||||||
if ext == ".ts":
|
name, ext = os.path.splitext(orig_filename)
|
||||||
arguments += ["-bsf:a", "aac_adtstoasc"]
|
arguments = ["-c", "copy", "-copyts", "-f", "mp4"]
|
||||||
arguments += ["-y", tempfile]
|
if ext == ".ts":
|
||||||
cmd = [self.detect, "-i", orig_filename]
|
arguments += ["-bsf:a", "aac_adtstoasc"]
|
||||||
cmd += arguments
|
arguments += ["-y", tempfile]
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
|
cmd = [self.detect, "-i", orig_filename]
|
||||||
stdout, stderr = p.communicate()
|
cmd += arguments
|
||||||
if p.returncode != 0:
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
|
||||||
stderr = stderr.decode('utf-8', 'replace')
|
stdout, stderr = p.communicate()
|
||||||
msg = stderr.strip().split('\n')[-1]
|
if p.returncode != 0:
|
||||||
log.error("Something went wrong: %s", msg)
|
stderr = stderr.decode('utf-8', 'replace')
|
||||||
return
|
msg = stderr.strip().split('\n')[-1]
|
||||||
log.info("Muxing done. removing the old file.")
|
log.error("Something went wrong: %s", msg)
|
||||||
os.remove(self.stream.options.output)
|
return
|
||||||
os.rename(tempfile, new_name)
|
log.info("Muxing done, removing the old file.")
|
||||||
|
os.remove(self.stream.options.output)
|
||||||
|
os.rename(tempfile, new_name)
|
||||||
|
|
||||||
def merge(self):
|
def merge(self):
|
||||||
if self.detect is None:
|
if self.detect is None:
|
||||||
log.error("Cant detect ffmpeg or avconv. cant mux files without it")
|
log.error("Cant detect ffmpeg or avconv. Cant mux files without it.")
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.stream.finished is False:
|
if self.stream.finished is False:
|
||||||
|
Loading…
Reference in New Issue
Block a user