Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
appwiki:resolve [2018/04/26 14:46]
ying [subtitle workflow]
appwiki:resolve [2019/06/28 02:42] (current)
ying [Inside the DB file]
Line 1: Line 1:
 +====== Resolve 15 and Disk Database file ======
 +
 +===== DB location and structure =====
 +
 +  * If you open project manager, and click on the top left icon to expand the database disk view
 +    * you can see the list of "​Resolve Database Files with DB Name" (actually the Location Path)
 +
 +  * Add database file to Project Manager
 +    * "New Database"​ button, choose "​connect",​ give the database name, and the root location, which named "​Resolve Projects"​
 +    * or choose "​Create",​ to create the database folder structure
 +    * you can use this method on Shared Network drive to share project between different computers, (even works for the free version, if not working, try move original one, and create same database, then swap back to the original database folder)
 +      * note: resolve save different "​Project"​ in different disk folder with different "​.db"​ file, saving project of same project on different computer seems not update other computer in real time, other computer need to re-open the project to see the reflect changes
 +
 +  * "​Resolve Projects"​ disk database structure
 +    - Users
 +      - admin
 +        - Configs/​User Default Config.xml
 +        - User.db
 +      - guest
 +        - User.db
 +        - Projects
 +          - EachProjName/​Project.db (sqlite 3 format)
 +        - Configs/​User Default Config.xml
 +    - Settings
 +      - list of config xmls
 +
 +  * code to list project<​code python>
 +import os
 +db_file = '​Project.db'​
 +db_disk_path = r'​d:​\yourPathTo\Resolve_Projects_parentFolder'​
 +proj_dir = os.path.join(db_disk_path,'​Resolve Projects','​Users','​guest','​Projects'​)
 +proj_list = []
 +if os.path.isdir(proj_dir):​
 +    proj_list= os.listdir(proj_dir)
 +
 +# access first project
 +cur_proj = proj_list[0]
 +cur_db_file = os.path.join(proj_dir,​cur_proj,​db_file)
 +if not os.path.isfile(cur_db_file):​
 +    print('​DB file not exists: {0}'​.format(cur_db_file))
 +</​code>​
 +
 +  * Access DB using python sqlite module <code python>
 +import sqlite3 as sql
 +print(sql.sqlite_version) # make sure your sqlite is newer than resolve sql database
 +
 +con = sql.connect(cur_db_file)
 +sql_cmd = '​SELECT Name FROM Sm2MpMedia'​ # list media pool item
 +cur = con.cursor()
 +cur.execute(sql_cmd)
 +all_rows = cur.fetchall()
 +print(all_rows)
 +# [(u'​20190410_xslate_1.mp4',​),​ (u'​Timeline 1',), (u'​Timeline 2',)]
 +</​code>​
 +
 +  * Access DB use Python+Qt <code python>
 +# ---- qtMode ----
 +qtMode = 0 # 0: PySide; 1 : PyQt, 2: PySide2, 3: PyQt5
 +qtModeList = ('​PySide',​ '​PyQt4',​ '​PySide2',​ '​PyQt5'​)
 +try:
 +    from PySide import QtGui, QtCore, QtSql
 +    import PySide.QtGui as QtWidgets
 +    qtMode = 0
 +except ImportError:​
 +    try:
 +        from PySide2 import QtCore, QtGui, QtWidgets, QtSql
 +        qtMode = 2
 +    except ImportError:​
 +        try:
 +            from PyQt4 import QtGui,​QtCore,​ QtSql
 +            import PyQt4.QtGui as QtWidgets
 +            import sip
 +            qtMode = 1
 +        except ImportError:​
 +            from PyQt5 import QtGui,​QtCore,​QtWidgets,​ QtSql
 +            import sip
 +            qtMode = 3
 +print('​Qt:​ {0}'​.format(qtModeList[qtMode]))
 +
 +db = QtSql.QSqlDatabase.addDatabase('​QSQLITE'​)
 +db.setDatabaseName(cur_db_file)
 +if db.open():
 +    print('​DB is open.'​)
 +    ​
 +sql_query = QtSql.QSqlQuery()
 +sql_cmd = '​SELECT * FROM Sm2MpMedia'​
 +sql_query.exec_(sql_cmd)
 +print(sql_query.record())
 +title_list = [x.strip() for x in 'Name, MpFolder, FrameRate, Sm2MpFolder_id,​ Video, VideoType, Sm2MpMedia_id'​.split(','​)]
 +title_ids = [sql_query.record().indexOf(x) for x in title_list]
 +print(sql_query.record().indexOf("​Name"​))
 +
 +# data
 +media_data=[]
 +while sql_query.next():​
 +    media_data.append([sql_query.value(x) for x in title_ids])
 +print(media_data)
 +</​code>​
 +
 +===== Inside the DB file =====
 +
 +  * Before Resolve 15, it use xml based Folder+XML structure to store, and some table name is change through versions.
 +    * db code operation ref: https://​www.steakunderwater.com/​wesuckless/​viewtopic.php?​t=2012
 +
 +| Table Name | Information | Fields |
 +^ Sm2MpMedia | the Media Pool Items | Name, MpFolder, FrameRate, Sm2MpFolder_id,​ Video, VideoType, Sm2MpMedia_id |
 +^ Sm2MpFolder | Media Pool bins | Sm2MpFolder_id,​ Name | 
 +^ Sm2MpFolder_Sm2MpMedia | Media Pool bin to Media relationship | DBOwner (folder_id),​ DbAssociate (media_id) |
 +^ Sm2Timline | timeline items | Sm2Timline_id,​ Name, PTZRPreset |
 +^ SM_Setup | Project setup | SM_Setup_id,​ ResTemplate,​ Width, Height, BitDepth, \\ FrameTransmitRate,​ PixelAspectRatio,​ FPS, FormatWidth,​ FormatHeight |
 +^ Sm2TiItem | Media item involved with timeline | Sm2TiItem_id,​ Name, Start, Duration, In, MediaRef (media id), MediaStartTime,​ MediaFilePath |
 +^ SmPreset, Sm2TiAudioClip,​ Sm2Sequence |||
 +
 +  * note:
 +    * seems if the media in media pool not used in timeline, then the MediaFilePath info is not available
 +
 +  * Digging most useful information (Python + Qt method) <code python>
 +db = QtSql.QSqlDatabase.addDatabase('​QSQLITE'​)
 +db.setDatabaseName(cur_db_file)
 +if db.open():
 +    print('​DB is open.'​)
 +
 +sql_query = QtSql.QSqlQuery()
 +
 +# ~ update media folder
 +sql_cmd = '​SELECT * FROM Sm2MpFolder'​
 +sql_query.exec_(sql_cmd)
 +title_list = [x.strip() for x in '​Sm2MpFolder_id,​ Name'​.split(','​)]
 +title_ids = [sql_query.record().indexOf(x) for x in title_list]
 +folder_data={}
 +while sql_query.next():​
 +    t_row = [sql_query.value(x) for x in title_ids]
 +    folder_data[t_row[0]]=t_row[1]
 +print(folder_data)
 +
 +
 +# ---------- main media infos --------------
 +sql_cmd = '​SELECT * FROM Sm2MpMedia where DbType = "​Sm2MpVideoClip"'​
 +sql_query.exec_(sql_cmd)
 +
 +title_list = [x.strip() for x in 'Name, Sm2MpMedia_id,​ Sm2MpFolder_id,​ Video'​.split(','​)]
 +title_ids = [sql_query.record().indexOf(x) for x in title_list]
 +
 +main_media_data=[]
 +main_media_dict ={}
 +while sql_query.next():​
 +    t_row= [sql_query.value(x) for x in title_ids]
 +    main_media_data.append(t_row)
 +    main_media_dict[t_row[1]] = {'​n':​t_row[0],​ '​bin':​folder_data[t_row[2]]}
 +
 +print(main_media_data)
 +
 +
 +# ~ get timeline item data
 +sql_cmd = '​SELECT * FROM Sm2TiItem'​
 +sql_query.exec_(sql_cmd)
 +title_list = [x.strip() for x in '​Sm2TiItem_id,​ Name, Start, Duration, MediaRef, MediaFilePath'​.split(','​)]
 +title_ids = [sql_query.record().indexOf(x) for x in title_list]
 +
 +ti_item_data = []
 +while sql_query.next():​
 +    t_row = [sql_query.value(x) for x in title_ids]
 +    ti_item_data.append(t_row)
 +    if t_row[4] in main_media_dict.keys():​
 +            if '​path'​ not in main_media_dict[t_row[4]].keys():​
 +                main_media_dict[t_row[4]]['​path'​] = t_row[5]
 +            if '​start'​ not in main_media_dict[t_row[4]].keys():​
 +                main_media_dict[t_row[4]]['​start'​] = t_row[2]
 +            if '​duration'​ not in main_media_dict[t_row[4]].keys():​
 +                main_media_dict[t_row[4]]['​duration'​] = t_row[3]
 +
 +
 +import pprint
 +pprint.pprint(main_media_dict)
 +
 +# ~ get timeline list
 +sql_cmd = '​SELECT * FROM Sm2Timeline'​
 +sql_query.exec_(sql_cmd)
 +title_list = [x.strip() for x in 'Name, Sm2Timeline_id,​ Sm2MpMedia_id'​.split(','​)]
 +title_ids = [sql_query.record().indexOf(x) for x in title_list]
 +
 +timeline_data = []
 +while sql_query.next():​
 +    t_row = [sql_query.value(x) for x in title_ids]
 +    timeline_data.append(t_row)
 +
 +print(timeline_data)
 +
 +# ~ get project setup
 +sql_cmd = '​SELECT * FROM SM_Setup'​
 +sql_query.exec_(sql_cmd)
 +title_list = [x.strip() for x in '​ResTemplate,​ Width, Height, BitDepth,​FPS,​PixelAspectRatio,​ModDateTime,​CreateDateTime,​StillDurationSecs'​.split(','​)]
 +title_ids = [sql_query.record().indexOf(x) for x in title_list]
 +
 +proj_data = []
 +while sql_query.next():​
 +    t_row = [sql_query.value(x) for x in title_ids]
 +    proj_data.append(t_row)
 +
 +print(proj_data)
 +
 +# ~ get Project Name
 +print(cur_proj)
 +
 +# ~ other table
 +# BtVideoInfo
 +</​code>​
 +
 +====== Resolve Version Control Workflow ======
 +
 +  * ref: 
 +    * Resolve-Fusion/​Flame/​Nuke/​AE Hack workflow: https://​vimeo.com/​213588842#​at=219
 +
 ====== Free vs Paid version of Resolve 12 ====== ====== Free vs Paid version of Resolve 12 ======
  
Line 9: Line 222:
     * Multi-GPU acceleration support (resolve 12 only can use 1 GPU, and 2 on MacPro)     * Multi-GPU acceleration support (resolve 12 only can use 1 GPU, and 2 on MacPro)
  
 +  * In Resolve 15, scripting is only available in paid version
 ====== DaVinci Resolve 12 Media Note ====== ====== DaVinci Resolve 12 Media Note ======
 ^ input ^ File Format ^ resolution ^ ^ input ^ File Format ^ resolution ^