mirror of
https://github.com/soimort/you-get.git
synced 2025-02-03 00:33:58 +03:00
Merge branch 'ffmpeg-live' of https://github.com/cnbeining/you-get into cnbeining-ffmpeg-live
This commit is contained in:
commit
2fdea30d8d
@ -899,6 +899,23 @@ def download_rtmp_url(url,title, ext,params={}, total_size=0, output_dir='.', re
|
|||||||
assert has_rtmpdump_installed(), "RTMPDump not installed."
|
assert has_rtmpdump_installed(), "RTMPDump not installed."
|
||||||
download_rtmpdump_stream(url, title, ext,params, output_dir)
|
download_rtmpdump_stream(url, title, ext,params, output_dir)
|
||||||
|
|
||||||
|
def download_url_ffmpeg(url,title, ext,params={}, total_size=0, output_dir='.', refer=None, merge=True, faker=False):
|
||||||
|
assert url
|
||||||
|
if dry_run:
|
||||||
|
print('Real URL:\n%s\n' % [url])
|
||||||
|
if params.get("-y",False): #None or unset ->False
|
||||||
|
print('Real Playpath:\n%s\n' % [params.get("-y")])
|
||||||
|
return
|
||||||
|
|
||||||
|
if player:
|
||||||
|
from .processor.ffmpeg import ffmpeg_play_stream
|
||||||
|
ffmpeg_play_stream(player, url, params)
|
||||||
|
return
|
||||||
|
|
||||||
|
from .processor.ffmpeg import has_ffmpeg_installed, ffmpeg_download_streaming
|
||||||
|
assert has_ffmpeg_installed(), "FFmpeg not installed."
|
||||||
|
ffmpeg_download_stream(url, title, ext, params, output_dir)
|
||||||
|
|
||||||
def playlist_not_supported(name):
|
def playlist_not_supported(name):
|
||||||
def f(*args, **kwargs):
|
def f(*args, **kwargs):
|
||||||
raise NotImplementedError('Playlist is not supported for ' + name)
|
raise NotImplementedError('Playlist is not supported for ' + name)
|
||||||
|
2
src/you_get/extractors/iqiyi.py
Normal file → Executable file
2
src/you_get/extractors/iqiyi.py
Normal file → Executable file
@ -246,4 +246,4 @@ class Iqiyi(VideoExtractor):
|
|||||||
site = Iqiyi()
|
site = Iqiyi()
|
||||||
download = site.download_by_url
|
download = site.download_by_url
|
||||||
iqiyi_download_by_vid = site.download_by_vid
|
iqiyi_download_by_vid = site.download_by_vid
|
||||||
download_playlist = site.download_playlist_by_url
|
download_playlist = site.download_playlist_by_url
|
@ -199,3 +199,81 @@ def ffmpeg_concat_mp4_to_mp4(files, output='output.mp4'):
|
|||||||
for file in files:
|
for file in files:
|
||||||
os.remove(file + '.ts')
|
os.remove(file + '.ts')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def ffmpeg_download_stream(files, title, ext, params={}, output_dir='.'):
|
||||||
|
"""str, str->True
|
||||||
|
WARNING: NOT THE SAME PARMS AS OTHER FUNCTIONS!!!!!!
|
||||||
|
You can basicly download anything with this function
|
||||||
|
but better leave it alone with
|
||||||
|
"""
|
||||||
|
output = title + '.' + ext
|
||||||
|
|
||||||
|
if not (output_dir == '.'):
|
||||||
|
output = output_dir + output
|
||||||
|
|
||||||
|
ffmpeg_params = []
|
||||||
|
#should these exist...
|
||||||
|
if len(params) > 0:
|
||||||
|
for k, v in params:
|
||||||
|
ffmpeg_params.append(k)
|
||||||
|
ffmpeg_params.append(v)
|
||||||
|
|
||||||
|
print('Downloading streaming content with FFmpeg, press q to stop recording...')
|
||||||
|
ffmpeg_params = [FFMPEG] + ['-y', '-re', '-i']
|
||||||
|
ffmpeg_params.append(files) #not the same here!!!!
|
||||||
|
|
||||||
|
if FFMPEG == 'avconv': #who cares?
|
||||||
|
ffmpeg_params += ['-c', 'copy', output]
|
||||||
|
else:
|
||||||
|
ffmpeg_params += ['-c', 'copy', '-bsf:a', 'aac_adtstoasc']
|
||||||
|
|
||||||
|
ffmpeg_params.append(output)
|
||||||
|
|
||||||
|
print(' '.join(ffmpeg_params))
|
||||||
|
|
||||||
|
try:
|
||||||
|
a = subprocess.Popen(ffmpeg_params, stdin= subprocess.PIPE)
|
||||||
|
a.communicate()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
try:
|
||||||
|
a.stdin.write('q'.encode('utf-8'))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
#
|
||||||
|
#To be refactor
|
||||||
|
#Direct copy of rtmpdump.py
|
||||||
|
#
|
||||||
|
def ffmpeg_play_stream(player, url, params={}):
|
||||||
|
ffmpeg_params = []
|
||||||
|
#should these exist...
|
||||||
|
if len(params) > 0:
|
||||||
|
for k, v in params:
|
||||||
|
ffmpeg_params.append(k)
|
||||||
|
ffmpeg_params.append(v)
|
||||||
|
|
||||||
|
print('Playing streaming content with FFmpeg, press 1 to stop recording...')
|
||||||
|
ffmpeg_params = [FFMPEG] + LOGLEVEL + ['-y', '-re', '-i']
|
||||||
|
ffmpeg_params.append(url) #not the same here!!!!
|
||||||
|
|
||||||
|
if FFMPEG == 'avconv': #who cares?
|
||||||
|
ffmpeg_params += ['-c', 'copy', '|']
|
||||||
|
else:
|
||||||
|
ffmpeg_params += ['-c', 'copy', '-bsf:a', 'aac_adtstoasc', '|']
|
||||||
|
|
||||||
|
ffmpeg_params += [player, '-']
|
||||||
|
|
||||||
|
print(' '.join(ffmpeg_params))
|
||||||
|
|
||||||
|
try:
|
||||||
|
a = subprocess.Popen(ffmpeg_params, stdin= subprocess.PIPE)
|
||||||
|
a.communicate()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
try:
|
||||||
|
a.stdin.write('q'.encode('utf-8'))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return True
|
@ -43,6 +43,7 @@ def download_rtmpdump_stream(url, title, ext,params={},output_dir='.'):
|
|||||||
|
|
||||||
#
|
#
|
||||||
#To be refactor
|
#To be refactor
|
||||||
|
#To the future myself: Remember to refactor the same function in ffmpeg.py
|
||||||
#
|
#
|
||||||
def play_rtmpdump_stream(player, url, params={}):
|
def play_rtmpdump_stream(player, url, params={}):
|
||||||
cmdline="rtmpdump -r '%s' "%url
|
cmdline="rtmpdump -r '%s' "%url
|
||||||
|
Loading…
Reference in New Issue
Block a user