Пример #1
0
def muxer_worker():
    global redis
    global onset_dicts, onset_dir, X, Y, Z

    while True:
        try:
            yt_url = redis.lpop('yturls')
            if yt_url is None:
                time.sleep(10)
            else:
                m = Muxer(yt_url=yt_url)
                m.download_video()
                with open(
                    '{output_dir}/{ytid}.status.json'.format(output_dir=output_dir, ytid=m.ytid), 'w'
                ) as f:
                    f.write('{"status": "processing", "stage": 1}')
                m.demux()
                with open(
                    '{output_dir}/{ytid}.status.json'.format(output_dir=output_dir, ytid=m.ytid), 'w'
                ) as f:
                    f.write('{"status": "processing", "stage": 2}')
                m.convert_to_wav()
                with open(
                    '{output_dir}/{ytid}.status.json'.format(output_dir=output_dir, ytid=m.ytid), 'w'
                ) as f:
                    f.write('{"status": "processing", "stage": 3}')
                # XXX: Call meshuggahfier here, and use its output in place of m.get_audio_file()
                meshuggahfied_file = '{output_path}/{ytid}mm.wav'.format(
                    output_path=m.output_dir, ytid=m.ytid
                )
                if not os.path.exists(meshuggahfied_file):
                    meshuggahme(
                        m.get_audio_file(),
                        X, improve_func=improve_log_no_loudness,
                        onset_dicts=onset_dicts, onset_dir=onset_dir,
                        metric='correlation', output_file=meshuggahfied_file,
                        original_w=10
                    )
                with open(
                    '{output_dir}/{ytid}.status.json'.format(output_dir=output_dir, ytid=m.ytid), 'w'
                ) as f:
                    f.write('{"status": "processing", "stage": 4}')
                meshuggahfied_file = m.compress_wav(meshuggahfied_file)
                with open(
                    '{output_dir}/{ytid}.status.json'.format(output_dir=output_dir, ytid=m.ytid), 'w'
                ) as f:
                    f.write('{"status": "processing", "stage": 5}')
                m.remux(meshuggahfied_file).split('/')[-1]
                with open(
                    '{output_dir}/{ytid}.status.json'.format(output_dir=output_dir, ytid=m.ytid), 'w'
                ) as f:
                    f.write('{"status": "complete"}')
        except Exception as e:
            print repr(e)
Пример #2
0
#!/usr/bin/env python

import os

os.environ['MESHUGGAHME_AVCONV_PATH'] = '/usr/bin/avconv'
os.environ['MESHUGGAHME_YTDL_PATH'] = '/home/phaedrus/repos/meshuggahme/muxer/youtube-dl'
os.environ['MESHUGGAHME_DL_PATH'] = '/home/phaedrus/tmp/meshuggahme/dl'
os.environ['MESHUGGAHME_OUTPUT_PATH'] = '/home/phaedrus/tmp/meshuggahme/out'

from muxer import Muxer

gojira = 'https://www.youtube.com/watch?v=BGHlZwMYO9g'
#spears = 'https://www.youtube.com/watch?v=LOZuxwVk7TU'
spears = 'https://youtu.be/LOZuxwVk7TU'

if __name__ == '__main__':
    gojira_muxer = Muxer(yt_url=gojira)
    spears_muxer = Muxer(yt_url=spears)

    gojira_muxer.download_video()
    spears_muxer.download_video()

    gojira_muxer.demux()
    spears_muxer.demux()

    spears_muxer.remux(gojira_muxer.get_audio_file())