Compare commits

...

3 Commits

Author SHA1 Message Date
j 19b54d57cb include sound adjustments
Front L & R: +3.0
Centre: -14.0
Rear: L & R +3.0
Wall (Back): L & R -8.0 (These is the stereo pair attached to the "original" clips)
2024-03-22 14:25:13 +01:00
j d72bf343e3 adjust levels
- Melody (Ban's vocals) (+ 1 db)
- Ashley (Ban's vocals) (- 0.75 db)
2024-03-22 14:13:16 +01:00
j ed03c7026a sync to hour, play sax inline, add s/p keybindings 2024-03-22 14:10:07 +01:00
4 changed files with 62 additions and 12 deletions

View File

@ -8,6 +8,7 @@ import time
from threading import Thread
from datetime import datetime
import ox
import mpv
@ -53,11 +54,22 @@ class Sync(Thread):
def __init__(self, *args, **kwargs):
self.is_main = kwargs.get('mode', 'main') == 'main'
self.start_at_hour = kwargs.get("hour", False)
self.sock = self.init_socket()
self.main = Main()
if self.is_main:
self.socket_enable_broadcast()
if kwargs.get("sax"):
self.sax = mpv.MPV(
log_handler=mpv_log, input_default_bindings=True,
input_vo_keyboard=True,
)
self.sax.loop_file = True
self.sax.play("/srv/t_for_time/render/Saxophone-5.1.mp4")
else:
self.sax = None
if mpv.MPV_VERSION >= (2, 2):
self.mpv = mpv.MPV(
log_handler=mpv_log, input_default_bindings=True,
@ -79,6 +91,8 @@ class Sync(Thread):
self.mpv.loop_file = False
self.mpv.loop_playlist = True
self.mpv.register_key_binding('q', self.q_binding)
self.mpv.register_key_binding('s', self.s_binding)
self.mpv.register_key_binding('p', self.p_binding)
self.playlist = kwargs['playlist']
self.playlist_mtime = os.stat(self.playlist).st_mtime
self.mpv.loadlist(self.playlist)
@ -90,6 +104,30 @@ class Sync(Thread):
time.sleep(0.1)
self.mpv.pause = True
self.sync_to_main()
elif self.start_at_hour:
self.mpv.pause = True
fmt = '%Y-%m-%d %H'
now = datetime.now()
offset = (now - datetime.strptime(now.strftime(fmt), fmt)).total_seconds()
if self.sax:
self.sax.seek(offset, 'absolute', 'exact')
self.sax.pause = True
position = 0
for idx, item in enumerate(self.mpv.playlist):
duration = ox.avinfo(item['filename'])['duration']
if position + duration > offset:
pos = offset - position
self.mpv.playlist_play_index(idx)
self.mpv.pause = False
self.mpv.wait_until_playing()
self.mpv.seek(pos, 'absolute', 'exact')
time.sleep(0.1)
break
else:
position += duration
if self.sax:
self.sax.pause = False
self.ready = True
Thread.__init__(self)
self.start()
@ -116,6 +154,16 @@ class Sync(Thread):
self.stop()
self.mpv.stop()
def s_binding(self, *args):
self.mpv.pause = True
if self.sax:
self.sax.pause = True
def p_binding(self, *args):
self.mpv.pause = False
if self.sax:
self.sax.pause = False
def stop(self, *args):
self.active = False
if self.sock:
@ -302,6 +350,8 @@ def main():
parser.add_argument('--prefix', help='video location', default=prefix)
parser.add_argument('--window', action='store_true', help='run in window', default=False)
parser.add_argument('--debug', action='store_true', help='debug', default=False)
parser.add_argument('--hour', action='store_true', help='hour', default=False)
parser.add_argument('--sax', action='store_true', help='hour', default=False)
args = parser.parse_args()
DEBUG = args.debug
@ -311,7 +361,7 @@ def main():
base = os.path.dirname(os.path.abspath(__file__))
#os.chdir(base)
player = Sync(mode=args.mode, playlist=args.playlist, fullscreen=not args.window)
player = Sync(mode=args.mode, playlist=args.playlist, fullscreen=not args.window, hour=args.hour, sax=args.sax)
while player.active:
try:
player.mpv.wait_for_playback()

View File

@ -132,17 +132,17 @@ def compose(clips, target=150, base=1024, voice_over=None):
subs = []
for vo in voice_overs:
voc = vo.copy()
a, b = '3', '-6'
a, b = '-11', '-3'
if 'Whispered' in voc['src']:
a, b = '6', '-3'
a, b = '-8', '0'
elif 'Read' in voc['src']:
a, b = '6.25', '-2.75'
a, b = '-7.75', '0.25'
elif 'Free' in voc['src']:
a, b = '5.2', '-3.8'
a, b = '-8.8', '-0.8'
elif 'Ashley' in voc['src']:
a, b = '3.75', '-5.25'
a, b = '-9.5', '-1.50'
elif 'Melody' in voc['src']:
a, b = '4.25', '-4.75'
a, b = '-5.75', '-0.75'
voc['filter'] = {'volume': a}
scene['audio-center']['A1'].append(voc)
vo_low = vo.copy()
@ -282,10 +282,10 @@ def compose(clips, target=150, base=1024, voice_over=None):
scene['audio-back']['A1'].append({
'duration': clip['duration'],
'src': clip['original'],
'filter': {'volume': '+0.2'},
'filter': {'volume': '-8.2'},
})
# TBD: Foley
cf_volume = '-5.5'
cf_volume = '-2.5'
scene['audio-front']['A2'].append({
'duration': clip['duration'],
'src': foley,

6
sax.py
View File

@ -31,7 +31,7 @@ reverb = {
"src": reverb_wav,
"duration": 3600.0,
"filter": {
"volume": "0.5"
"volume": "3.5"
},
}
@ -39,14 +39,14 @@ long = {
"src": long_wav,
"duration": 3600.0,
"filter": {
"volume": "-4"
"volume": "-1"
},
}
noise = {
"src": nois_wav,
"duration": 3600.0,
"filter": {
"volume": "4.75"
"volume": "7.75"
},
}

BIN
title.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB