mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-02-05 18:20:10 +09:00
Compare commits
5 Commits
0a4cdbb642
...
0145f4fd5f
Author | SHA1 | Date | |
---|---|---|---|
|
0145f4fd5f | ||
|
1036478d13 | ||
|
00ad2b8ca1 | ||
|
ab7c61ca29 | ||
|
dc179db221 |
@ -122,6 +122,7 @@ from .postprocessor import (
|
||||
FFmpegFixupM4aPP,
|
||||
FFmpegFixupStretchedPP,
|
||||
FFmpegMergerPP,
|
||||
FFmpegConcatPP,
|
||||
FFmpegPostProcessor,
|
||||
get_postprocessor,
|
||||
)
|
||||
@ -1206,6 +1207,20 @@ class YoutubeDL(object):
|
||||
entry_result = self.__process_iterable_entry(entry, download, extra)
|
||||
# TODO: skip failed (empty) entries?
|
||||
playlist_results.append(entry_result)
|
||||
|
||||
if self.params.get('concat_playlist', False):
|
||||
concat_pp = FFmpegConcatPP(self)
|
||||
ie_result['__postprocessors'] = [concat_pp]
|
||||
ie_result['__files_to_concat'] = list(map(lambda e: e['_filename'], entries))
|
||||
|
||||
filename_wo_ext = self.prepare_filename(ie_result)
|
||||
|
||||
# Ensure filename always has a correct extension for successful merge
|
||||
ie_result['ext'] = self.params.get('merge_output_format') or entries[0]['ext']
|
||||
ie_result['_filename'] = filename = '%s.%s' % (filename_wo_ext, ie_result['ext'])
|
||||
|
||||
self.post_process(filename, ie_result)
|
||||
|
||||
ie_result['entries'] = playlist_results
|
||||
self.to_screen('[download] Finished downloading playlist: %s' % playlist)
|
||||
return ie_result
|
||||
@ -1858,6 +1873,7 @@ class YoutubeDL(object):
|
||||
new_info = dict(info_dict)
|
||||
new_info.update(format)
|
||||
self.process_info(new_info)
|
||||
format.update(new_info)
|
||||
# We update the info dict with the best quality format (backwards compatibility)
|
||||
info_dict.update(formats_to_download[-1])
|
||||
return info_dict
|
||||
|
@ -411,6 +411,7 @@ def _real_main(argv=None):
|
||||
'youtube_include_dash_manifest': opts.youtube_include_dash_manifest,
|
||||
'encoding': opts.encoding,
|
||||
'extract_flat': opts.extract_flat,
|
||||
'concat_playlist': opts.concat_playlist,
|
||||
'mark_watched': opts.mark_watched,
|
||||
'merge_output_format': opts.merge_output_format,
|
||||
'postprocessors': postprocessors,
|
||||
|
@ -9,6 +9,7 @@ import json
|
||||
import os.path
|
||||
import random
|
||||
import re
|
||||
import string
|
||||
import time
|
||||
import traceback
|
||||
|
||||
@ -67,6 +68,7 @@ from ..utils import (
|
||||
|
||||
class YoutubeBaseInfoExtractor(InfoExtractor):
|
||||
"""Provide base functions for Youtube extractors"""
|
||||
|
||||
_LOGIN_URL = 'https://accounts.google.com/ServiceLogin'
|
||||
_TWOFACTOR_URL = 'https://accounts.google.com/signin/challenge'
|
||||
|
||||
@ -138,7 +140,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
||||
[2, 1, None, 1,
|
||||
'https://accounts.google.com/ServiceLogin?passive=true&continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Fnext%3D%252F%26action_handle_signin%3Dtrue%26hl%3Den%26app%3Ddesktop%26feature%3Dsign_in_button&hl=en&service=youtube&uilel=3&requestPath=%2FServiceLogin&Page=PasswordSeparationSignIn',
|
||||
None, [], 4],
|
||||
1, [None, None, []], None, None, None, True
|
||||
1, [None, None, []], None, None, None, True,
|
||||
],
|
||||
username,
|
||||
]
|
||||
@ -160,7 +162,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
||||
None, 1, None, [1, None, None, None, [password, None, True]],
|
||||
[
|
||||
None, None, [2, 1, None, 1, 'https://accounts.google.com/ServiceLogin?passive=true&continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Fnext%3D%252F%26action_handle_signin%3Dtrue%26hl%3Den%26app%3Ddesktop%26feature%3Dsign_in_button&hl=en&service=youtube&uilel=3&requestPath=%2FServiceLogin&Page=PasswordSeparationSignIn', None, [], 4],
|
||||
1, [None, None, []], None, None, None, True
|
||||
1, [None, None, []], None, None, None, True,
|
||||
]]
|
||||
|
||||
challenge_results = req(
|
||||
@ -213,7 +215,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
||||
user_hash, None, 2, None,
|
||||
[
|
||||
9, None, None, None, None, None, None, None,
|
||||
[None, tfa_code, True, 2]
|
||||
[None, tfa_code, True, 2],
|
||||
]]
|
||||
|
||||
tfa_results = req(
|
||||
@ -284,7 +286,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
||||
'client': {
|
||||
'clientName': 'WEB',
|
||||
'clientVersion': '2.20201021.03.00',
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -385,7 +387,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
||||
'client': {
|
||||
'clientName': 'WEB',
|
||||
'clientVersion': '2.20201021.03.00',
|
||||
}
|
||||
},
|
||||
},
|
||||
'query': query,
|
||||
}
|
||||
@ -462,7 +464,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
||||
# (HTML, videodetails, metadata, renderers)
|
||||
'name': ('content', 'author', (('ownerChannelName', None), 'title'), ['text']),
|
||||
'url': ('href', 'ownerProfileUrl', 'vanityChannelUrl',
|
||||
['navigationEndpoint', 'browseEndpoint', 'canonicalBaseUrl'])
|
||||
['navigationEndpoint', 'browseEndpoint', 'canonicalBaseUrl']),
|
||||
}
|
||||
if any((videodetails, metadata, renderers)):
|
||||
result = (
|
||||
@ -671,7 +673,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||
'uploader_url': r're:https?://(?:www\.)?youtube\.com/user/8KVIDEO',
|
||||
'description': '',
|
||||
'uploader': '8KVIDEO',
|
||||
'title': 'UHDTV TEST 8K VIDEO.mp4'
|
||||
'title': 'UHDTV TEST 8K VIDEO.mp4',
|
||||
},
|
||||
'params': {
|
||||
'youtube_include_dash_manifest': True,
|
||||
@ -711,7 +713,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||
'uploader_url': r're:https?://(?:www\.)?youtube\.com/@theamazingatheist',
|
||||
'title': 'Burning Everyone\'s Koran',
|
||||
'description': 'SUBSCRIBE: http://www.youtube.com/saturninefilms \r\n\r\nEven Obama has taken a stand against freedom on this issue: http://www.huffingtonpost.com/2010/09/09/obama-gma-interview-quran_n_710282.html',
|
||||
}
|
||||
},
|
||||
},
|
||||
# Age-gated videos
|
||||
{
|
||||
@ -839,7 +841,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||
},
|
||||
'expected_warnings': [
|
||||
'DASH manifest missing',
|
||||
]
|
||||
],
|
||||
},
|
||||
# Olympics (https://github.com/ytdl-org/youtube-dl/issues/4431)
|
||||
{
|
||||
@ -1820,8 +1822,8 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||
|
||||
# cpn generation algorithm is reverse engineered from base.js.
|
||||
# In fact it works even with dummy cpn.
|
||||
CPN_ALPHABET = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_'
|
||||
cpn = ''.join(CPN_ALPHABET[random.randint(0, 256) & 63] for _ in range(0, 16))
|
||||
CPN_ALPHABET = string.ascii_letters + string.digits + '-_'
|
||||
cpn = ''.join(CPN_ALPHABET[random.randint(0, 256) & 63] for _ in range(16))
|
||||
|
||||
# more consistent results setting it to right before the end
|
||||
qs = parse_qs(playback_url)
|
||||
@ -1881,8 +1883,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||
mobj = re.match(cls._VALID_URL, url, re.VERBOSE)
|
||||
if mobj is None:
|
||||
raise ExtractorError('Invalid URL: %s' % url)
|
||||
video_id = mobj.group(2)
|
||||
return video_id
|
||||
return mobj.group(2)
|
||||
|
||||
def _extract_chapters_from_json(self, data, video_id, duration):
|
||||
chapters_list = try_get(
|
||||
@ -2035,7 +2036,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||
headers = {
|
||||
'X-YouTube-Client-Name': '85',
|
||||
'X-YouTube-Client-Version': '2.0',
|
||||
'Origin': 'https://www.youtube.com'
|
||||
'Origin': 'https://www.youtube.com',
|
||||
}
|
||||
|
||||
video_info = self._call_api('player', query, video_id, fatal=False, headers=headers)
|
||||
@ -2064,8 +2065,8 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||
return ''.join([r['text'] for r in runs if isinstance(r.get('text'), compat_str)])
|
||||
|
||||
search_meta = (
|
||||
lambda x: self._html_search_meta(x, webpage, default=None)) \
|
||||
if webpage else lambda x: None
|
||||
(lambda x: self._html_search_meta(x, webpage, default=None))
|
||||
if webpage else lambda _: None)
|
||||
|
||||
video_details = player_response.get('videoDetails') or {}
|
||||
microformat = try_get(
|
||||
@ -2137,7 +2138,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||
def build_fragments(f):
|
||||
return LazyList({
|
||||
'url': update_url_query(f['url'], {
|
||||
'range': '{0}-{1}'.format(range_start, min(range_start + CHUNK_SIZE - 1, f['filesize']))
|
||||
'range': '{0}-{1}'.format(range_start, min(range_start + CHUNK_SIZE - 1, f['filesize'])),
|
||||
})
|
||||
} for range_start in range(0, f['filesize'], CHUNK_SIZE))
|
||||
|
||||
@ -2236,7 +2237,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||
'protocol': 'http_dash_segments',
|
||||
'fragments': build_fragments(dct),
|
||||
} if dct['filesize'] else {
|
||||
'downloader_options': {'http_chunk_size': CHUNK_SIZE} # No longer useful?
|
||||
'downloader_options': {'http_chunk_size': CHUNK_SIZE}, # No longer useful?
|
||||
})
|
||||
|
||||
formats.append(dct)
|
||||
@ -2414,9 +2415,9 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||
'is_live': is_live,
|
||||
}
|
||||
|
||||
pctr = try_get(
|
||||
pctr = traverse_obj(
|
||||
player_response,
|
||||
lambda x: x['captions']['playerCaptionsTracklistRenderer'], dict)
|
||||
('captions', 'playerCaptionsTracklistRenderer', T(dict)))
|
||||
if pctr:
|
||||
def process_language(container, base_url, lang_code, query):
|
||||
lang_subs = []
|
||||
@ -2430,9 +2431,11 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||
})
|
||||
container[lang_code] = lang_subs
|
||||
|
||||
def process_subtitles():
|
||||
subtitles = {}
|
||||
for caption_track in (pctr.get('captionTracks') or []):
|
||||
base_url = caption_track.get('baseUrl')
|
||||
for caption_track in traverse_obj(pctr, (
|
||||
'captionTracks', lambda _, v: v.get('baseUrl'))):
|
||||
base_url = self._yt_urljoin(caption_track['baseUrl'])
|
||||
if not base_url:
|
||||
continue
|
||||
if caption_track.get('kind') != 'asr':
|
||||
@ -2443,18 +2446,19 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||
subtitles, base_url, lang_code, {})
|
||||
continue
|
||||
automatic_captions = {}
|
||||
for translation_language in (pctr.get('translationLanguages') or []):
|
||||
translation_language_code = translation_language.get('languageCode')
|
||||
if not translation_language_code:
|
||||
continue
|
||||
for translation_language in traverse_obj(pctr, (
|
||||
'translationLanguages', lambda _, v: v.get('languageCode'))):
|
||||
translation_language_code = translation_language['languageCode']
|
||||
process_language(
|
||||
automatic_captions, base_url, translation_language_code,
|
||||
{'tlang': translation_language_code})
|
||||
info['automatic_captions'] = automatic_captions
|
||||
info['subtitles'] = subtitles
|
||||
|
||||
process_subtitles()
|
||||
|
||||
parsed_url = compat_urllib_parse_urlparse(url)
|
||||
for component in [parsed_url.fragment, parsed_url.query]:
|
||||
for component in (parsed_url.fragment, parsed_url.query):
|
||||
query = compat_parse_qs(component)
|
||||
for k, v in query.items():
|
||||
for d_k, s_ks in [('start', ('start', 't')), ('end', ('end',))]:
|
||||
@ -2684,7 +2688,7 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
|
||||
'title': 'Super Cooper Shorts - Shorts',
|
||||
'uploader': 'Super Cooper Shorts',
|
||||
'uploader_id': '@SuperCooperShorts',
|
||||
}
|
||||
},
|
||||
}, {
|
||||
# Channel that does not have a Shorts tab. Test should just download videos on Home tab instead
|
||||
'url': 'https://www.youtube.com/@emergencyawesome/shorts',
|
||||
@ -2738,7 +2742,7 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
|
||||
'description': 'md5:609399d937ea957b0f53cbffb747a14c',
|
||||
'uploader': 'ThirstForScience',
|
||||
'uploader_id': '@ThirstForScience',
|
||||
}
|
||||
},
|
||||
}, {
|
||||
'url': 'https://www.youtube.com/c/ChristophLaimer/playlists',
|
||||
'only_matching': True,
|
||||
@ -3037,7 +3041,7 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
|
||||
'uploader': '3Blue1Brown',
|
||||
'uploader_id': '@3blue1brown',
|
||||
'channel_id': 'UCYO_jab_esuFRV4b17AJtAw',
|
||||
}
|
||||
},
|
||||
}]
|
||||
|
||||
@classmethod
|
||||
@ -3335,7 +3339,7 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
|
||||
'client': {
|
||||
'clientName': 'WEB',
|
||||
'clientVersion': client_version,
|
||||
}
|
||||
},
|
||||
}
|
||||
visitor_data = try_get(context, lambda x: x['client']['visitorData'], compat_str)
|
||||
|
||||
@ -3354,7 +3358,7 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
|
||||
headers['x-goog-visitor-id'] = visitor_data
|
||||
data['continuation'] = continuation['continuation']
|
||||
data['clickTracking'] = {
|
||||
'clickTrackingParams': continuation['itct']
|
||||
'clickTrackingParams': continuation['itct'],
|
||||
}
|
||||
count = 0
|
||||
retries = 3
|
||||
@ -3613,7 +3617,7 @@ class YoutubePlaylistIE(InfoExtractor):
|
||||
'uploader': 'milan',
|
||||
'uploader_id': '@milan5503',
|
||||
'channel_id': 'UCEI1-PVPcYXjB73Hfelbmaw',
|
||||
}
|
||||
},
|
||||
}, {
|
||||
'url': 'http://www.youtube.com/embed/_xDOZElKyNU?list=PLsyOSbh5bs16vubvKePAQ1x3PhKavfBIl',
|
||||
'playlist_mincount': 455,
|
||||
@ -3623,7 +3627,7 @@ class YoutubePlaylistIE(InfoExtractor):
|
||||
'uploader': 'LBK',
|
||||
'uploader_id': '@music_king',
|
||||
'channel_id': 'UC21nz3_MesPLqtDqwdvnoxA',
|
||||
}
|
||||
},
|
||||
}, {
|
||||
'url': 'TLGGrESM50VT6acwMjAyMjAxNw',
|
||||
'only_matching': True,
|
||||
@ -3734,7 +3738,7 @@ class YoutubeSearchIE(SearchInfoExtractor, YoutubeBaseInfoExtractor):
|
||||
'info_dict': {
|
||||
'id': 'youtube-dl test video',
|
||||
'title': 'youtube-dl test video',
|
||||
}
|
||||
},
|
||||
}]
|
||||
|
||||
def _get_n_results(self, query, n):
|
||||
@ -3754,7 +3758,7 @@ class YoutubeSearchDateIE(YoutubeSearchIE):
|
||||
'info_dict': {
|
||||
'id': 'youtube-dl test video',
|
||||
'title': 'youtube-dl test video',
|
||||
}
|
||||
},
|
||||
}]
|
||||
|
||||
|
||||
@ -3769,7 +3773,7 @@ class YoutubeSearchURLIE(YoutubeBaseInfoExtractor):
|
||||
'id': 'youtube-dl test video',
|
||||
'title': 'youtube-dl test video',
|
||||
},
|
||||
'params': {'playlistend': 5}
|
||||
'params': {'playlistend': 5},
|
||||
}, {
|
||||
'url': 'https://www.youtube.com/results?q=test&sp=EgQIBBgB',
|
||||
'only_matching': True,
|
||||
@ -3785,6 +3789,7 @@ class YoutubeSearchURLIE(YoutubeBaseInfoExtractor):
|
||||
class YoutubeFeedsInfoExtractor(YoutubeTabIE):
|
||||
"""
|
||||
Base class for feed extractors
|
||||
|
||||
Subclasses must define the _FEED_NAME property.
|
||||
"""
|
||||
_LOGIN_REQUIRED = True
|
||||
|
@ -183,6 +183,11 @@ def parseOpts(overrideArguments=None):
|
||||
action='store_const', dest='extract_flat', const='in_playlist',
|
||||
default=False,
|
||||
help='Do not extract the videos of a playlist, only list them.')
|
||||
general.add_option(
|
||||
'--concat-playlist',
|
||||
action='store_true', dest='concat_playlist', default=False,
|
||||
help='Concatenate all videos in a playlist into a single video file. Useful for services which split up full '
|
||||
'episodes into multiple segments.')
|
||||
general.add_option(
|
||||
'--mark-watched',
|
||||
action='store_true', dest='mark_watched', default=False,
|
||||
|
@ -9,6 +9,7 @@ from .ffmpeg import (
|
||||
FFmpegFixupM3u8PP,
|
||||
FFmpegFixupM4aPP,
|
||||
FFmpegMergerPP,
|
||||
FFmpegConcatPP,
|
||||
FFmpegMetadataPP,
|
||||
FFmpegVideoConvertorPP,
|
||||
FFmpegSubtitlesConvertorPP,
|
||||
@ -31,6 +32,7 @@ __all__ = [
|
||||
'FFmpegFixupM4aPP',
|
||||
'FFmpegFixupStretchedPP',
|
||||
'FFmpegMergerPP',
|
||||
'FFmpegConcatPP',
|
||||
'FFmpegMetadataPP',
|
||||
'FFmpegPostProcessor',
|
||||
'FFmpegSubtitlesConvertorPP',
|
||||
|
@ -84,7 +84,7 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
|
||||
|
||||
self._downloader.to_screen('[ffmpeg] Adding thumbnail to "%s"' % filename)
|
||||
|
||||
self.run_ffmpeg_multiple_files([filename, thumbnail_filename], temp_filename, options)
|
||||
self.run_ffmpeg_multiple_files([filename, thumbnail_filename], temp_filename, options, [])
|
||||
|
||||
if not self._already_have_thumbnail:
|
||||
os.remove(encodeFilename(thumbnail_filename))
|
||||
|
@ -5,7 +5,6 @@ import subprocess
|
||||
import time
|
||||
import re
|
||||
|
||||
|
||||
from .common import AudioConversionError, PostProcessor
|
||||
|
||||
from ..compat import compat_open as open
|
||||
@ -24,7 +23,6 @@ from ..utils import (
|
||||
replace_extension,
|
||||
)
|
||||
|
||||
|
||||
EXT_TO_OUT_FORMATS = {
|
||||
'aac': 'adts',
|
||||
'flac': 'flac',
|
||||
@ -196,7 +194,7 @@ class FFmpegPostProcessor(PostProcessor):
|
||||
return mobj.group(1)
|
||||
return None
|
||||
|
||||
def run_ffmpeg_multiple_files(self, input_paths, out_path, opts):
|
||||
def run_ffmpeg_multiple_files(self, input_paths, out_path, opts, file_opts):
|
||||
self.check_version()
|
||||
|
||||
oldest_mtime = min(
|
||||
@ -207,6 +205,7 @@ class FFmpegPostProcessor(PostProcessor):
|
||||
files_cmd = []
|
||||
for path in input_paths:
|
||||
files_cmd.extend([
|
||||
*file_opts,
|
||||
encodeArgument('-i'),
|
||||
encodeFilename(self._ffmpeg_filename_argument(path), True)
|
||||
])
|
||||
@ -231,8 +230,8 @@ class FFmpegPostProcessor(PostProcessor):
|
||||
raise FFmpegPostProcessorError(msg)
|
||||
self.try_utime(out_path, oldest_mtime, oldest_mtime)
|
||||
|
||||
def run_ffmpeg(self, path, out_path, opts):
|
||||
self.run_ffmpeg_multiple_files([path], out_path, opts)
|
||||
def run_ffmpeg(self, path, out_path, opts, file_opts):
|
||||
self.run_ffmpeg_multiple_files([path], out_path, opts, file_opts)
|
||||
|
||||
def _ffmpeg_filename_argument(self, fn):
|
||||
# Always use 'file:' because the filename may contain ':' (ffmpeg
|
||||
@ -270,7 +269,8 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor):
|
||||
raise PostProcessingError('WARNING: unable to obtain file audio codec with ffprobe')
|
||||
|
||||
more_opts = []
|
||||
if self._preferredcodec == 'best' or self._preferredcodec == filecodec or (self._preferredcodec == 'm4a' and filecodec == 'aac'):
|
||||
if self._preferredcodec == 'best' or self._preferredcodec == filecodec or (
|
||||
self._preferredcodec == 'm4a' and filecodec == 'aac'):
|
||||
if filecodec == 'aac' and self._preferredcodec in ['m4a', 'best']:
|
||||
# Lossless, but in another container
|
||||
acodec = 'copy'
|
||||
@ -315,7 +315,8 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor):
|
||||
extension = 'wav'
|
||||
more_opts += ['-f', 'wav']
|
||||
|
||||
prefix, sep, ext = path.rpartition('.') # not os.path.splitext, since the latter does not work on unicode in all setups
|
||||
prefix, sep, ext = path.rpartition(
|
||||
'.') # not os.path.splitext, since the latter does not work on unicode in all setups
|
||||
new_path = prefix + sep + extension
|
||||
|
||||
information['filepath'] = new_path
|
||||
@ -353,14 +354,16 @@ class FFmpegVideoConvertorPP(FFmpegPostProcessor):
|
||||
def run(self, information):
|
||||
path = information['filepath']
|
||||
if information['ext'] == self._preferedformat:
|
||||
self._downloader.to_screen('[ffmpeg] Not converting video file %s - already is in target format %s' % (path, self._preferedformat))
|
||||
self._downloader.to_screen(
|
||||
'[ffmpeg] Not converting video file %s - already is in target format %s' % (path, self._preferedformat))
|
||||
return [], information
|
||||
options = []
|
||||
if self._preferedformat == 'avi':
|
||||
options.extend(['-c:v', 'libxvid', '-vtag', 'XVID'])
|
||||
prefix, sep, ext = path.rpartition('.')
|
||||
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) + outpath)
|
||||
self.run_ffmpeg(path, outpath, options)
|
||||
information['filepath'] = outpath
|
||||
information['format'] = self._preferedformat
|
||||
@ -419,7 +422,7 @@ class FFmpegEmbedSubtitlePP(FFmpegPostProcessor):
|
||||
|
||||
temp_filename = prepend_extension(filename, 'temp')
|
||||
self._downloader.to_screen('[ffmpeg] Embedding subtitles in \'%s\'' % filename)
|
||||
self.run_ffmpeg_multiple_files(input_files, temp_filename, opts)
|
||||
self.run_ffmpeg_multiple_files(input_files, temp_filename, opts, [])
|
||||
os.remove(encodeFilename(filename))
|
||||
os.rename(encodeFilename(temp_filename), encodeFilename(filename))
|
||||
|
||||
@ -502,7 +505,7 @@ class FFmpegMetadataPP(FFmpegPostProcessor):
|
||||
options.extend(['-map_metadata', '1'])
|
||||
|
||||
self._downloader.to_screen('[ffmpeg] Adding metadata to \'%s\'' % filename)
|
||||
self.run_ffmpeg_multiple_files(in_filenames, temp_filename, options)
|
||||
self.run_ffmpeg_multiple_files(in_filenames, temp_filename, options, [])
|
||||
if chapters:
|
||||
os.remove(metadata_filename)
|
||||
os.remove(encodeFilename(filename))
|
||||
@ -516,7 +519,7 @@ class FFmpegMergerPP(FFmpegPostProcessor):
|
||||
temp_filename = prepend_extension(filename, 'temp')
|
||||
args = ['-c', 'copy', '-map', '0:v:0', '-map', '1:a:0']
|
||||
self._downloader.to_screen('[ffmpeg] Merging formats into "%s"' % filename)
|
||||
self.run_ffmpeg_multiple_files(info['__files_to_merge'], temp_filename, args)
|
||||
self.run_ffmpeg_multiple_files(info['__files_to_merge'], temp_filename, args, [])
|
||||
os.rename(encodeFilename(temp_filename), encodeFilename(filename))
|
||||
return info['__files_to_merge'], info
|
||||
|
||||
@ -538,6 +541,29 @@ class FFmpegMergerPP(FFmpegPostProcessor):
|
||||
return True
|
||||
|
||||
|
||||
class FFmpegConcatPP(FFmpegPostProcessor):
|
||||
def run(self, info):
|
||||
filename = info['filepath']
|
||||
|
||||
list_filename = prepend_extension(filename, 'list')
|
||||
temp_filename = prepend_extension(filename, 'temp')
|
||||
|
||||
with open(list_filename, 'wt') as f:
|
||||
f.write('ffconcat version 1.0\n')
|
||||
for file in info['__files_to_concat']:
|
||||
f.write("file '%s'\n" % self._ffmpeg_filename_argument(file))
|
||||
|
||||
file_opts = ['-f', 'concat', '-safe', '0']
|
||||
opts = ['-c', 'copy']
|
||||
self._downloader.to_screen('[ffmpeg] Concatenating files into "%s"' % filename)
|
||||
self.run_ffmpeg(list_filename, temp_filename, opts, file_opts)
|
||||
os.rename(encodeFilename(temp_filename), encodeFilename(filename))
|
||||
return info['__files_to_concat'], info
|
||||
|
||||
def can_merge(self):
|
||||
return True
|
||||
|
||||
|
||||
class FFmpegFixupStretchedPP(FFmpegPostProcessor):
|
||||
def run(self, info):
|
||||
stretched_ratio = info.get('stretched_ratio')
|
||||
@ -583,7 +609,7 @@ class FFmpegFixupM3u8PP(FFmpegPostProcessor):
|
||||
|
||||
options = ['-c', 'copy', '-f', 'mp4', '-bsf:a', 'aac_adtstoasc']
|
||||
self._downloader.to_screen('[ffmpeg] Fixing malformed AAC bitstream in "%s"' % filename)
|
||||
self.run_ffmpeg(filename, temp_filename, options)
|
||||
self.run_ffmpeg(filename, temp_filename, options, [])
|
||||
|
||||
os.remove(encodeFilename(filename))
|
||||
os.rename(encodeFilename(temp_filename), encodeFilename(filename))
|
||||
|
Loading…
Reference in New Issue
Block a user