Rerun Flavor Generation from all Videos


A large part of our Videos in our Kaltura System dont own all Flavors.

I rerun some of the Videos manually over the Entry Investigation Interface.
But we have at least 2500 Videos in our System.

Is there a possibility to automate this?

Dear Raumen837

Hi @Raumen837,

Yes. As a general rule, anything that can be done using the Admin Console can be done via the API because the Admin Console, KMC, KMS and all other Kaltura web I/F make use of the API to accomplish their goals. In Admin Console specifically, there are very exceptions to that rule but flavour conversion is not one of these exceptions:)

If you wish to reconvert all flavours of a specific entry, you can call media->convert(), there is an example for that in the sanity tests:
That script accepts an entry ID as a param and calls media->convert() passing along the entry ID.
Obviously, you’ll want to change it so it calls media->list() and then iterate over the list of entries calling media->convert() for each. You can see the script passes null as $conversionProfileId and so, the default conversion profile will be used, if you have several profiles, you can pass the profile ID instead of null.

Alternatively, if you only want to reconvert SOME of the flavour assets, you can use flavorAsset->reconvert(), passing along a specific flavour ID.

Here is a simple code sample for iterating over all the media entries and their respective flavour assets:

if ($argc < 4){
    echo "\nUsage: ".$argv[0] . ' <partner id> <admin secret> <service url>'."\n\n";
    exit (1);
$userId = null;
$expiry = null;
$privileges = "disableentitlement";
$secret = $argv[2];
$type = KalturaSessionType::ADMIN;
$config = new KalturaConfiguration($partnerId);
$config->serviceUrl = $argv[3];
$client = new KalturaClient($config);
$ks = $client->session->start($secret, $userId, $type, $partnerId, $expiry, $privileges);
$filter = new KalturaMediaEntryFilter();
$total_media_entries = $client->media->count($filter);
$pager = new KalturaFilterPager();
$pager->pageSize = 500;
while ($processed_entries < $total_media_entries){
    $result = $client->media->listAction($filter, $pager);
        foreach ($result->objects as $entry) {
            $filter = new KalturaAssetFilter();
            $filter->entryIdEqual = $entry->id;
            // you can filter and only get flavor assets with certain tags
            //$filter->tagsLike = 'source';
            // or status
            // $filter->statusIn=
            $pager = null;
            $result = $client->flavorAsset->listAction($filter, $pager);
            echo 'Flavour assets for entry ID '. $entry->id ."\n";
            foreach ($result->objects as $flavour) {
                // currently just printing the ID and tags, here is where you would call flavorAsset->reconvert()
                echo $flavour->id . "\n";
                echo $flavour->tags . "\n";

Thanks !
This is what I am looking for :slight_smile: