Skip to content

Tutorial.8 Overlay an image on a video

Giuliano Catrambone edited this page May 22, 2018 · 4 revisions

This tutorial implements the following Workflow:

  • a video and an image is added into MMS in parallel
  • as soon as the image is in MMS, it is encoded according the 'Profile Logo' profile
  • once all the above activities are finished, the encoded images (Profile Logo) is overlayed on the video

Reference manual for

Input creation (json)

Create a file (demo_8.json) having the following content

{
    "Type": "Workflow",
    "Label": "1",
    "Variables": {
        "TitleOfVideo_1": "My Title of the video_1 content",
        "TitleOfImage_1": "My Title of the logo content",
        "TitleOfOverlayVideo_1": "My Title of the overlay content"
    },
    "Task": {
        "Type": "GroupOfTasks",
        "Parameters": {
            "ExecutionType": "parallel",
            "Tasks": [
                {
                    "Label": "${TitleOfVideo_1}",
                    "Type": "Add-Content",
                    "Parameters": {
                        "SourceURL": "http://techslides.com/demos/sample-videos/small.mp4",
                        "FileFormat": "mp4",
                        "ContentType": "video",
                        "UserData": { "MyData": "this is my video data" },
                        "Title": "${TitleOfVideo_1}",
                        "Retention": "0s"
                    }                   
                },              
                {               
                    "Label": "${TitleOfImage_1}",
                    "Type": "Add-Content",
                    "Parameters": {     
                        "SourceURL": "copy:///home/mms/catramms/CatraMMS/samples/free-logo.jpg",
                        "FileFormat": "jpg",    
                        "ContentType": "image", 
                        "UserData": { "MyData": "this is my image data" },
                        "Title": "${TitleOfImage_1}",
                        "Retention": "0s"
                    },                  
                    "OnSuccess": {      
                        "Task": {               
                            "Label": "my image encode", 
                            "Type": "Encode",           
                            "Parameters": {             
                                "EncodingPriority": "Low",      
                                "EncodingProfileLabel": "Profile Logo"
                            }                           
                        }                       
                    }                   
                }               
            ]
        },
        "OnSuccess": {
            "Task": {
                "Label": "my overlay",
                "Type": "Overlay-Image-On-Video",
                "Parameters": {
                    "ImagePosition_X_InPixel": "video_width-image_width-10",
                    "ImagePosition_Y_InPixel": "video_height-image_height-10",
                    "EncodingPriority": "High",
                    "References": [
                        { "ReferenceLabel": "my image encode", "EncodingProfileLabel": "Profile Logo" },
                        { "ReferenceLabel": "${TitleOfVideo_1}" }
                    ],
                    "UserData": { "MyData": "this is my overlay data" },
                    "Title": "${TitleOfOverlayVideo_1}",
                    "Retention": "1d"
                }
            }
        }
    }
}

Command

Run the following HTTP POST having as input userKey, APIKey and demo_6.json:

The return will be:

  • { "workflow": { "ingestionRootKey": 258, "label": "1" }, "tasks": [ { "ingestionJobKey": 872, "label": "My Title of the video_1 content" }, { "ingestionJobKey": 873, "label": "My Title of the logo content" }, { "ingestionJobKey": 874, "label": "my image encode" }, { "ingestionJobKey": 875, "label": "my overlay" } ] }

Get the status of the entire Workflow

To get the status of the above ingestion, run the HTTP GET having as input the ingestionRootKey:

The return will be:

{
	"workflow" : 
	{
		"ingestionRootKey" : 258,
		"label" : "1",
		"tasks" : 
		[
			{
				"downloadingProgress" : 100,
				"endIngestion" : "2018-05-15T14:28:56Z",
				"errorMessage" : null,
				"ingestionJobKey" : 872,
				"ingestionType" : "Add-Content",
				"label" : "My Title of the video_1 content",
				"mediaItemKey" : 16,
				"physicalPathKey" : null,
				"startIngestion" : "2018-05-15T14:28:52Z",
				"status" : "End_TaskSuccess",
				"uploadingProgress" : null,
				"videoDetails" : 
				{
					"audioBitRate" : 83050,
					"audioChannels" : 1,
					"audioCodecName" : "aac",
					"audioSampleRate" : 48000,
					"bitRate" : 551193,
					"durationInMilliSeconds" : 5000,
					"videoAvgFrameRate" : "30/1",
					"videoBitRate" : 465641,
					"videoCodecName" : "h264",
					"videoHeight" : 320,
					"videoProfile" : "Constrained Baseline",
					"videoWidth" : 560
				}
			},
			{
				"downloadingProgress" : null,
				"endIngestion" : "2018-05-15T14:28:56Z",
				"errorMessage" : null,
				"imageDetails" : 
				{
					"format" : "JPEG",
					"height" : 756,
					"quality" : 92,
					"width" : 650
				},
				"ingestionJobKey" : 873,
				"ingestionType" : "Add-Content",
				"label" : "My Title of the logo content",
				"mediaItemKey" : 17,
				"physicalPathKey" : null,
				"startIngestion" : "2018-05-15T14:28:52Z",
				"status" : "End_TaskSuccess",
				"uploadingProgress" : null
			},
			{
				"encoding" : 
				{
					"encodingFailuresNumber" : 0,
					"encodingJobEnd" : "2018-05-15T14:29:04Z",
					"encodingJobStart" : "2018-05-15T14:29:04Z",
					"encodingProgress" : 100,
					"encodingStatus" : "End_ProcessedSuccessful",
					"parameters" : 
					{
						"encodingProfileKey" : 6,
						"sourcePhysicalPathKey" : 21
					},
					"type" : "EncodeImage"
				},
				"endIngestion" : "2018-05-15T14:29:04Z",
				"errorMessage" : null,
				"imageDetails" : 
				{
					"format" : "JPEG",
					"height" : 47,
					"quality" : 92,
					"width" : 40
				},
				"ingestionJobKey" : 874,
				"ingestionType" : "Encode",
				"label" : "my image encode",
				"mediaItemKey" : 17,
				"physicalPathKey" : 22,
				"startIngestion" : "2018-05-15T14:28:52Z",
				"status" : "End_TaskSuccess"
			},
			{
				"encoding" : 
				{
					"encodingFailuresNumber" : 0,
					"encodingJobEnd" : "2018-05-15T14:29:19Z",
					"encodingJobStart" : "2018-05-15T14:29:14Z",
					"encodingProgress" : 100,
					"encodingStatus" : "End_ProcessedSuccessful",
					"parameters" : 
					{
						"imagePosition_X_InPixel" : "video_width-image_width-10",
						"imagePosition_Y_InPixel" : "video_height-image_height-10",
						"sourceImagePhysicalPathKey" : 22,
						"sourceVideoPhysicalPathKey" : 20
					},
					"type" : "OverlayImageOnVideo"
				},
				"endIngestion" : "2018-05-15T14:29:19Z",
				"errorMessage" : null,
				"ingestionJobKey" : 875,
				"ingestionType" : "Overlay-Image-On-Video",
				"label" : "my overlay",
				"mediaItemKey" : 18,
				"physicalPathKey" : 23,
				"startIngestion" : "2018-05-15T14:28:52Z",
				"status" : "End_TaskSuccess",
				"videoDetails" : 
				{
					"audioBitRate" : 69275,
					"audioChannels" : 1,
					"audioCodecName" : "aac",
					"audioSampleRate" : 48000,
					"bitRate" : 286110,
					"durationInMilliSeconds" : 5000,
					"videoAvgFrameRate" : "30/1",
					"videoBitRate" : 207495,
					"videoCodecName" : "h264",
					"videoHeight" : 320,
					"videoProfile" : "High",
					"videoWidth" : 560
				}
			}
		]
	}
}
  1. Home

    Tutorial
    1. User registration
    2. Add content - Pull
    3. Add content, on success send an email
    4. Two Tasks (Add content) to be executed in parallel
    5. Add a set of video encoding profiles
    6. Add two contents, send an email, concat, cut and encode
    7. Add a single image profile (Logo)
    8. Add a video, an image, encode the image, overlay the encoded image on the video
  2. REST API version 1 (latest)

    Registration
    1. User registration
    2. Login
    3. Create Workspace
    4. Share Workspace
    5. Update Workspace
    6. Update User
    Workflow Ingestion
    1. Workflow
    2. Status/metadata of an ingestion
    3. Group Of Tasks
    Workflow As Library
    1. Workflow as Library
    2. Create-Update a Workflow as Library
    3. Delete a Workflow as Library
    4. Use of a Workflow as Library
    Add-Remove Content
    1. Add a new Content
      1. Pull
      2. Push
    2. Remove a Content
    3. Information about the contents saved into MMS
    4. Retention of a Content
    Delivery
    1. Download HTTP of a Content
    2. FTP of a Content
    3. Local copy of a Content
    4. Live Proxy
    5. VOD Proxy
    6. Countdown
    7. Check Streaming
    Social Network Delivery
    1. POST a Content on Facebook
    2. POST a Content on YouTube
    3. YouTube Live Broadcast
    4. Facebook Live Broadcast
    Encoding (video-audio-image)
    1. Add encoding profiles
    2. Remove encoding profiles
    3. Encode
    4. Information about the encoding profiles saved into MMS
    5. Predefined MMS Encoding Profiles
    Media activities
    1. Concatenate videos having same codecs
    2. Cut
    3. Video speed
    4. Extract tracks
    5. Add silent audio
    Overlay
    1. Overlay an Image on a Video
    2. Overlay a Text on a Video
    3. Picture In Picture
    4. Intro Outro Overlay
    5. Live Grid
    Frame Processing
    1. Frame of a video
    2. Periodical Frames of a video
    3. I-Frames of a video
    4. Motion JPEG video generated by Periodical Frames of a video
    5. Motion JPEG video generated by I-Frames of a video
    6. Slideshow video by images
    Recorder
    1. Live Recorder
    2. Live Cut
    Communication
    1. HTTP Callback
    2. Notification through email
    Utilities
    1. Change File Format
    2. Media Cross Reference
    Computer Vision
    1. Face Recognition
    2. Face Identification
    Configuration
    1. YouTube
    2. Facebook
    3. Live URL
    4. FTP
    5. E-Mail
Clone this wiki locally