2021年3月30日星期二

Azure Media Services - v3 Overlay position issue

I am working on an encoding flow that adds an overlay image to the video. I want this watermark to be in the bottom right corner. No matter what I try with the position parameter, the watermark is positioned in the top left.

Can someone point me to a sample that covers that scenario? The Microsoft docs and samples are vague about positioning the overlay and setting the opacity.

Here is a snippet of code that contains my transform definition. Regardless of the overlay settings, I can use any values for the rectangle position element and nothing changes. The watermark ends up in the upper right of the video. Its like the position and opacity properties are being ignored.

 new AMSModels.TransformOutput(              new AMSModels.StandardEncoderPreset(                   filters: new AMSModels.Filters                          {                              Overlays = new List<AMSModels.Overlay>                              {                                  new AMSModels.VideoOverlay()                                  {                                      InputLabel =  "tbvvideooverlay",                                      Opacity = .5,                                      Position = new AMSModels.Rectangle(){ Left = "100", Top = "100", Width = "100", Height = "100"} //**I've tried all types of values here including percentages, nothing changes when I reencode the video.**                                      }                              }                          },                  codecs: new AMSModels.Codec[]                  {                      // Add an AAC Audio layer for the audio encoding                      new AMSModels.AacAudio(                          channels: 2,                          samplingRate: 48000,                          bitrate: 128000,                          profile: AMSModels.AacAudioProfile.AacLc                      ),                      // Next, add a H264Video for the video encoding                     new AMSModels.H264Video (                          // Set the GOP interval to 2 seconds for all H264Layers                          keyFrameInterval:TimeSpan.FromSeconds(2),                           // Add H264Layers. Assign a label that you can use for the output filename                          layers:  new AMSModels.H264Layer[]                          {                              new AMSModels.H264Layer (                                  bitrate: 3600000, // Units are in bits per second and not kbps or Mbps - 3.6 Mbps or 3,600 kbps                                  width: "1280",                                  height: "720",                                  label: "3600" // This label is used to modify the file name in the output formats                              ),                              new AMSModels.H264Layer (                                  bitrate: 1600000, // Units are in bits per second and not kbps or Mbps - 1.6 Mbps or 1600 kbps                                  width: "960",                                  height: "540",                                  label: "1600" // This label is used to modify the file name in the output formats                              ),                              new AMSModels.H264Layer (                                  bitrate: 600000, // Units are in bits per second and not kbps or Mbps - 0.6 Mbps or 600 kbps                                  width: "640",                                  height: "360",                                  label: "600" // This label is used to modify the file name in the output formats                              ),                          }                      ),                      // Also generate a set of PNG thumbnails                      new AMSModels.PngImage(                          start: "10%",                          step: "10%",                          range: "90%",                          layers: new Microsoft.Azure.Management.Media.Models.PngLayer[]{                              new AMSModels.PngLayer(                                  width: "100%",                                  height: "100%"                              )                          }                      ),                      new AMSModels.JpgImage(                          start: "10%",                          step: "10%",                          range: "90%",                          layers: new Microsoft.Azure.Management.Media.Models.JpgLayer[]{                              new AMSModels.JpgLayer(                                  quality: 100,                                  width: "100%",                                  height: "100%"                              )                          }                      )                  },                  // Specify the format for the output files - one for video+audio, and another for the thumbnails                  formats: new AMSModels.Format[]                  {                      // Mux the H.264 video and AAC audio into MP4 files, using basename, label, bitrate and extension macros                      // Note that since you have multiple H264Layers defined above, you have to use a macro that produces unique names per H264Layer                      // Either {Label} or {Bitrate} should suffice                                             new AMSModels.Mp4Format(                          filenamePattern:"{Basename}_{Resolution}_{Bitrate}{Extension}"                      ),                      new AMSModels.PngFormat(                          filenamePattern:"Thumbnail-{Basename}-{Index}{Extension}"                      ),                          new AMSModels.JpgFormat(                          filenamePattern:"Thumbnail-{Basename}-{Index}{Extension}"                      )                  }              ),              onError: AMSModels.OnErrorType.StopProcessingJob,              relativePriority: AMSModels.Priority.Normal          )          };                string description = "A simple custom encoding transform with 2 MP4 bitrates";              // Create the custom Transform with the outputs defined above              transform = await client.Transforms.CreateOrUpdateAsync(resourceGroupName, accountName, transformName, outputs, description);          }  

Thank you!

https://stackoverflow.com/questions/66864532/azure-media-services-v3-overlay-position-issue March 30, 2021 at 11:50AM

没有评论:

发表评论