移除spriteSheets图像名称的后缀

huangapple go评论62阅读模式
英文:

Remove the suffix of spriteSheets image name

问题

I understand. Here's the translated content:

我对Transcoder API有以下工作请求:

```js
  const request = {
    parent,
    job: {
      inputUri: `gs://${bucket}/${name}`,
      outputUri: `gs://${settings.bucket.cdn}/${fileName}/`,
      config: {
        pubsubDestination: {
          topic: `projects/${settings.project.id}/topics/${settings.pubsub.transcoder}`,
        },
        elementaryStreams: [
          {
            key: 'video-stream',
            videoStream: {
              h265: {
                heightPixels: 1080,
                widthPixels: 1920,
                bitrateBps: 12288000,
                frameRate: 60,
              },
            },
          },
        ],
        muxStreams: [
          {
            key: 'video',
            container: 'mp4',
            elementaryStreams: ['video-stream'],
          },
        ],
        spriteSheets: [
          {
            filePrefix: 'spritesheet',
            quality: 90,
            spriteWidthPixels: 360,
            interval: {
              seconds: 3,
            },
          },
        ],
      },
    },
  } 满足 protos.google.cloud.video.transcoder.v1.ICreateJobRequest

它有效。

然而,它生成了不可预测的文件名,例如前缀 spritesheet 会得到 spritesheet0000000000.jpeg

有可能修复这个名称,使其没有这些数字吗?


<details>
<summary>英文:</summary>

I have the following job request for Transcoder API

const request = {
parent,
job: {
inputUri: gs://${bucket}/${name},
outputUri: gs://${settings.bucket.cdn}/${fileName}/,
config: {
pubsubDestination: {
topic: projects/${settings.project.id}/topics/${settings.pubsub.transcoder},
},
elementaryStreams: [
{
key: 'video-stream',
videoStream: {
h265: {
heightPixels: 1080,
widthPixels: 1920,
bitrateBps: 12288000,
frameRate: 60,
},
},
},
],
muxStreams: [
{
key: 'video',
container: 'mp4',
elementaryStreams: ['video-stream'],
},
],
spriteSheets: [
{
filePrefix: 'spritesheet',
quality: 90,
spriteWidthPixels: 360,
interval: {
seconds: 3,
},
},
],
},
},
} satisfies protos.google.cloud.video.transcoder.v1.ICreateJobRequest


It works. 


However, it generates unpredictable filenames, for example prefix `spritesheet` I get `spritesheet0000000000.jpeg`


Is it possible to fix the name without those numbers?


</details>


# 答案1
**得分**: 1

对于 [`spritesheet`](https://cloud.google.com/transcoder/docs/reference/rest/v1/JobConfig#spritesheet) 参数,您只能指定 `file_prefix`。

根据[文档](https://cloud.google.com/transcoder/docs/reference/rest/v1/JobConfig#spritesheet:~:text=每个精灵表都有一个增量的10位零填充后缀,从0开始,直到扩展名之前,比如`sprite_sheet0000000123.jpeg.`:

> 每个精灵表都有一个增量的10位零填充后缀,从0开始,直到扩展名之前,比如 `sprite_sheet0000000123.jpeg.`

这样做是为了在有多个输出文件时防止文件名冲突。

您可以按照 [列出对象](https://cloud.google.com/storage/docs/listing-objects#client-libraries) 文档中所示,通过使用前缀访问Google Cloud Storage中的文件。

<details>
<summary>英文:</summary>

For the [`spritesheet`](https://cloud.google.com/transcoder/docs/reference/rest/v1/JobConfig#spritesheet) parameter, you can only specify the `file_prefix`.

From the [documentation](https://cloud.google.com/transcoder/docs/reference/rest/v1/JobConfig#spritesheet:~:text=Each%20sprite%20sheet%20has%20an%20incremental%2010%2Ddigit%20zero%2Dpadded%20suffix%20starting%20from%200%20before%20the%20extension%2C%20such%20as%20sprite_sheet0000000123.jpeg.):

&gt; Each sprite sheet has an incremental 10-digit zero-padded suffix starting from 0 before the extension, such as `sprite_sheet0000000123.jpeg.`

This is done to prevent file name collisions when there are multiple output files.

You can access files in Google Cloud Storage by using a prefix as shown in the [Listing objects](https://cloud.google.com/storage/docs/listing-objects#client-libraries) documentation.



</details>



huangapple
  • 本文由 发表于 2023年4月6日 20:44:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/75949688.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定