Create Video node programmatically

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by Airborn on August 2, 2013 at 8:11am

Dear,

I would like to ask for some help regarding the topic mentioned in the title. My objective is to record a video through a webcam and pass it somehow to the Video module and create a Video node out of it. I can already upload videos to the module and transcode it through Zencoder and I'm already solved the recording part with the "Media: Webcam" module (https://drupal.org/project/media_webcam) but I don't know how to connect those two and pass the recorded video to the Video module.

Can you help me with this?

Thank you,
Alex

Categories: ,

Comments

I tried to make a small

Posted by Airborn on August 2, 2013 at 8:14am

I tried to make a small extension which gets the node before save with the hook_node_presave() but I don't know exaclty how to convert it to a Video node :S

Okay it seems to be solved

Posted by Airborn on August 2, 2013 at 8:59am

Okay it seems to be solved with this small hack:

function webcam_video_converter_node_presave($node) {
if ($node->type = 'webcam') {
$node->type = 'video';
$node->field_video['und'][0] = array_merge($node->field_webcam['und'][0], array(
'display' => 1,
'dimensions' => '1280x720',
'convert_video_on_save' => 1,
'bypass_autoconversion' => 0,
'use_default_video_thumb' => 0,
'conversionstatus' => NULL,
'thumbnail' => 0,
));
}
}

If you have a better solution, please inform me :)

Alex

There is a strange behavious

Posted by Airborn on August 2, 2013 at 9:25am

There is a strange behavious while using this code. The files are transcoded they are moved to S3 and after a time they are disappearing from there. I can't understand the reason.

I think it was because of a

Posted by Airborn on August 2, 2013 at 9:56am

I think it was because of a mistype in the if statement. Of course we need == insted of = :)
But I will test it a bit.

And the thumbnails are not

Posted by Airborn on August 2, 2013 at 9:25am

And the thumbnails are not created.

This one is also fixed by the

Posted by Airborn on August 2, 2013 at 1:30pm

This one is also fixed by the fix above

Video

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /