Skip to content

Commit dc4f449

Browse files
Improve the docs for transcode (#374)
1 parent 96dbaa9 commit dc4f449

File tree

13 files changed

+91
-12
lines changed

13 files changed

+91
-12
lines changed

__TESTS_BUNDLE_SIZE__/utils/stringGenerators/importFromDist.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Utility function used to import items from ./dist
33
* @param {string} pathInDist - relative path inside ./dist, for example 'actions/resize'
44
* The result will be `import resize from '../../dist/resize`;
5-
* * @returns string
5+
* @returns string
66
*/
77
function importFromDist(pathInDist: string, namedVariableName: string): string {
88

src/actions/transcode.ts

Lines changed: 79 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export type ITranscodeAction = BitRateAction
2727
* <b>Learn more:</b> {@link https://cloudinary.com/documentation/video_manipulation_and_delivery#transcoding_video_to_other_formats | Transcoding video to other formats}
2828
* @memberOf Actions
2929
* @namespace Transcode
30+
* @example
31+
* // See examples under each method
3032
*/
3133

3234
/**
@@ -36,7 +38,17 @@ export type ITranscodeAction = BitRateAction
3638
*
3739
* <b>Learn more</b>: {@link https://cloudinary.com/documentation/audio_transformations#audio_frequency_control | Audio frequency control}
3840
* @param {string|number} freq The audio frequency.
39-
* @return {AudioFrequencyAction}
41+
* @example
42+
* import {Cloudinary} from "@cloudinary/base/instance/Cloudinary";
43+
* import {FREQ11025} from '@cloudinary/base/qualifiers/audioFrequency'
44+
* import {audioFrequency} from '@cloudinary/base/actions/transcode'
45+
*
46+
* const yourCldInstance = new Cloudinary({cloud:{cloudName:'demo'}});
47+
* const video = yourCldInstance.video('dog');
48+
*
49+
* video.transcode(audioFrequency(FREQ11025()))
50+
* @return {Actions.Transcode.AudioFrequencyAction}
51+
*
4052
*/
4153
function audioFrequency(freq: string|number): AudioFrequencyAction{
4254
return new AudioFrequencyAction(freq);
@@ -46,7 +58,16 @@ function audioFrequency(freq: string|number): AudioFrequencyAction{
4658
* @memberOf Actions.Transcode
4759
* @description Sets the audio codec or removes the audio channel.
4860
* @param {string} codec The audio codec or "none".
49-
* @return {AudioCodecAction}
61+
* @example
62+
* import {Cloudinary} from "@cloudinary/base/instance/Cloudinary";
63+
* import {aac} from '@cloudinary/base/qualifiers/audioCodec'
64+
* import {audioCodec} from '@cloudinary/base/actions/transcode'
65+
*
66+
* const yourCldInstance = new Cloudinary({cloud:{cloudName:'demo'}});
67+
* const video = yourCldInstance.video('dog');
68+
*
69+
* video.transcode( audioCodec( aac() ) );
70+
* @return {Actions.Transcode.AudioCodecAction}
5071
*/
5172
function audioCodec(codec: string): AudioCodecAction{
5273
return new AudioCodecAction(codec);
@@ -64,7 +85,14 @@ function audioCodec(codec: string): AudioCodecAction{
6485
* uses a variable bitrate (VBR), with this value indicating the maximum bitrate.
6586
* The value can be an integer e.g. 120000, or a string supporting "k" and "m"
6687
* (kilobits and megabits respectively) e.g. 250k or 2m.
67-
* @return {BitRateAction}
88+
* @example
89+
* import {Cloudinary} from "@cloudinary/base/instance/Cloudinary";
90+
* import {bitRate} from '@cloudinary/base/actions/transcode'
91+
* const yourCldInstance = new Cloudinary({cloud:{cloudName:'demo'}});
92+
* const video = yourCldInstance.video('dog');
93+
*
94+
* video.transcode( bitRate(500).constant() );
95+
* @return {Actions.Transcode.BitRateAction}
6896
*/
6997
function bitRate(bitRate: string|number): BitRateAction {
7098
return new BitRateAction(bitRate);
@@ -74,7 +102,15 @@ function bitRate(bitRate: string|number): BitRateAction {
74102
* @summary action
75103
* @memberOf Actions.Transcode
76104
* @param {number} from frame rate
77-
* @return {FPSAction}
105+
* @example
106+
* import {Cloudinary} from "@cloudinary/base/instance/Cloudinary";
107+
* import {fps} from '@cloudinary/base/actions/transcode'
108+
*
109+
* const yourCldInstance = new Cloudinary({cloud:{cloudName:'demo'}});
110+
* const video = yourCldInstance.video('dog');
111+
*
112+
* video.transcode( fps(15) );
113+
* @return {Actions.Transcode.FPSAction}
78114
*/
79115
function fps(from: number): FPSAction {
80116
return new FPSAction(from);
@@ -87,7 +123,15 @@ function fps(from: number): FPSAction {
87123
* delivered with an expected FPS level (helps with sync to audio).
88124
* @param {number} from frame rate
89125
* @param {number} to frame rate
90-
* @return {FPSRangeAction}
126+
* @example
127+
* import {Cloudinary} from "@cloudinary/base/instance/Cloudinary";
128+
* import {fpsRange} from '@cloudinary/base/actions/transcode'
129+
*
130+
* const yourCldInstance = new Cloudinary({cloud:{cloudName:'demo'}});
131+
* const video = yourCldInstance.video('dog');
132+
*
133+
* video.transcode( fpsRange( 20, 25 ) );
134+
* @return {Actions.Transcode.FPSRangeAction}
91135
*/
92136
function fpsRange(from: number, to?: number): FPSRangeAction {
93137
return new FPSRangeAction(from, to);
@@ -98,7 +142,15 @@ function fpsRange(from: number, to?: number): FPSRangeAction {
98142
* @memberOf Actions.Transcode
99143
* @description Sets the keyframe interval of the delivered video.
100144
* @param {number | string} interval The keyframe interval in seconds.
101-
* @return {KeyframeIntervalsAction}
145+
* @example
146+
* import {Cloudinary} from "@cloudinary/base/instance/Cloudinary";
147+
* import {keyframeInterval} from '@cloudinary/base/actions/transcode'
148+
*
149+
* const yourCldInstance = new Cloudinary({cloud:{cloudName:'demo'}});
150+
* const video = yourCldInstance.video('dog');
151+
*
152+
* video.transcode( keyframeInterval( 0.5 ) );
153+
* @return {Actions.Transcode.KeyframeIntervalsAction}
102154
*/
103155
function keyframeInterval(interval: number | string): KeyframeIntervalsAction {
104156
return new KeyframeIntervalsAction(interval);
@@ -112,7 +164,16 @@ function keyframeInterval(interval: number | string): KeyframeIntervalsAction {
112164
* You can use the streaming profiles methods of StreamingProfilesTrait to get a list of the available streaming
113165
* profiles or to create new custom profiles.
114166
* @param {string} profile The streaming profile.
115-
* @return {StreamingProfileAction}
167+
* @example
168+
* import {Cloudinary} from "@cloudinary/base/instance/Cloudinary";
169+
* import {fullHd} from "@cloudinary/base/qualifiers/streamingProfile";
170+
* import {streamingProfile} from '@cloudinary/base/actions/transcode'
171+
*
172+
* const yourCldInstance = new Cloudinary({cloud:{cloudName:'demo'}});
173+
* const video = yourCldInstance.video('dog');
174+
*
175+
* video.transcode( streamingProfile( fullHd() ) );
176+
* @return {Actions.Transcode.StreamingProfileAction}
116177
*/
117178
function streamingProfile(profile: string): StreamingProfileAction {
118179
return new StreamingProfileAction(profile);
@@ -123,7 +184,16 @@ function streamingProfile(profile: string): StreamingProfileAction {
123184
* @memberOf Actions.Transcode
124185
* @description Converts a video to animated image.
125186
* @param {string} animatedFormat The streaming profile.
126-
* @return {ToAnimatedAction}
187+
* @example
188+
* import {Cloudinary} from "@cloudinary/base/instance/Cloudinary";
189+
* import {gif} from '@cloudinary/base/qualifiers/animatedFormat'
190+
* import {toAnimated} from '@cloudinary/base/actions/transcode'
191+
*
192+
* const yourCldInstance = new Cloudinary({cloud:{cloudName:'demo'}});
193+
* const video = yourCldInstance.video('dog');
194+
*
195+
* video.transcode( toAnimated( gif() ) );
196+
* @return {Actions.Transcode.ToAnimatedAction}
127197
*/
128198
function toAnimated(animatedFormat: AnimatedFormatQualifierValue | string): ToAnimatedAction {
129199
return new ToAnimatedAction(animatedFormat);
@@ -134,7 +204,7 @@ function toAnimated(animatedFormat: AnimatedFormatQualifierValue | string): ToAn
134204
* @memberOf Actions.Transcode
135205
* @description Controls the video codec.
136206
* @param {Qualifiers.VideoCodec.VideoCodecType | Qualifiers.VideoCodec.AdvVideoCodecType} videoCodecType CodecType
137-
* @example // Setting the video codec
207+
* @example
138208
* import {Cloudinary} from "@cloudinary/base/instance/Cloudinary";
139209
* import {vp9} from '@cloudinary/base/qualifiers/videoCodec'
140210
* import {videoCodec} from '@cloudinary/base/actions/transcode'

src/actions/transcode/AudioCodecAction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {Qualifier} from "../../internal/qualifier/Qualifier";
77
* @description Controls the audio codec or removes the audio channel.
88
*
99
* <b>Learn more</b>: {@link https://cloudinary.com/documentation/audio_transformations#audio_frequency_control | Audio codec settings}
10+
* @see Visit {@link Actions.Transcode|Transcode} for an example
1011
*/
1112
class AudioCodecAction extends Action {
1213
constructor(codec: string) {

src/actions/transcode/AudioFrequencyAction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {Qualifier} from "../../internal/qualifier/Qualifier";
77
* @description Controls audio sample frequency.
88
*
99
* <b>Learn more</b>: {@link https://cloudinary.com/documentation/audio_transformations#audio_codec_settings | Audio frequency control}
10+
* @see Visit {@link Actions.Transcode|Transcode} for an example
1011
*/
1112
class AudioFrequencyAction extends Action {
1213
constructor(freq: string|number) {

src/actions/transcode/BitRateAction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {QualifierValue} from "../../internal/qualifier/QualifierValue";
88
* @description Defines the video bitrate in bits per second.
99
*
1010
* <b>Learn more</b>: {@link https://cloudinary.com/documentation/video_manipulation_and_delivery#bitrate_control | Bitrate control}
11+
* @see Visit {@link Actions.Transcode|Transcode} for an example
1112
*/
1213
class BitRateAction extends Action {
1314
private bitRate: string|number;

src/actions/transcode/FPSAction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {Qualifier} from "../../internal/qualifier/Qualifier";
99
* an expected FPS level (helps with sync to audio).
1010
*
1111
* <b>Learn more</b>: {@link https://cloudinary.com/documentation/video_transformation_reference#video_settings | Video settings}
12+
* @see Visit {@link Actions.Transcode|Transcode} for an example
1213
*/
1314
class FPSAction extends Action {
1415

src/actions/transcode/FPSRangeAction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {QualifierValue} from "../../internal/qualifier/QualifierValue";
1010
* an expected FPS level (helps with sync to audio).
1111
*
1212
* <b>Learn more</b>: {@link https://cloudinary.com/documentation/video_transformation_reference#video_settings | Video settings}
13+
* @see Visit {@link Actions.Transcode|Transcode} for an example
1314
*/
1415
class FPSRangeAction extends Action {
1516
private from: number;

src/actions/transcode/KeyframeIntervalsAction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {toFloatAsString} from "../../internal/utils/toFloatAsString";
66
* @extend {SDK.Action}
77
* @memberOf Actions.Transcode
88
* @description Controls the keyframe interval of the delivered video.
9+
* @see Visit {@link Actions.Transcode|Transcode} for an example
910
*/
1011
class KeyframeIntervalsAction extends Action {
1112
constructor(interval: number | string) {

src/actions/transcode/StreamingProfile.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {Qualifier} from "../../internal/qualifier/Qualifier";
77
* @description The predefined streaming profiles.
88
*
99
* <b>Learn more</b>: {@link https://cloudinary.com/documentation/video_manipulation_and_delivery#predefined_streaming_profiles | Predefined streaming profiles}
10+
* @see Visit {@link Actions.Transcode|Transcode} for an example
1011
*/
1112
class StreamingProfileAction extends Action {
1213
constructor(profile: string|number) {

src/actions/transcode/ToAnimatedAction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {animated} from "../../qualifiers/flag";
1010
* @description Converts a video to an animated webp or gif.
1111
* The resulting transformation includes format (f_format) and the animated flag (fl_animated).
1212
* The flag fl_awebp is added only when an animated webp is requested.
13+
* @see Visit {@link Actions.Transcode|Transcode} for an example
1314
*/
1415
class ToAnimatedAction extends Action {
1516
constructor(animatedFormat: AnimatedFormatQualifierValue | string) {

0 commit comments

Comments
 (0)