Advertising sustains the DA. Ads are hidden for members. Join today

Computed Field

Computed field: Calculate duration of CCK video field

Last updated on
30 April 2025

If you have installed video and ffmpeg_wrapper modules and want to calculate duration of your video CCK field in Computed field in the same content type, this is the code for it.

In computed code enter this:

if (!$node->nid) node_save($node);
$filepath = "";
module_load_include('inc', 'ffmpeg_wrapper', 'ffmpeg_wrapper_class');
$duration = ffmpeg_wrapper_get_file_duration($node->field_video_file[0]['filepath']);
$node_field[0]['value'] = $duration;

where field_video_file is the name of CCK video file field (so change this to correspond to your CCK filed)

In display format eneter this:

$display = $node_field_item['value'] . ' sec';

Help improve this page

Page status: Not set

You can: