Alex Sknarin Posted January 23, 2018 Report Share Posted January 23, 2018 Hello, I've got great headache with publishing versions with video for review with python api. My goal is to get exactly same behaviour as wheen using drag and drop: - Encode video - Video sould be playable in web player and in web review tool - Thumbnail You know how it should look, obviously: At first I tried to do as documentation says. just: asset_type = session.query('AssetType where name is "Upload"').one() f_asset = session.create('Asset', { 'name': 'cg0019_prm_05', 'type': asset_type, 'parent': f_shot }) asset_version = session.create('AssetVersion', { 'asset': f_asset, 'task': f_shot }) component = asset_version2.create_component( path='D:\\yandex\\YandexDisk\\WOF\\tmp\\_bd_to_ftrack\\ml\\prm\\cg0019_prm_v001.mov', data={ 'name': 'ftrackreview-mp4' }, location=server_location ) component['metadata']['ftr_meta'] = json.dumps({ 'frameIn': 0, 'frameOut': 33, 'frameRate': 24 }) component.session.commit() After executing that video file successfuly uploaded to ftrack.server and version is generated. BUT: - Video isn't playable in web player (I could only download it and play locally) - There are no thumbnail looks completely diffrent from drag-n-drop version: Ok I added encoding at the end before commit: #blah blah bla same code as before component['metadata']['ftr_meta'] = json.dumps({ 'frameIn': 0, 'frameOut': 33, 'frameRate': 24 }) job2 = session.encode_media(component) component.session.commit() I see that Encoding job has been added to the queue, but results are the same Ok I made thumbnail by myself and upload it separately: thumbnail = session.create_component(path='D:\\yandex\\YandexDisk\\WOF\\tmp\\_bd_to_ftrack\\ml\\tbn\\cg0019_prm.jpg', data={'name': 'thumbnail'}, location=server_location) asset_version2['thumbnail'] = thumbnail Now I've got thumbnail! (But it isn't right I used to write stuff fo three other project managment systems - all of them have a way to automatically create thumbnail one way or another, so I think it should be a way in ftrack too) But video still doesnt work. Trying to upload and encode it separately: component = session.create_component(path='D:\\yandex\\YandexDisk\\WOF\\tmp\\_bd_to_ftrack\\ml\\prm\\cg0019_prm_v001.mov', data={'name': 'ftrackreview-mp4'}, location=server_location) component['metadata']['ftr_meta'] = json.dumps({ 'frameIn': 0, 'frameOut': 33, 'frameRate': 24 }) session.commit() job2 = session.encode_media(component) asset_type2 = session.query('AssetType where name is "Upload"').one() f_asset2 = session.create('Asset', { 'name': 'cg0019_prm_03_mov', 'type': asset_type2, 'parent': f_shot2 }) asset_version2 = session.create('AssetVersion', { 'asset': f_asset2, 'task': f_shot2 }) asset_version2['components'] = [component] thumbnail = session.create_component(path='D:\\yandex\\YandexDisk\\WOF\\tmp\\_bd_to_ftrack\\ml\\tbn\\cg0019_prm.jpg', data={'name': 'thumbnail'}, location=server_location) asset_version2['thumbnail'] = thumbnail session.commit() Same result. What am I doing wrong? Link to comment Share on other sites More sharing options...
Alex Sknarin Posted January 23, 2018 Author Report Share Posted January 23, 2018 found this: job = asset_version.encode_media('/PATH/TO/MEDIA') this doing ALMOST what I need. Only one thing left: Why my original vile is always called "main" after encoding this way? Using drag n drop is keeps original name somehow Link to comment Share on other sites More sharing options...
Eric Hermelin Posted January 24, 2018 Report Share Posted January 24, 2018 Hi Alex, the below example should replicate the drag and drop behavior: import ftrack_api import ftrack_api.symbol session = ftrack_api.Session() file_path = '/home/erhe/Downloads/colour_wheel.mov' asset_name, _ = os.path.splitext( os.path.basename(file_path) ) asset_type = session.query( 'AssetType where name is "Upload"' ).one() shot = session.get( 'Shot', '28032993-d3e7-44c8-83c5-fe42e080d86a' ) asset = session.create('Asset', { 'name': asset_name, 'type': asset_type, 'parent': shot }) asset_version = session.create('AssetVersion', { 'asset':asset, 'task': shot }) component = asset_version.create_component( path=file_path, data={ 'name': asset_name }, location=session.get('Location', ftrack_api.symbol.SERVER_LOCATION_ID) ) asset_version.encode_media( component ) session.commit() result : I am unsure why your first example where you set the metadata manually fails to play in the web player, could you tell me what version of the python api you are running? cheers Eric Link to comment Share on other sites More sharing options...
Alex Sknarin Posted February 20, 2018 Author Report Share Posted February 20, 2018 thank you very much! next question: is it possible to get uploading/encoding progress somehow to use for progressbar in my pySide application? Link to comment Share on other sites More sharing options...
kylebjordahl Posted March 22, 2018 Report Share Posted March 22, 2018 Hey Alex, Not sure if you ever found an answer to this, but I believe the call to encode_media() returns a Job entity, so you could try polling it periodically for status, or perhaps find a clever way to listen to update events on the event hub regarding it's ID. That won't get you percentage completion, but you can at least get a confirmation it is complete. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.