mirror of
https://github.com/soimort/you-get.git
synced 2025-03-13 03:17:44 +03:00
[ffmpeg] remove unuseful ffmpeg_play_stream(), fix #1336
This commit is contained in:
parent
c6784f2fb8
commit
3a8ce8819d
@ -910,8 +910,7 @@ def download_url_ffmpeg(url,title, ext,params={}, total_size=0, output_dir='.',
|
|||||||
return
|
return
|
||||||
|
|
||||||
if player:
|
if player:
|
||||||
from .processor.ffmpeg import ffmpeg_play_stream
|
launch_player(player, [url])
|
||||||
ffmpeg_play_stream(player, url, params)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
from .processor.ffmpeg import has_ffmpeg_installed, ffmpeg_download_stream
|
from .processor.ffmpeg import has_ffmpeg_installed, ffmpeg_download_stream
|
||||||
@ -1218,12 +1217,12 @@ def script_main(script_name, download, download_playlist, **kwargs):
|
|||||||
import socket
|
import socket
|
||||||
import socks
|
import socks
|
||||||
socks_proxy_addrs = socks_proxy.split(':')
|
socks_proxy_addrs = socks_proxy.split(':')
|
||||||
socks.set_default_proxy(socks.SOCKS5,
|
socks.set_default_proxy(socks.SOCKS5,
|
||||||
socks_proxy_addrs[0],
|
socks_proxy_addrs[0],
|
||||||
int(socks_proxy_addrs[1]))
|
int(socks_proxy_addrs[1]))
|
||||||
socket.socket = socks.socksocket
|
socket.socket = socks.socksocket
|
||||||
def getaddrinfo(*args):
|
def getaddrinfo(*args):
|
||||||
return [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))]
|
return [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))]
|
||||||
socket.getaddrinfo = getaddrinfo
|
socket.getaddrinfo = getaddrinfo
|
||||||
except ImportError:
|
except ImportError:
|
||||||
log.w('Error importing PySocks library, socks proxy ignored.'
|
log.w('Error importing PySocks library, socks proxy ignored.'
|
||||||
|
@ -204,13 +204,13 @@ def ffmpeg_download_stream(files, title, ext, params={}, output_dir='.'):
|
|||||||
"""str, str->True
|
"""str, str->True
|
||||||
WARNING: NOT THE SAME PARMS AS OTHER FUNCTIONS!!!!!!
|
WARNING: NOT THE SAME PARMS AS OTHER FUNCTIONS!!!!!!
|
||||||
You can basicly download anything with this function
|
You can basicly download anything with this function
|
||||||
but better leave it alone with
|
but better leave it alone with
|
||||||
"""
|
"""
|
||||||
output = title + '.' + ext
|
output = title + '.' + ext
|
||||||
|
|
||||||
if not (output_dir == '.'):
|
if not (output_dir == '.'):
|
||||||
output = output_dir + '/' + output
|
output = output_dir + '/' + output
|
||||||
|
|
||||||
ffmpeg_params = []
|
ffmpeg_params = []
|
||||||
#should these exist...
|
#should these exist...
|
||||||
if params is not None:
|
if params is not None:
|
||||||
@ -219,20 +219,20 @@ def ffmpeg_download_stream(files, title, ext, params={}, output_dir='.'):
|
|||||||
ffmpeg_params.append(k)
|
ffmpeg_params.append(k)
|
||||||
ffmpeg_params.append(v)
|
ffmpeg_params.append(v)
|
||||||
|
|
||||||
|
|
||||||
print('Downloading streaming content with FFmpeg, press q to stop recording...')
|
print('Downloading streaming content with FFmpeg, press q to stop recording...')
|
||||||
ffmpeg_params = [FFMPEG] + ['-y', '-re', '-i']
|
ffmpeg_params = [FFMPEG] + ['-y', '-re', '-i']
|
||||||
ffmpeg_params.append(files) #not the same here!!!!
|
ffmpeg_params.append(files) #not the same here!!!!
|
||||||
|
|
||||||
if FFMPEG == 'avconv': #who cares?
|
if FFMPEG == 'avconv': #who cares?
|
||||||
ffmpeg_params += ['-c', 'copy', output]
|
ffmpeg_params += ['-c', 'copy', output]
|
||||||
else:
|
else:
|
||||||
ffmpeg_params += ['-c', 'copy', '-bsf:a', 'aac_adtstoasc']
|
ffmpeg_params += ['-c', 'copy', '-bsf:a', 'aac_adtstoasc']
|
||||||
|
|
||||||
ffmpeg_params.append(output)
|
ffmpeg_params.append(output)
|
||||||
|
|
||||||
print(' '.join(ffmpeg_params))
|
print(' '.join(ffmpeg_params))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
a = subprocess.Popen(ffmpeg_params, stdin= subprocess.PIPE)
|
a = subprocess.Popen(ffmpeg_params, stdin= subprocess.PIPE)
|
||||||
a.communicate()
|
a.communicate()
|
||||||
@ -243,41 +243,3 @@ def ffmpeg_download_stream(files, title, ext, params={}, output_dir='.'):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
#
|
|
||||||
#To be refactor
|
|
||||||
#Direct copy of rtmpdump.py
|
|
||||||
#
|
|
||||||
def ffmpeg_play_stream(player, url, params={}):
|
|
||||||
ffmpeg_params = []
|
|
||||||
#should these exist...
|
|
||||||
if params is not None:
|
|
||||||
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
|
|
Loading…
x
Reference in New Issue
Block a user