Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

AVAsset.Image

Returns an image for the asset at or near a specified time.

Component Version macOS Windows Linux Server iOS SDK
AVAsset 5.2 ✅ Yes ❌ No ❌ No ✅ Yes, on macOS ✅ Yes
MBS( "AVAsset.Image"; Asset; Time { ; ImageType; FileName; Width; Height } )   More

Parameters

Parameter Description Example Flags
Asset The reference number of the asset. Please use AVAsset.OpenContainer, AVAsset.OpenFile or AVAsset.OpenURL function to get asset reference. $asset
Time The position in the video in seconds. 5.2
ImageType The type of image to return.
Either JPEG, PNG, GIF or BMP. Default is JPEG.
"JPEG" Optional
FileName The filename to use for the picture.
Default is "image" with the extension matching the image type.
"test.jpg" Optional
Width The maximum width to use. 500 Optional
Height The maximum height to use. 500 Optional

Result

Returns container value with image or error.

Description

Returns an image for the asset at or near a specified time.
The time may not exactly be possible, so a nearby frame may be picked.
You can call AVAsset.RequestImageTimePrecision before to request exact timings for images. Query AVAsset.ImageActualTime function to see which time the image was created from.

If you need this functionality on Linux or Windows, you can use Shell functions and run ffmpeg command line to extract a frame for you.

Examples

Queries image at 5 seconds:

MBS( "AVAsset.Image"; $asset; 5; "jpeg"; "preview.jpg")

Make a preview from video:

# try video via AVAsset functions
If [ $CouldBeVideo ]
    Set Variable [ $asset ; Value: MBS( "AVAsset.OpenContainer"; $input ) ]
    If [ MBS("IsError") = 0 ]
        Set Variable [ $image ; Value: MBS( "AVAsset.Image"; $asset; 10; "jpeg"; "preview.jpg") ]
        If [ MBS("IsError") = 0 ]
            Set Field [ Get Preview::Preview ; $image ]
            Set Field [ Get Preview::Made using ; "AVAsset" ]
            Set Variable [ $r ; Value: MBS( "AVAsset.Release"; $asset ) ]
            Exit Script [ Text Result: ]
        End If
        Set Variable [ $r ; Value: MBS( "AVAsset.Release"; $asset ) ]
    End If
End If

See also

Example Databases

Blog Entries

This function checks for a license.

Created 19th June 2015, last changed 15th April 2023


AVAsset.HasProtectedContent - AVAsset.ImageActualTime