Jump to content

How to actually publish video for web review to have same result as drag and drop?


Alex Sknarin

Recommended Posts

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:

2affca58a7aa.png

 

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:

637eb0fb1ebb.png

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

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 :

image.png

 

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

  • 4 weeks later...
  • 1 month later...

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...