Cross-platform MLV to DNG converter

Started by MonteNero, July 22, 2014, 02:02:22 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MonteNero

Hi everyone!
Since recently we've started to use ML on some production shoots this led us to develop ML convert a little open source python app that batch converts MLV files to DNGs. 
The app has been tested on Windows platform and works flawlessly. It should work on Mac too, but since I don't have a Mac around I can't test it.
ML convert is just a text file with open python code that you are free to modify and adopt for your own needs.
In order to run the ML convert all you have to do is to install the Python language from official python website, here is a download link https://www.python.org/downloads/release/python-341/
Since the ML convert is based on Magic Lantern's MLV_DUMP you have to copy MLV_DUMP.exe to C:/Program Files/ or if you are a Mac user copy MLV_DUMP.osx to /usr/local/bin
That's it!
Check out some screenshots of the simple workflow with ML convert.


And here is the app itself! Just copy the provided code into the text file and save it as ML convert.py
That's it. I hope someone will find it useful. Cheers!


#title                :ML_convert
#version              :Beta
#description          :The program converts MLV files to DNG sequence. In order to use ML_convert, copy MLV_DUMP program to Win C:/Program Files/ or Mac /usr/local/bin
#date                 :July 22 2014
#python_version       :3.4
#notes                :Please use at your own risk.
import os
import shutil
from tkinter import *
from tkinter.filedialog import askopenfilenames

class ml_converter:
    p = ''
    exe = ''
    winexe = 'C:/Program Files/mlv_dump.exe'
    macexe = '/usr/local/bin/mlv_dump.osx'
    testexe = 'C:/mlv_dump.exe'
    result = ''
   
    def find_mlv_dump(self):
        self.exe = self.winexe
        if not os.path.isfile(self.winexe):
            self.exe = self.macexe
        if os.path.isfile(self.exe):
            return True
        else:
            return False
       
    def convert(self,mlv_file):
        #dir = os.path.dirname(mlv_file)
        ext = os.path.splitext(mlv_file)[-1].lower()
        if ext==".mlv":
            direct,f = os.path.split(mlv_file)
            filename = f[:-4]
            newdir = (direct+("/"+filename))
            if not os.path.exists(newdir):
                os.mkdir(newdir)
                newdir = shutil.move(mlv_file,newdir)
            else:
                print ("Directory already exists,the file moved into already existing folder")
                newdir = shutil.move(mlv_file,newdir)
            os.system("\""+"\""+ self.exe+"\"" + ' --dng' + " \""+ newdir +"\""+"\"")
            shutil.move(newdir,mlv_file)
            self.result = 1
            return self.result
        else:
            print (" not supported file format")
            self.result = 0
            return self.result
       

class ml_ui(Frame, ml_converter):
    def __init__(self,mlc):
        Frame.__init__(self)
        self.mlv_files = []
        self.mlv_file = ''
        self.str = ''
        self.exe = 1
        self.result = ''
        self.i = 0
        self.master.title("MLV convert")
        self.pack()
        self.browse_btn = Button(self, text="Browse MLV", command=self.load_file, width=20)
        self.browse_btn.pack(side = "top")
        self.convert_btn = Button(self,text="Convert to DNG",command=lambda: self.conv(), width=20)
        self.convert_btn.pack(side = "top")
        self.log = Text(self)
        self.log.pack(side="top")

    def load_file(self):
        self.mlv_files = askopenfilenames()
    def conv(self):
        self.exedir = self.find_mlv_dump()
        if self.exedir ==True:
            self.i = 0
            size = len(self.mlv_files)
            print (size)
            self.log.delete('1.0',END)
            for self.mlv_file in self.mlv_files:
                self.result = self.convert(self.mlv_file)
                self.i+=1
                if (self.result != 0):
                    self.log.insert(INSERT,str(self.mlv_file)+"    Done!"+"\n") #### fix needed, UI shows non MLV files processed
                    self.str = '%i out of %i \n'%(self.i,size)
                    self.log.insert(INSERT,self.str)
                else:
                    self.log.insert(INSERT,str(self.mlv_file)+" is not MLV file!"+"\n")
                    self.str = '%i out of %i \n'%(self.i,size)
                    self.log.insert(INSERT,self.str)
                    ml_ui.update(self)
        else:
            self.log.insert(INSERT," MLV_DUMP program is not found \n Copy the MLV_DUMP into C:/Program Files/ or /usr/local/bin \n" )
            print('not found')

if __name__ == "__main__":
    mlc = ml_converter()
    ui = ml_ui(mlc)
    ui.mainloop()

MonteNero

Moreover I'am planning to add some MLV_DUMP features such as compression and bit depth.