I'm developing a basic application which can download YouTube videos. Throughout the development, I had several quirks, including issues with formats.
I decided to use a hopefully foolproof format syntax that youtube-dl will happily download for me in almost any case.
Part of my YoutubeDL options look like this:
self.ydl_opts = {
'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best',
'quiet': True,
'progress_hooks': [self.ydl_progress],
'outtmpl': None
}
The outtmpl is inserted later on when output folder is chosen by the user.
Since I'm using this format string, youtube-dl uses ffmpeg to merge(?) the audio and video if they are downloaded separately.
When it does that, it opens very annoying console windows that capture the focus and interrupt other things I might be doing while the videos are downloading.
My question is, how can I prevent ffmpeg or youtube-dl from creating those console windows from appearing, aka. how can I hide them?
EDIT:
I'll provide bare bones script that reproduces the problem:
from __future__ import unicode_literals
from PyQt4 import QtGui, QtCore
import youtube_dl, sys
def on_progress(info):
print info.get("_percent_str", "Finished")
ydl_opts = {
'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best',
'progress_hooks': [on_progress],
'quiet': True,
'outtmpl': "C:/Users/Raketa/Desktop/%(title)s.%(ext)s"
}
ydl = youtube_dl.YoutubeDL(ydl_opts)
class DownloadThread(QtCore.QThread):
def __init__(self):
super(DownloadThread, self).__init__()
self.start()
def __del__(self):
self.wait()
def run(self):
print "Download start"
ydl.download(["https://www.youtube.com/watch?v=uy7BiiOI_No"])
print "Download end"
class Application(QtGui.QMainWindow):
def __init__(self):
super(Application, self).__init__()
self.dl_thread = DownloadThread()
def run(self):
self.show()
def main():
master = QtGui.QApplication(sys.argv)
app = Application()
app.run()
sys.exit(master.exec_())
if __name__ == '__main__':
main()
2(?) consoles appear at start of each download and 1 longer lasting console appears when both video and audio are downloaded. When downloading longer videos, the last console becomes unbearable.
Is it possible to get rid of those?