per clip volume

This commit is contained in:
j 2017-03-22 10:19:38 +00:00
parent ed4b2fde61
commit b22d4e9551

View file

@ -50,28 +50,30 @@ def add_color(playlist, color, duration):
red.set_in_and_out(0, duration) red.set_in_and_out(0, duration)
playlist.append(red) playlist.append(red)
def add_clip(playlist, file_, in_, duration): def add_clip(playlist, clip, in_, duration):
file_ = clip['path']
if not isinstance(file_, str): if not isinstance(file_, str):
file_ = file_.encode('utf-8') file_ = file_.encode('utf-8')
'''
info = ox.avinfo(file_) info = ox.avinfo(file_)
tractor = mlt.Tractor(profile) tractor = mlt.Tractor(profile)
tracks = tractor.multitrack() tracks = tractor.multitrack()
video = mlt.Playlist() video = mlt.Playlist()
''' c = mlt.Producer(profile, file_)
clip = mlt.Producer(profile, file_) c.set_in_and_out(in_, in_+duration-1)
clip.set_in_and_out(in_, in_+duration-1) video.append(c)
playlist.append(clip)
'''
video.append(clip)
tracks.connect(video, 0) tracks.connect(video, 0)
if not not info.get('audio'): if not info.get('audio'):
audio = mlt.Playlist() audio = mlt.Playlist()
add_silence(audio, duration) add_silence(audio, duration)
tracks.connect(audio, 1) tracks.connect(audio, 1)
#tracks.set_in_and_out(in_, in_+duration-1) else:
volume = mlt.Filter(profile, "volume")
if clip.get('tag', '') == 'gong':
volume.set("gain", '0.8')
else:
volume.set("gain", '0.12')
tractor.plant_filter(volume)
playlist.append(tractor) playlist.append(tractor)
'''
def add_audio_clip(playlist, file_, duration): def add_audio_clip(playlist, file_, duration):
in_ = 0 in_ = 0
@ -112,7 +114,7 @@ for clip in data['clips']:
sys.exit(1) sys.exit(1)
# fixme seconds to fps! # fixme seconds to fps!
in_ = int(clip['in'] * fps) in_ = int(clip['in'] * fps)
add_clip(video, clip['path'], in_, frames) add_clip(video, clip, in_, frames)
add_color(video, 'black', 60) add_color(video, 'black', 60)
for clip in data['text']: for clip in data['text']:
@ -160,9 +162,11 @@ composite = mlt.Transition(profile, "composite")
tractor.plant_transition(composite) tractor.plant_transition(composite)
'''
volume = mlt.Filter(profile, "volume") volume = mlt.Filter(profile, "volume")
volume.set("gain", '0.12') volume.set("gain", '0.12')
tractor.plant_filter(volume) tractor.plant_filter(volume)
'''
def mix_audio_tracks(a, b, ratio): def mix_audio_tracks(a, b, ratio):
tractor = mlt.Tractor(profile) tractor = mlt.Tractor(profile)