MLT2EDL script error fix

I am a big fan of this software. I started using it when I teach in my classes.
And I wanted to implement the Exchage of EDL to Davinci Resolve.

However I was stuck with the MLT2EDL script giving me errors all the time.
I finally managed to get it running on python on my OSX El Capitan.
I want to share it with you, but I dont know where to upload it, and cannot contact the original author. If someone is in touch, just give it back.

I would like to make a more complex transcription of the tool. to take what is possible from effects to other EDL formats. Any suggestions?

mlt2edl.py.zip (5.8 KB)

I know the author and have his e-mail address. I will forward it to him. As for other converting effects, that is quite difficult because effect implementations are so different between tools. And when you can make some sort of conversion, there is often a big difference in the fidelity of the conversion. I think that opens a big door to headaches both for support and for simply your own usage. What do you think? I have no advice for how to actually proceed on that.

Before proceeding to make it much more complex, I wonder if it should be ported from Python to something else. As a python script, it has little hope of being integrated into Shotcut because I am not going to put something in that requires someone to install Python on their own, and neither am I willing to include Python in the installer just for this one feature that only advanced users would use. Let me think about what would be a better…

I completely agree. thank you for forwarding it to the author.
Python was a pain on my mac, and for my students I used pytoninstall.py to make the little executable. I am not really familiar with python. I am rather thinking of a XML Transformation. I have done this in the past to format and output information from FinalCut XML. Would this be more doable within this environment? Some manipulations could it also make it easier to rename and relink the files.
The question is, what would be a great output format? FinalCut has become a bit obsolete, although it was very useful.

I do not think another XML as the target is necessarily any easier than another text format. FCPXML does have a DTD to make validating the result easier. Meanwhile, EDL has some documentation and Blender’s source code to make understanding it easier. Both FCPXML and EDL are popular interchange formats.

As for porting to another language, I think it is best to keep it as a high level language for other people to maintain. Qt apps such as Shotcut and Kdenlive make it possible to use Javascript to run a conversion, and there are npm modules (Javascript library) to make processing XML easy.

ok, I will have a look at the code an try to compile it by myself to see if I get some ideas.

If you are thinking about trying to compile the Shotcut code, beware! It is not easy. We use a long and complicated bash script to make nightly and release builds [1]. And on OS X, it also requires MacPorts to provide many dependencies outside the script. Trust me when I say, I do not think this is the road you want to go down for this task.

I suggest if you want to look into porting the MLT2EDL code to Javascript, you do that separately using node.js and npm modules. In essence, node.js is simply a command line interpreter. There is plenty of good information about getting, running, and using node.js. It is quite a joy to use. After that, I will accept the burden of integration into Shotcut.

[1] https://github.com/mltframework/shotcut/blob/master/scripts/build-shotcut.sh

Great to hear that you turn that MLT2EDL script into something useful for you. I’m not a python coder nor am I a coder in general, so that script is just a result of me tinkering with the kdenparse script(which I haven’t touched since).

EDL may at first seem like a simple format, however it’s original purpose of carrying information on a celluloid footage reel and a frame number and later a tape name and a time code, is that archaic, that various softwares using this format have added several alterations, which makes it prone to errors.

What makes it even more difficult to work with is that the reel names and time codes listed in the edl file are read from embedded metadata in the source files. So unless you source material is in a format which can’t carry reel name/time code - you can’t be sure that the first frame of a source clip is 00:00:00:00 - which means that you would have to transcode your source material into a codec which allows embedded time code (and Shotcut would have to read the embedded time codes and adjust the in/out point in the EDL according to the start value of the time code).

With the reel name it is even more important to embed it into the sourcefile metadata because there is no common naming convention, however the reel name is limited to 8 characters, no spaces and no file extension. The limited reel name often means that you would manually have to point to the folder where you source files are located or even pointing to the specific file mentioned in the EDL. As an alternative to using the reel name for indicating the file name FCP is using a line before the edl line. Like this: * FROM CLIP NAME: CLIP NAME HERE(can contain the full path). But other softwares use clip name specified in a comment line but saying * COMMENT: instead of * FROM CLIP NAME: Some softwares read that from the line before the time code line and other softwares use the line after the time code line. And yet other softwares doesn’t read this line at all(like the Blender edl import script), so you would have to add the file name information from the reel name tag. (http://eyeframeconverter.wordpress.com can transcode to ex. ProRes or DNxHD with embedded reel name and time code)

Another inconsistent value is the EditMode value written and read differently in different softwares. They can be written/read like this:
Blender: ‘V’ | ‘A’ | ‘VA’ | ‘B’ | ‘v’ | ‘a’ | ‘va’ | ‘b’ which equals Video, Audio, Video_Audio edits (note B or b can be used in place of VA or va).

Or Lightworks:
AA/V – Video and audio on channel 1 and 2
VA1A2 – Video and audio on channel 1 and 2
A12V – Video and audio on channel 1 and 2
AUD3 – Audio only on channel 3
A3 – Audio only on channel 3

Or this:
NONE, A, B, V, A2, A2\V, AA, AA\V

So some softwares writes/reads what tracks goes where and some don’t(Blender doesn’t). I believe that Lightworks limits export to an EDL with 2 or 4 audio tracks.

I’ve written a bit about my findings here: http://blender.45788.x6.nabble.com/Bug-when-using-va-b-setting-in-edl-file-td128520.html

(Btw. I don’t think that the EDL format can carry effect information - only a handful of various transitions).

The good thing about EDL is that it is widespread, and you can edit it by hand.

The newer alternative is aaf, which supports more options(maybe even effects).



Java-binding: https://github.com/AMWA-TV/maj
Python-binding: https://github.com/markreidvfx/pyaaf
Info: http://amwa.tv/developers.shtml

Most of the pro NLEs out there support this format, and also most pro DAWs which means you can import this format into an audio editing software to edit your project natively in there. Unfortutately the author of Ardour hates the aaf format with passion: https://community.ardour.org/node/8491

I believe it is a huge undertaking to implement I/O of EDL or AAF, but maybe as a Google Summer of Code project it would be possible? Or maybe it would be better to implement it in MLT so all projects using MLT would be able to benefit from it?

So in other words at this time there is no perfect interchange format, which is kind of sad, since it would be really great if projects could be painless moved between ex. Shotcut, Blender, Natron, Resolve, OpenCine, OpenToonz and Ardour.

Thanks Dan for inviting me here!

I think we should avoid going to extremes in this area. Apparently, conversion to EDL is useful to some people even when assuming start timecode is 00:00:00:00. As for the reel name, one can use an 8 character hash. Shotcut already computes a hash (of the file contents) into its MLT XML. Use the first 8 characters from that hash. Sure, this is not best way to EDL, but it solves many people’s itch to simply repurpose a Shotcut sequence. Again, if someone ports MLT2EDL to Javascript, I will integrate it in a manner that makes it easy for someone to hack on it by simply installing Shotcut.

thanks tin2tin.
I am also sharing what I found out so far with Davinci Resolve and Shotcut.
A small tutorial I made.

shotcut2davinciEDL.pdf.zip (510.0 KB)

1 Like

Nice tutorial. So you save a mlt file pr track, convert them individually, and import them in Resolve one by one? I believe I have imported more tracks in one go, but maybe I remember it wrong…

Dan, wouldn’t you prefer a qt sollution? And the reading of a mlt file, would’t be needed, right? Is there code included in shotcut to do math with time codes, like frames to TC?

Btw. There is a edl2aaf c++ code project here: https://sourceforge.net/p/edl2aaf/code/?source=navbar
I’m unfamiliar with c++, but maybe this project would make it easier to get a head start with the edl format or even code a aaf exporter.

In connection to the above mentioned project there is a description of the edl cmx 3600 format edl2aaf can import: http://edl2aaf.sourceforge.net/

Javascript is a Qt solution. The Shotcut timeline and filter panels make use of Javascript. If you look into the share/shotcut subdir of a Shotcut installation, you will find many .qml and .js files.

I am not really volunteering to doing a lot in this area. I cannot do everything, or at least I have many higher priorities. All I offer to do is to embrace this related project (MLT2EDL and kdenparse) by integrating and giving it a new home for ongoing maintenance. But I am cannot integrate a Python solution.

True, but someone making a standalone Javascript port of this script needs to read a file (or paste the XML into one big string in the script). When I integrate, the script will likely take on quite a different shape. Upon integration, the MLT XML will probably be supplied as a string. How exactly this integrates is not important at this time.

Yes, to convert between frames and timecode given a fps.

I’m sorry I do not have the time for learning java at this time, however I came across this project to convert the syntax from python to java: https://github.com/issmirnov/Python2Java

Running mlt2edl through that thing the syntax looks like this, however the functions etc. are not converted: http://codepaste.net/rgd7b4

OK, but Java and JavaScript are two very different things. I just took a look at the python script, and the core code (minus command line option processing and frames/timecode conversion) is only 300 lines. And I know Python well. So, I will give a crack myself.

I ported and integrated it as File > Export EDL…

Wow, that was quick! If you post an Shotcut saved EDL we can test it against Blender/Resolve/Avid if you like. Or is there a nightly build we can test?

Looking through your code, I realize that what you’ve done is a complete rewrite in only one day. That’s downright impressive!

I worry that not all softwares will be able to digest the “AA/V” setting. Maybe “b” will be more digestable for more softwares out there? Uwe, can you test if Resolve will accept “b” for video+audio?

Another thing I found out is that ex. Premiere Pro writes the comment line after the edit decisions concerning that clip, followed by an empty line:

001 DL02_024 AA/V C 00:00:00:19 00:00:04:19 00:00:00:00 00:00:04:00

  • FROM CLIP NAME: DL02_024.MTS

002 DL02_002 AA/V C 00:00:10:16 00:00:23:14 00:00:04:00 00:00:16:23

  • FROM CLIP NAME: DL02_002.MTS

The more I look around, the more it seems to be a common way to do it. The other way around was, I believe, for Blender import. So this way around is probably better.

Just for later reference I’ll add a few links here concerning EDL:
A free (Windows) EDL toolkit to check EDL files and spot differences: http://www.frogsoft.com/edl_toolkit.htm
FCP manual on EDL: https://documentation.apple.com/en/finalcutpro/usermanual/index.html#chapter=96%26section=1%26tasks=true
Really old EDL specifications: http://xmil.biz/EDL-X/CMX3600.pdf
http://www.scottsimmons.tv/blog/2006/10/12/how-to-read-an-edl/
How to read an EDL – Niwa

Python script to parse and import EDL into Blender:
https://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Import-Export/EDL_Import
https://github.com/sambler/myblenderaddons/blob/master/io_sequencer_edl/parse_edl.py
https://github.com/sambler/myblenderaddons/blob/master/io_sequencer_edl/import_edl.py

The old, scanned CMX3600 document is my baseline specification.
I am willing to add a submenu:
File > Export EDL > ToolA / ToolB…
File > Export EDL > ToolC…
File > Export EDL > Generic / CMX3600…

However, at the moment, I do not have enough information (in my head) to differentiate them. Definitely, “AA/V” seems wrong to me, and “B” more correct, and that is probably an area of difference. Also, which tools can accept a very long reel name? Do they accept an absolute file path? A quoted absolute file path? Which ones use the “FROM CLIP NAME” comment to resolve file links? Do they accept absolute file path?
A simple table based on those criteria will be a good start.

My sample. This uses the example video Wildlife.wmv that came with Windows 7, which you can get here: https://archive.org/details/wildlife.wmv
Except, mine is .avi because I had converted it to MJPEG.
wildlife shots.mlt (10.0 KB)
test.edl (1006 Bytes)

Will have to investigate further. Here are a few edl’s found on the net:EDLex.zip (1.2 KB)

As both Final Cut and Premiere has the comment line following the “time codes” line, this is probably the correct way to do it. One thing one must be very careful about when importing into Lightworks is that each column has the exact number of characters - which means that the reel name can contain spaces, however the Blender import script separates columns by locating the spaces. So that’s the reason for strict 8 characters for the reel name and only containing characters a-Z and 0-9. another thing to note is that “cleaning” your test.edl in EDLtoolkit AA/V gets translated to A12V. (A12V is not supported in Blender)

I’ve been trying to find an example with absolute paths, but unsuccessfully. This is one of the major shortcomings of this format. Maybe it was Sony Vegas, however their edl seems to be something completely different. This is the reason for the somewhat complicated import process Uwe mentioned in his Resolve write up. And same thing (but no media pool) when importing edl in Blender:

USING THE IMPORT EDL ADDON IN BLENDER:

    • Open Blender.
    • File > User preferences > Addons > Categories > Import – Export > Import – Export Import EDL > Check it.
    • Click button > Save user settings (so that setting will be used each time you start Blender).
    • Close the user preferences window.
    • Change the combo box in the top bar saying Default to Video Editing.
    • To the right of the time line you’ll see EDL import (if not, maybe Blender needs a restart after enabling the addon?)
    • Click the open folder button under the offset line and select your edl file.
    • Click ‘Refresh Reels’.
    • Add paths to the missing reels using the open folder buttons.
    • When all is set click ‘Import video sequence (.edl)
    • The time line should now show your Shotcut project.
    • A+alt is play/pause.

Good news. Blender opens your EDL correctly(though one audio clip looks a bit too long):

Lwks doesn’t open it. I’ve tried to embed reel name and time code in the source files(which Lwks demands), but still without success. As I wrote earlier on Lwks is very picky on the exact number of spaces between columns. I managed to get something into Lightworks by adding the wildlife to the edl included in the zip above. (Lwks will import edl in the free version).

On the mlt project. I changed the absolute paths to relative paths and changed the file extension to mp4, but I haven’t succeeded to load the video into the project. (running SC 16.04.01)

Will have to look more closely on the complicated EDL Manager to try to import the edl to Avid.

[Edit: Resolve appears to import the edl fine, with and without embedded meta data]