1. Trang chủ
  2. » Công Nghệ Thông Tin

Quản lý cấu hình web - part 39 ppt

10 166 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 10
Dung lượng 5,96 MB

Nội dung

Leveraging Alfresco Framework for WCM [ 362 ] Various options for video transcoding Following are the various options for video transcoding: • -b bitrate Set the video bitrate in bit/s (default = 200 kb/s). =>512 k • -r fps Set frame rate (Hz value, fraction, or abbreviation), (default = 25). =>15.02 • -s size Set frame size. The format is 'wxh' (ffserver default = 160x128, ffmpeg default = same as source). =>320x240 • -aspect aspect Set aspect ratio (4:3, 16:9 or 1.3333, 1.7777). =>4:3 Various options for audio transcoding Following are the various options for audio transcoding: • -ar freq Set the audio sampling frequency (default = 44100 Hz). => 44100 • -ab bitrate Set the audio bitrate in bit/s (default = 64 k). => 64 k • -ac channels Set the number of audio channels (default = 1 Mono; 2 = stereo). => 2 For further details and all options, you can refer to http://www.ffmpeg.org/ ffmpeg-doc.html . Download from Wow! eBook <www.wowebook.com> Chapter 11 [ 363 ] Integrating transformation as an Action in Alfresco In this section, we will see how we can use FFMPEG transformations as a custom action in Alfresco. From there we can trigger some business rules on the spaces, which will execute this custom action to perform transformation of all video les. Follow these steps to execute the transformation: 1. We need to congure the extra mime types that we want to use. Here in our case, we are using 3GP, MP2, MP4, AVI, MOV, and many more. All others are already supported by Alfresco and are dened in the mimetype-map.xml le in Alfresco (except 3GP). So we need to add 3GP as a mimetype supported by Alfresco in the mimetype-map le, as follows: <config evaluator="string-compare" condition="Mimetype Map"> <mimetypes> <mimetype mimetype="video/3gp" display="Mobile video"> <extension>3gp</extension> </mimetype> </mimetypes> </config> 2. The next step is, as FFMPEG is a command-line interface, we can use Alfresco's org.alfresco.util.exec.RuntimeExec class to execute this command. For that we need to congure it as a bean, which will be referred by our custom action executer. We can make these bean entries in the custom-services-context.xml le. <bean id="transformer.ffmpegVideo" class="com.cignex.alfresco.repo.content.transform. FfmpegVideoContentTransformer" parent="baseContentTransformer" init-method=»init»> <property name=»executer»> <bean name=»transformer.ffmpegVideo.Command» class=»org.alfresco.util.exec.RuntimeExec»> <property name=»commandMap»> <map> <entry key=»Windows.*»> <value>ffmpeg -i «${source}» ${options} «${target}»</value> </entry> </map> </property> <property name=»defaultProperties»> <props> <prop key="options"></prop> </props> Download from Wow! eBook <www.wowebook.com> Leveraging Alfresco Framework for WCM [ 364 ] </property> </bean> </property> </bean> <bean id="transform-video" class="com.cignex.alfresco.repo.action.executer. FfmpegVideoTransformActionExecuter" parent=»transform»> <property name=»videoContentTransformer»> <ref bean=»transformer.ffmpegVideo» /> </property> </bean> 3. In the web-client-config-custom.xml le, add the following: <config evaluator="string-compare" condition="Action Wizards"> <video-transformers> <transformer name="video/x-msvideo"/> <transformer name="video/mp4"/> <transformer name="video/3gp"/> <transformer name="video/x-ms-wmv"/> </video-transformers> <action-handlers> <handler name="transform-video" class="com.cignex.alfresco.web.bean.actions.handlers. FfmpegTransformVideoHandler" /> </action-handlers> </config> 4. Here you can specify all transformer names, and the formats you want to support in the transform action from the Alfresco UI as: <transformer name="video/mp4"/> 5. You can add more if you want; here we have congured four different formats. 6. Once this is done, you need to create custom Action Executer classes and do the congurations for this. You can also refer to the following Wikis for more detail on these: http://wiki.alfresco.com/wiki/Custom_Actions http://wiki.alfresco.com/wiki/Wizard_Framework Download from Wow! eBook <www.wowebook.com> Chapter 11 [ 365 ] 7. After nishing creation and conguration of the Action Executer, you are ready with the example code. Now start the Alfresco server and we will see how you can congure the rule for transformation. 8. We will create the folder structure such as Company Home | Cignex | videos. Inside the videos space, create spaces for all different types of formats (for video) that you want to support (that is, MPEG4, 3GP, and so on). Conguring FFMPEG transformation as a business rule Alfresco DM provides the business rule; you can congure a business rule for a particular type of content or for all the content in a particular space. Here we will congure a business rule on the videos space to transform the videos we upload in this space to convert into other formats. 1. Browse to Company Home | Cignex | videos and click on More Actions | Manage Content Rules. On the next screen, click on the Create Rule link. In the rst step of the Create Rule Wizard, select All Items and click on Add to List. Click on Next. 2. In the next step, you can see the action created by us in the Select Action combo box. Select the action Transform video using FFMPEG and copy, as shown in the following screenshot. Click on Next: Download from Wow! eBook <www.wowebook.com> Leveraging Alfresco Framework for WCM [ 366 ] 3. In the next step, you need to select the proper value for the required format (the target format for transformation). As we have congured 3GP, MP4, AVI, and WMV in the conguration le, we will have all these four options available to us for transforming the video. After that, provide the proper options for a particular video transformation selection based on source- and target-type of video le. Also, you need to provide the destination space to copy the transformed video. Here we have created the 3GP space inside the videos folder, so provide it as a destination folder. Click on OK. 4. In the next step, choose Type as Inbound; also provide Title and Description. Check the option Apply rule to sub spaces as shown in the following screenshot. Click on Finish: Download from Wow! eBook <www.wowebook.com> Chapter 11 [ 367 ] Now whenever you upload any video in videos space, it will be transformed into the 3GP video format. It will also be copied to the 3GP space inside the videos space as shown in the next screenshot: You can create as many rules and transformations as you want to perform for different video types. Download the sample code les from the Packt website. Copying videos from DM to WCM In this section, we will discuss the different ways to copy the content—here videos from DM to WCM. One is with the help of business rule and the other one is using JavaScript. Both of these are described in the following sections. DM to WCM using business rule We have videos available in all required formats under Company Home | Cignex | videos and the respective folders for the video formats. Now we need to move these videos in WCM in the proper web project and to the proper folder. Download from Wow! eBook <www.wowebook.com> Leveraging Alfresco Framework for WCM [ 368 ] There is one more rule available in DM, which will copy the DM content to WCM. For this, you need to congure that rule. Use the following steps: 1. Browse to Company Home | Cignex | videos and click on More Actions | Manage Content Rules. In the next screen, click on the Create Rule link. In the rst step of the Create Rule Wizard, select All Items and click on Add to List. Click on Next. 2. In the next step, you can see the action created by us in the Select Action combo box. Select the Copy item to a folder in a web project action, as shown in the following screenshot. Click on Next: Download from Wow! eBook <www.wowebook.com> Chapter 11 [ 369 ] 3. In the next screen, select the web project and the specic folder in that web project as Destination folder and click on OK as shown in the following screenshot: 4. Then click on Next. In the next screen, choose Type as Inbound and provide the Title and the Description. Also select Apply rule to sub spaces as shown in the next screenshot. Click on Finish: Download from Wow! eBook <www.wowebook.com> Leveraging Alfresco Framework for WCM [ 370 ] DM to WCM using JavaScript There is one API available in Alfresco JavaScript, which allows you to copy content from one repository to another. Using this API, you can copy the content from DM to WCM. Here we will copy all the videos, which we transformed previously to a specic folder in the web project. Alfresco JavaScript has crossRepoCopy as one of the root objects, using which we can copy nodes or content between the different repositories (Document Management and Web Content Management). copy(ScriptNode source, ScriptNode destination, String name): This will copy a source node to the specied destination node and return the new node. In the parameter name, you can specify the new name for that content, which is being copied to some other location. Using this API, we can copy all of the transformed video from the DM repository to the WCM repository, as follows: 1. Create new JavaScript le, copy_wcm.js, with the following content: logger.log("Document :: " + document.name); var l_cignex_root=avm.lookupStore("wwwcignex admin"); l_video_path="/ROOT/videos"; if(l_cignex_root != null) { l_videoNode = l_cignex_root.lookupNode(l_video_path + "/"); if(l_videoNode != null){ crossRepoCopy.copy(document,l_videoNode,document.name); logger.log(document.name + " is copied"); } } 2. Upload this JavaScript le to the Company Home | Data Dictionary | Scripts space in Alfresco. Download from Wow! eBook <www.wowebook.com> Chapter 11 [ 371 ] 3. Now, with the help of Run Action, you can execute this script. Go to the View Details page of the video content, which you want to copy to the WCM. Click on Run Action from the available actions, as shown in the following screenshot: Download from Wow! eBook <www.wowebook.com> . </property> </bean> 3. In the web- client-config-custom.xml le, add the following: <config evaluator="string-compare" condition="Action Wizards"> <video-transformers> <transformer. name="video/x-msvideo"/> <transformer name="video/mp4"/> <transformer name="video/3gp"/> <transformer name="video/x-ms-wmv"/> </video-transformers> <action-handlers> . name="video/x-ms-wmv"/> </video-transformers> <action-handlers> <handler name="transform-video" class="com.cignex.alfresco .web. bean.actions.handlers. FfmpegTransformVideoHandler" /> </action-handlers> </config> 4.

Ngày đăng: 05/07/2014, 20:21

w