in media/transcoder/api/Transcoder.Samples/CreateJobWithSetNumberImagesSpritesheet.cs [26:135]
public Job CreateJobWithSetNumberImagesSpritesheet(
string projectId, string location, string inputUri, string outputUri)
{
// Create the client.
TranscoderServiceClient client = TranscoderServiceClient.Create();
// Build the parent location name.
LocationName parent = new LocationName(projectId, location);
// Build the job config.
VideoStream videoStream0 = new VideoStream
{
H264 = new VideoStream.Types.H264CodecSettings
{
BitrateBps = 550000,
FrameRate = 60,
HeightPixels = 360,
WidthPixels = 640
}
};
AudioStream audioStream0 = new AudioStream
{
Codec = "aac",
BitrateBps = 64000
};
// Generates a 10x10 spritesheet of small images from the input video.
// To preserve the source aspect ratio, you should set the
// SpriteWidthPixels field or the SpriteHeightPixels field, but not
// both (the API will automatically calculate the missing field). For
// this sample, we don't care about the aspect ratio so we set both
// fields.
SpriteSheet smallSpriteSheet = new SpriteSheet
{
FilePrefix = SmallSpritesheetFilePrefix,
SpriteHeightPixels = 32,
SpriteWidthPixels = 64,
ColumnCount = 10,
RowCount = 10,
TotalCount = 100
};
// Generates a 10x10 spritesheet of larger images from the input video.
// input video. To preserve the source aspect ratio, you should set the
// SpriteWidthPixels field or the SpriteHeightPixels field, but not
// both (the API will automatically calculate the missing field). For
// this sample, we don't care about the aspect ratio so we set both
// fields.
SpriteSheet largeSpriteSheet = new SpriteSheet
{
FilePrefix = LargeSpritesheetFilePrefix,
SpriteHeightPixels = 72,
SpriteWidthPixels = 128,
ColumnCount = 10,
RowCount = 10,
TotalCount = 100
};
ElementaryStream elementaryStream0 = new ElementaryStream
{
Key = "video_stream0",
VideoStream = videoStream0
};
ElementaryStream elementaryStream1 = new ElementaryStream
{
Key = "audio_stream0",
AudioStream = audioStream0
};
MuxStream muxStream0 = new MuxStream
{
Key = "sd",
Container = "mp4",
ElementaryStreams = { "video_stream0", "audio_stream0" }
};
Input input = new Input
{
Key = "input0",
Uri = inputUri
};
Output output = new Output
{
Uri = outputUri
};
JobConfig jobConfig = new JobConfig
{
Inputs = { input },
Output = output,
ElementaryStreams = { elementaryStream0, elementaryStream1 },
MuxStreams = { muxStream0 },
SpriteSheets = { smallSpriteSheet, largeSpriteSheet }
};
// Build the job.
Job newJob = new Job();
newJob.InputUri = inputUri;
newJob.OutputUri = outputUri;
newJob.Config = jobConfig;
// Call the API.
Job job = client.CreateJob(parent, newJob);
// Return the result.
return job;
}