Dolby
  • Up and Running
  • Getting Started
  • Amazon IAM
  • Configure Web Player
  • Hybrik JSON
  • Hybrik REST API
  • Hybrik API with Postman
  • Stitching
  • Trimming
  • Definitions and Placeholders
  • Tagging
  • Analyze and Quality Control
  • Quality Control Jobs
  • Troubleshooting Tips
  • Amazon Web Services
  • Sources
  • Hybrik JSON
  • Video Filters
  • Audio Filters
  • Working with Audio
  • Task Modifiers
  • Package Task
  • Analysis & Quality Control
  • Dolby Technologies
  • Additional Tasks
  • Hybrik Versions
  • QC Player
  • Machine Performance Analysis

    Trimming Tutorial

    In most transcoding operations, the entire contents of one file are converted into a different format. However, there can be cases where you don’t want the entire file and instead want only a sub-segment of the file to be converted. Some examples include:

    • Removing bars and tone from the beginning of a video
    • Removing excess material from the end of a video
    • Extracting a short selection to use as a preview video
    • Transcoding a segment in order to rapidly test encoding parameters

    Within the Hybrik job JSON, you can specify each of these types of transcodes using the “trim” specifier. In this short tutorial, we will show you how to use the “trim” operation on your content. You should already be familiar with Hybrik’s JSON structure before going further. If not, please take a few minutes to read the Hybrik JSON Tutorial before continuing.

    The Trim Operation

    The trim operation is specified by adding it to the source element. Our normal (untrimmed) source element looks like this:

    {
      "uid": "source_file",
      "kind": "source",
      "payload": {
        "kind": "asset_url",
        "payload": {
          "storage_provider": "s3",
          "url": "s3://hybrik-examples/public/sources/sample1.mp4"
        }
      }
    }
    

    By adding a “trim” object, you can specify how you would like Hybrik to trim the source content. Here is the same example source file, but this time we have specified that we want create an output that is only 60 seconds long – starting from 5 seconds into the video:

    {
      "uid": "source_file",
      "kind": "source",
      "payload": {
        "kind": "asset_url",
        "payload": {
          "storage_provider": "s3",
          "url": "s3://hybrik-examples/public/sources/sample1.mp4",
          "trim": {
            "inpoint_sec": 5,
            "outpoint_sec": 65
          }
        }
      }
    }
    

    Trim Variations

    Hybrik provides a variety of ways that you can specify the trim operation. For example, if you do not specify the outpoint, the trim will include the entirety of the source after the inpoint. This example uses everything after the first 6 seconds of the file:

    "trim": {
        "inpoint_sec": 6
    }
    

    Conversely, if you do not specify an inpoint, Hybrik will use the start of the file as the starting point. This example uses only the first 2 minutes of the source file:

    "trim": {
        "outpoint_sec": 120
    }
    

    You can also specify an inpoint and a duration. This example creates a 2 minute clip, starting at 1 minute into the source file:

    "trim": {
        "inpoint_sec": 60,
        "duration_sec": 120
    }
    

    Frames and Timecode

    In addition to specifying start and end points in seconds, you can also specify them by timecode format. Here is an example using the timecode designation to trim out a 2 minute clip starting at 20 seconds into the source file. Use this when you want to specify timecode by timecode format but ignore any existing timecode in the source:

    "trim": {
        "inpoint_tc": "00:00:20:00",
        "outpoint_tc": "00:02:20:00"
    }
    

    To trim by source timecode value (not just timecode formatting), the syntax is inpoint_asset_tc and outpoint_asset_tc. These will reference the timecode found in the source asset:

    "trim": {
        "inpoint_asset_tc": "01:01:30:00",
        "outpoint_asset_tc": "01:02:30:00"
    }
    

    If the source asset doesn’t contain timecode, the above will cause an error.

    And finally, you can specify trimming using frame numbers. Here is an example using frame numbers in a 24 frame per second input video. This frame number designation trims out a 2 minute clip starting at 1 minute into the source file:

    "trim": {
        "inpoint_frame": 1440,
        "outpoint_frame": 4320
    }
    

    Examples

    • Trim by Time
    • Trim by Timecode Format
    • Trim by Timecode in Source