Revert "Adding Audio and Visual converter for ffmpeg."
This reverts commit 4aafb9a5e7e1728bf728a3f8c572cfa4454a6771.
This commit is contained in:
parent
7c58b5148d
commit
177a9ad6cc
@ -3,7 +3,6 @@ from __future__ import unicode_literals
|
|||||||
from .embedthumbnail import EmbedThumbnailPP
|
from .embedthumbnail import EmbedThumbnailPP
|
||||||
from .ffmpeg import (
|
from .ffmpeg import (
|
||||||
FFmpegPostProcessor,
|
FFmpegPostProcessor,
|
||||||
FFmpegAVConvertorPP,
|
|
||||||
FFmpegEmbedSubtitlePP,
|
FFmpegEmbedSubtitlePP,
|
||||||
FFmpegExtractAudioPP,
|
FFmpegExtractAudioPP,
|
||||||
FFmpegFixupStretchedPP,
|
FFmpegFixupStretchedPP,
|
||||||
@ -26,7 +25,6 @@ def get_postprocessor(key):
|
|||||||
__all__ = [
|
__all__ = [
|
||||||
'EmbedThumbnailPP',
|
'EmbedThumbnailPP',
|
||||||
'ExecAfterDownloadPP',
|
'ExecAfterDownloadPP',
|
||||||
'FFmpegAVConvertorPP',
|
|
||||||
'FFmpegEmbedSubtitlePP',
|
'FFmpegEmbedSubtitlePP',
|
||||||
'FFmpegExtractAudioPP',
|
'FFmpegExtractAudioPP',
|
||||||
'FFmpegFixupM3u8PP',
|
'FFmpegFixupM3u8PP',
|
||||||
|
@ -2,7 +2,6 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
import shutil
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
@ -351,10 +350,9 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor):
|
|||||||
|
|
||||||
|
|
||||||
class FFmpegVideoConvertorPP(FFmpegPostProcessor):
|
class FFmpegVideoConvertorPP(FFmpegPostProcessor):
|
||||||
def __init__(self, downloader=None, preferedformat=None, outpath=None):
|
def __init__(self, downloader=None, preferedformat=None):
|
||||||
super(FFmpegVideoConvertorPP, self).__init__(downloader)
|
super(FFmpegVideoConvertorPP, self).__init__(downloader)
|
||||||
self._preferedformat = preferedformat
|
self._preferedformat = preferedformat
|
||||||
self._outpath = outpath
|
|
||||||
|
|
||||||
def run(self, information):
|
def run(self, information):
|
||||||
path = information['filepath']
|
path = information['filepath']
|
||||||
@ -364,56 +362,16 @@ class FFmpegVideoConvertorPP(FFmpegPostProcessor):
|
|||||||
options = []
|
options = []
|
||||||
if self._preferedformat == 'avi':
|
if self._preferedformat == 'avi':
|
||||||
options.extend(['-c:v', 'libxvid', '-vtag', 'XVID'])
|
options.extend(['-c:v', 'libxvid', '-vtag', 'XVID'])
|
||||||
if not self._outpath:
|
prefix, sep, ext = path.rpartition('.')
|
||||||
prefix, sep, ext = path.rpartition('.')
|
outpath = prefix + sep + self._preferedformat
|
||||||
self._outpath = prefix + sep + self._preferedformat
|
self._downloader.to_screen('[' + 'ffmpeg' + '] Converting video from %s to %s, Destination: ' % (information['ext'], self._preferedformat) + outpath)
|
||||||
self._downloader.to_screen('[' + 'ffmpeg' + '] Converting video from %s to %s, Destination: ' % (information['ext'], self._preferedformat) + self._outpath)
|
self.run_ffmpeg(path, outpath, options)
|
||||||
self.run_ffmpeg(path, self._outpath, options)
|
information['filepath'] = outpath
|
||||||
information['filepath'] = self._outpath
|
|
||||||
information['format'] = self._preferedformat
|
information['format'] = self._preferedformat
|
||||||
information['ext'] = self._preferedformat
|
information['ext'] = self._preferedformat
|
||||||
return [path], information
|
return [path], information
|
||||||
|
|
||||||
|
|
||||||
class FFmpegAVConvertorPP(FFmpegPostProcessor):
|
|
||||||
def __init__(self, downloader=None, preferedvformat=None, preferedaformat=None, preferredquality=None):
|
|
||||||
super(FFmpegAVConvertorPP, self).__init__(downloader)
|
|
||||||
self._downloader = downloader
|
|
||||||
self._preferedaformat = preferedaformat
|
|
||||||
self._preferedvformat = preferedvformat
|
|
||||||
self._preferredquality = preferredquality
|
|
||||||
|
|
||||||
def run(self, information):
|
|
||||||
path = information['filepath']
|
|
||||||
paths_to_remove = []
|
|
||||||
prefix, sep, ext = path.rpartition('.')
|
|
||||||
tmp_file = prefix + '.tmp' + sep + self._preferedvformat
|
|
||||||
if ext != self._preferedvformat:
|
|
||||||
tmp_file = prefix + '.tmp' + sep + self._preferedvformat
|
|
||||||
vc = FFmpegVideoConvertorPP(downloader=self._downloader,
|
|
||||||
preferedformat=self._preferedvformat,
|
|
||||||
outpath=tmp_file)
|
|
||||||
path_list, information = vc.run(information)
|
|
||||||
paths_to_remove.append(path_list[0])
|
|
||||||
elif self.get_audio_codec(path) != self._preferedaformat:
|
|
||||||
information['filepath'] = tmp_file
|
|
||||||
shutil.move(path, tmp_file)
|
|
||||||
else:
|
|
||||||
self._downloader.to_screen('[ffmpeg] Not converting video file %s - '
|
|
||||||
'already is in target format %s:%s' %
|
|
||||||
(path, self._preferedvformat, self._preferedaformat))
|
|
||||||
return [], information
|
|
||||||
|
|
||||||
path = information['filepath']
|
|
||||||
if self.get_audio_codec(path) != self._preferedaformat:
|
|
||||||
output = prefix + sep + self._preferedvformat
|
|
||||||
aformat = self._preferedaformat
|
|
||||||
quality = self._preferredquality + 'k'
|
|
||||||
self.run_ffmpeg(path, output, ['-c:v', 'copy', '-c:a', aformat, '-b:a', quality])
|
|
||||||
paths_to_remove.append(path)
|
|
||||||
return paths_to_remove, information
|
|
||||||
|
|
||||||
|
|
||||||
class FFmpegEmbedSubtitlePP(FFmpegPostProcessor):
|
class FFmpegEmbedSubtitlePP(FFmpegPostProcessor):
|
||||||
def run(self, information):
|
def run(self, information):
|
||||||
if information['ext'] not in ('mp4', 'webm', 'mkv'):
|
if information['ext'] not in ('mp4', 'webm', 'mkv'):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user