google-cloud-platformgoogle-cloud-transcoder

crop functionality not working in Google Transcoder API


I'm trying to crop videos with the Google Transcoder API as described here: https://cloud.google.com/transcoder/docs/how-to/crop-videos

The transcoding runs successfully but no crop happens and the transcoding job details are actually missing the crop request.

I'm using npm @google-cloud/video-transcoder version 1.5.0

This is the json request:

{
    "parent": "projects/.../locations/us-central1",
    "job": {
        "config": {
            "pubsubDestination": {
                "topic": "projects/.../topics/..."
            },
            "elementaryStreams": [
                {
                    "key": "video-stream0",
                    "videoStream": {
                        "frameRate": 30,
                        "widthPixels": 480,
                        "codec": "h264",
                        "heightPixels": 270,
                        "bitrateBps": 150000,
                        "preset": "slower"
                    }
                },
                {
                    "key": "audio-stream0",
                    "audioStream": {
                        "codec": "aac",
                        "bitrateBps": 2000
                    }
                }
            ],
            "muxStreams": [
                {
                    "key": "g7FNokXVOuyCgw767Oz7",
                    "container": "mp4",
                    "fileName": "g7FNokXVOuyCgw767Oz7",
                    "elementaryStreams": [
                        "video-stream0",
                        "audio-stream0"
                    ]
                }
            ],
            "inputs": [
                {
                    "uri": "gs://.../g7FNokXVOuyCgw767Oz7.165.165",
                    "preprocessingConfig": {
                        "crop": {
                            "topPixels": 100
                        }
                    },
                    "key": "input0"
                }
            ],
            "output": {
                "uri": "gs://.../"
            }
        }
    }
}

When I inspect the job, here is what I see, the crop is gone:

{
  "config": {
    "editList": [
      {
        "inputs": [
          "input0"
        ],
        "key": "atom0",
        "startTimeOffset": "0s"
      }
    ],
    "elementaryStreams": [
      {
        "key": "video-stream0",
        "videoStream": {
          "bitrateBps": 150000,
          "codec": "h264",
          "crfLevel": 21,
          "entropyCoder": "cabac",
          "frameRate": 30.0,
          "gopDuration": "3s",
          "heightPixels": 270,
          "pixelFormat": "yuv420p",
          "preset": "slower",
          "profile": "high",
          "rateControlMode": "vbr",
          "vbvFullnessBits": 135000,
          "vbvSizeBits": 150000,
          "widthPixels": 480
        }
      },
      {
        "audioStream": {
          "bitrateBps": 2000,
          "channelCount": 2,
          "channelLayout": [
            "fl",
            "fr"
          ],
          "codec": "aac",
          "sampleRateHertz": 48000
        },
        "key": "audio-stream0"
      }
    ],
    "inputs": [
      {
        "key": "input0",
        "preprocessingConfig": {
          "audio": {},
          "color": {},
          "crop": {},
          "deblock": {},
          "denoise": {
            "tune": "standard"
          },
          "pad": {}
        },
        "uri": "gs://.../g7FNokXVOuyCgw767Oz7.165.165"
      }
    ],
    "muxStreams": [
      {
        "container": "mp4",
        "elementaryStreams": [
          "video-stream0",
          "audio-stream0"
        ],
        "fileName": "g7FNokXVOuyCgw767Oz7",
        "key": "g7FNokXVOuyCgw767Oz7"
      }
    ],
    "output": {
      "uri": "gs://.../"
    },
    "pubsubDestination": {
      "topic": "projects/.../topics/..."
    }
  },
  "createTime": "2021-07-27T03:23:46.089Z",
  "endTime": "2021-07-27T03:23:59.534Z",
  "name": "projects/372477578623/locations/us-central1/jobs/220420ff5a110eaa92c66d00d1f33df6",
  "startTime": "2021-07-27T03:23:52.106Z",
  "state": "SUCCEEDED",
  "ttlAfterCompletionDays": 30
}

Did anyone have any luck in cropping video with the Google Cloud Transcoder API?

[If Google developers see this post, the job name is in the snippet.]


Solution

  • I installed the NodeJS module and tried running a job with the same config, and can confirm that this reproduces.

    The issue might be that the v1beta1 proto for client libraries hasn't been synced up since it was originally created.

    We have created a fix and deploy to prod. It should work now.