Welcome, Guest
Username Password: Remember me
  • Page:
  • 1

TOPIC: Lightworks Assistant App: Blender

Lightworks Assistant App: Blender 4 years, 5 months ago #113795

  • lghtwrks
  • OFFLINE
  • Platinum Boarder
  • Posts: 3333
  • 4 years, 5 months ago
Lightworks_to_Blender_Nodes.py

(as I was not able to run any of the scripts in the latest blender version 2.77a on the pc)
I changed also some parsing + math, so it should work also if "(" and ")" etc are in the filename.

If you try to run this script on mac os or linux, you have to change the reading location of the lwks file:

WIN: f = open(("C:/Users/Public/Documents/Lightworks/Projects/sources-list.txt"), "r")

to

mac os /linux: f = open(os.path.expanduser("~/sources-list.txt"), "r")


LWKS generated file + parsing:

This image is hidden for guests. Please log in or register to see it.

This image is hidden for guests. Please log in or register to see it.

executing the script in blender ("manual mode"):
This image is hidden for guests. Please log in or register to see it.

generated compositing nodes:
This image is hidden for guests. Please log in or register to see it.



greets
s


original mac os version: github.com/dahnielson/BlenderAssist/blob/master/LICENSE
Attachments:
  • Attachment This image is hidden for guests. Please log in or register to see it.
  • Attachment This image is hidden for guests. Please log in or register to see it.
  • Attachment This image is hidden for guests. Please log in or register to see it.
  • Attachment This image is hidden for guests. Please log in or register to see it.
Last Edit: 4 years, 5 months ago by lghtwrks.

Re: Lightworks Assistant App: Blender 4 years, 5 months ago #113796

  • lghtwrks
  • OFFLINE
  • Platinum Boarder
  • Posts: 3333
  • 4 years, 5 months ago
Code/PC
(eg. you also can copy and paste the code to blender, after you have generated the source-list.txt file in lightworks)

Lightworks_to_Blender_Nodes.py

import bpy, math, os, sys

bpy.context.scene.use_nodes = True
Scene = bpy.context.scene

def addClip (clip_file_path, clip_start_frame):
    Clip = bpy.data.movieclips.load(clip_file_path)
    Clip.frame_offset = clip_start_frame
    return Clip

def addNode (parent, clip_file_path, clip_start_frame, clip_end_frame, clip_start_at = 0):
    Node = parent.nodes.new('CompositorNodeImage')
    Node.image = bpy.data.images.load(clip_file_path) 
    Node.name = os.path.basename(clip_file_path.strip())
    print ("Node generated: " + Node.name+"\r\n\r\n")
    Node.frame_duration = clip_end_frame - clip_start_frame + 1
    Node.frame_offset = clip_start_frame
    Node.frame_start = clip_start_at
    Node.use_auto_refresh = True
    return Node

location = [0,300]
parent = bpy.context.scene.node_tree
sequence_frame = 0
track_frame = 0

f = open(("C:/Users/Public/Documents/Lightworks/Projects/sources-list.txt"), "r")

print ("\r\n--------")
for line in iter(f):
    if line.startswith("Track"):
        track_frame = 0
        token = line.split()
        track_name = token[2]
        print ("TRACK:"+token[2]) 
        location[1] -= 300      
       
    elif line in ['\n', '\r\n']:
        print ("\r\n--------")
        
        
    else:
        token = line.rsplit(" (")
        clip_file_path = token[0].strip()
        token2 = token[1].split("->")
        token3 = token2[0].split(" ")
        token4 = token2[1].split(" ")
        clip_start_frame = int(token3[2])
        clip_end_frame = int(token4[1])
        print ("clip_file_path: \""+ clip_file_path +"\"")
        print ("clip_start_frame: "+token3[2])       
        print ("clip_end_frame: "+token4[1])         
        Node = addNode(parent, clip_file_path, clip_start_frame, clip_end_frame, track_frame)
        addClip(clip_file_path, clip_start_frame)
        Node.location = location
        location[0] += 150
        location[1] += 200
        track_frame += clip_end_frame - clip_start_frame
        sequence_frame = max(track_frame, sequence_frame)
        
Scene.frame_start = 0
Scene.frame_end = sequence_frame
f.close()


edit: removed os.system("cls") which just clears the console on blender/windows.

Examples:
Starting Blender and running the script:
"C:\Program Files\Blender Foundation\Blender\blender.exe" --python c:\Lightworks_to_Blender_Nodes.py

Starting Blender with a blend file and running the script:
"C:\Program Files\Blender Foundation\Blender\blender.exe" c:\mycomp.blend --python c:\Lightworks_to_Blender_Nodes.py
Last Edit: 4 years, 5 months ago by lghtwrks.

Re: Lightworks Assistant App: Blender 4 years, 5 months ago #113797

  • donkpow
  • Pro User
  • OFFLINE
  • Platinum Boarder
  • Posts: 8993
  • 4 years, 5 months ago
Well done!
HP Z600 5570
PNY Quadro K620
SB Audigy SE
Windows 10 Pro
ShuttlePRO v2

Re: Lightworks Assistant App: Blender 4 years, 5 months ago #113798

  • lghtwrks
  • OFFLINE
  • Platinum Boarder
  • Posts: 3333
  • 4 years, 5 months ago
thx, would be intersting if it works on linux/mac os too.
s

Re: Lightworks Assistant App: Blender 4 years, 5 months ago #113799

  • donkpow
  • Pro User
  • OFFLINE
  • Platinum Boarder
  • Posts: 8993
  • 4 years, 5 months ago
lghtwrks wrote:
thx, would be intersting if it works on linux/mac os too.
s
Indeed. Blender is a very popular cross platform program.
HP Z600 5570
PNY Quadro K620
SB Audigy SE
Windows 10 Pro
ShuttlePRO v2

Re: Lightworks Assistant App: Blender 4 years, 4 months ago #115551

  • variavision
  • Pro User
  • OFFLINE
  • Junior Boarder
  • Posts: 26
  • 4 years, 4 months ago
OMG! Thanks a lot!

You actually saved my life!

I'm on Linux and it is working like a charm. I really needed something like that.

I had done something similar, but in bash scripting about FFMPEG and stabilization

I am still working on it, before post the "new version". Here the post, maybe you could need it
  • Page:
  • 1
Time to create page: 0.38 seconds
Scroll To Top