Skip to content

Commit

Permalink
Stream uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierapivideo authored Nov 9, 2021
1 parent b3790ce commit 997b01a
Show file tree
Hide file tree
Showing 49 changed files with 583 additions and 375 deletions.
2 changes: 1 addition & 1 deletion CoC.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,4 @@ For answers to common questions about this code of conduct, see the FAQ at
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations
[translations]: https://www.contributor-covenant.org/translations
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,6 @@ Method | HTTP request | Description
## API Models

- [AccessToken](doc/model/AccessToken.md)
- [Account](doc/model/Account.md)
- [AccountQuota](doc/model/AccountQuota.md)
- [AuthenticatePayload](doc/model/AuthenticatePayload.md)
- [BadRequest](doc/model/BadRequest.md)
- [BytesRange](doc/model/BytesRange.md)
Expand Down
12 changes: 6 additions & 6 deletions doc/api/RawStatisticsApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Method | HTTP request | Description
const client = new ApiVideoClient({ apiKey: "YOUR_API_TOKEN" });

const liveStreamId = 'vi4k0jvEUuaTdRAEjQ4Jfrgz'; // The unique identifier for the live stream you want to retrieve analytics for.
const period = '2019-01-01'; // Period must have one of the following formats: - For a day : \"2018-01-01\", - For a week: \"2018-W01\", - For a month: \"2018-01\" - For a year: \"2018\" For a range period: - Date range: \"2018-01-01/2018-01-15\"
const period = '2019-01-01'; // Period must have one of the following formats: - For a day : \"2018-01-01\", - For a week: \"2018-W01\", - For a month: \"2018-01\" - For a year: \"2018\" For a range period: - Date range: \"2018-01-01/2018-01-15\"
const currentPage = '2'; // Choose the number of search results to return per page. Minimum value: 1
const pageSize = '30'; // Results per page. Allowed values 1-100, default is 25.

Expand All @@ -38,7 +38,7 @@ Method | HTTP request | Description
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**liveStreamId** | **string**| The unique identifier for the live stream you want to retrieve analytics for. | [default to undefined]
**period** | **string**| Period must have one of the following formats: - For a day : \"2018-01-01\", - For a week: \"2018-W01\", - For a month: \"2018-01\" - For a year: \"2018\" For a range period: - Date range: \"2018-01-01/2018-01-15\" | [optional] [default to undefined]
**period** | **string**| Period must have one of the following formats: - For a day : \"2018-01-01\", - For a week: \"2018-W01\", - For a month: \"2018-01\" - For a year: \"2018\" For a range period: - Date range: \"2018-01-01/2018-01-15\" | [optional] [default to undefined]
**currentPage** | **number**| Choose the number of search results to return per page. Minimum value: 1 | [optional] [default to 1]
**pageSize** | **number**| Results per page. Allowed values 1-100, default is 25. | [optional] [default to 25]

Expand Down Expand Up @@ -112,8 +112,8 @@ Name | Type | Description | Notes
const client = new ApiVideoClient({ apiKey: "YOUR_API_TOKEN" });

const videoId = 'vi4k0jvEUuaTdRAEjQ4Prklg'; // The unique identifier for the video you want to retrieve session information for.
const period = 'period_example'; // Period must have one of the following formats: - For a day : 2018-01-01, - For a week: 2018-W01, - For a month: 2018-01 - For a year: 2018 For a range period: - Date range: 2018-01-01/2018-01-15
const metadata = 'metadata[Author]=John Doe&metadata[Format]=Tutorial'; // Metadata and Dynamic Metadata filter. Send an array of key value pairs you want to filter sessios with.
const period = 'period_example'; // Period must have one of the following formats: - For a day : 2018-01-01, - For a week: 2018-W01, - For a month: 2018-01 - For a year: 2018 For a range period: - Date range: 2018-01-01/2018-01-15
const metadata = 'metadata[Author]=John Doe&metadata[Format]=Tutorial'; // Metadata and [Dynamic Metadata](https://api.video/blog/endpoints/dynamic-metadata) filter. Send an array of key value pairs you want to filter sessios with.
const currentPage = '2'; // Choose the number of search results to return per page. Minimum value: 1
const pageSize = '30'; // Results per page. Allowed values 1-100, default is 25.

Expand All @@ -131,8 +131,8 @@ Name | Type | Description | Notes
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**videoId** | **string**| The unique identifier for the video you want to retrieve session information for. | [default to undefined]
**period** | **string**| Period must have one of the following formats: - For a day : 2018-01-01, - For a week: 2018-W01, - For a month: 2018-01 - For a year: 2018 For a range period: - Date range: 2018-01-01/2018-01-15 | [optional] [default to undefined]
**metadata** | **{ [key: string]: string; }**| Metadata and Dynamic Metadata filter. Send an array of key value pairs you want to filter sessios with. | [optional]
**period** | **string**| Period must have one of the following formats: - For a day : 2018-01-01, - For a week: 2018-W01, - For a month: 2018-01 - For a year: 2018 For a range period: - Date range: 2018-01-01/2018-01-15 | [optional] [default to undefined]
**metadata** | **{ [key: string]: string; }**| Metadata and [Dynamic Metadata](https://api.video/blog/endpoints/dynamic-metadata) filter. Send an array of key value pairs you want to filter sessios with. | [optional]
**currentPage** | **number**| Choose the number of search results to return per page. Minimum value: 1 | [optional] [default to 1]
**pageSize** | **number**| Results per page. Allowed values 1-100, default is 25. | [optional] [default to 25]

Expand Down
2 changes: 1 addition & 1 deletion doc/api/UploadTokensApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ Name | Type | Description | Notes
const client = new ApiVideoClient({ apiKey: "YOUR_API_TOKEN" });

const tokenCreationPayload = {
ttl: 56, // Time in seconds that the token will be active. A value of 0 means that the token has no expiration date. The default is to have no expiration.
ttl: 56, // Time in seconds that the token will be active. A value of 0 means that the token has no exipration date. The default is to have no expiration.
};

// UploadToken
Expand Down
84 changes: 69 additions & 15 deletions doc/api/VideosApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Name | Type | Description | Notes

const title = 'My Video.mp4'; // The title of a specific video you want to find. The search will match exactly to what term you provide and return any videos that contain the same term as part of their titles.
const tags = '["captions", "dialogue"]'; // A tag is a category you create and apply to videos. You can search for videos with particular tags by listing one or more here. Only videos that have all the tags you list will be returned.
const metadata = 'metadata[Author]=John Doe&metadata[Format]=Tutorial'; // Videos can be tagged with metadata tags in key:value pairs. You can search for videos with specific key value pairs using this parameter.
const metadata = 'metadata[Author]=John Doe&metadata[Format]=Tutorial'; // Videos can be tagged with metadata tags in key:value pairs. You can search for videos with specific key value pairs using this parameter. [Dynamic Metadata](https://api.video/blog/endpoints/dynamic-metadata) allows you to define a key that allows any value pair.
const description = 'New Zealand'; // If you described a video with a term or sentence, you can add it here to return videos containing this string.
const liveStreamId = 'li400mYKSgQ6xs7taUeSaEKr'; // If you know the ID for a live stream, you can retrieve the stream by adding the ID for it here.
const sortBy = 'publishedAt'; // Allowed: publishedAt, title. You can search by the time videos were published at, or by title.
Expand All @@ -174,7 +174,7 @@ Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**title** | **string**| The title of a specific video you want to find. The search will match exactly to what term you provide and return any videos that contain the same term as part of their titles. | [optional] [default to undefined]
**tags** | **Array<string>**| A tag is a category you create and apply to videos. You can search for videos with particular tags by listing one or more here. Only videos that have all the tags you list will be returned. | [optional]
**metadata** | **{ [key: string]: string; }**| Videos can be tagged with metadata tags in key:value pairs. You can search for videos with specific key value pairs using this parameter. | [optional]
**metadata** | **{ [key: string]: string; }**| Videos can be tagged with metadata tags in key:value pairs. You can search for videos with specific key value pairs using this parameter. [Dynamic Metadata](https://api.video/blog/endpoints/dynamic-metadata) allows you to define a key that allows any value pair. | [optional]
**description** | **string**| If you described a video with a term or sentence, you can add it here to return videos containing this string. | [optional] [default to undefined]
**liveStreamId** | **string**| If you know the ID for a live stream, you can retrieve the stream by adding the ID for it here. | [optional] [default to undefined]
**sortBy** | **string**| Allowed: publishedAt, title. You can search by the time videos were published at, or by title. | [optional] [default to undefined]
Expand Down Expand Up @@ -211,11 +211,11 @@ Name | Type | Description | Notes
playerId: "pl4k0jvEUuaTdRAEjQ4Jfrgz", // The unique ID for the player you want to associate with your video.
title: "title_example", // The title you want to use for your video.
description: "A film about good books.", // A brief description of the video.
_public: true, // Whether the video is publicly available or not. False means it is set to private.
_public: true, // Whether the video is publicly available or not. False means it is set to private. Default is true. Tutorials on [private videos](https://api.video/blog/endpoints/private-videos).
panoramic: false, // Whether the video is a 360 degree or immersive video.
mp4Support: true, // Whether the player supports the mp4 format.
tags: ["maths", "string theory", "video"], // A list of terms or words you want to tag the video with. Make sure the list includes all the tags you want as whatever you send in this list will overwrite the existing list for the video.
metadata: null, // A list (array) of dictionaries where each dictionary contains a key value pair that describes the video. As with tags, you must send the complete list of metadata you want as whatever you send here will overwrite the existing metadata for the video.
metadata: null, // A list (array) of dictionaries where each dictionary contains a key value pair that describes the video. As with tags, you must send the complete list of metadata you want as whatever you send here will overwrite the existing metadata for the video. [Dynamic Metadata](https://api.video/blog/endpoints/dynamic-metadata) allows you to define a key that allows any value pair.
};

// Video
Expand Down Expand Up @@ -261,7 +261,7 @@ Name | Type | Description | Notes

const videoId = 'vi4k0jvEUuaTdRAEjQ4Jfrgz'; // Unique identifier of the video you want to add a thumbnail to, where you use a section of your video as the thumbnail.
const videoThumbnailPickPayload = {
timecode: "timecode_example", // Frame in video to be used as a placeholder before the video plays. Example: '\"00:01:00.000\" for 1 minute into the video.' Valid Patterns: \"hh:mm:ss.ms\" \"hh:mm:ss:frameNumber\" \"124\" (integer value is reported as seconds) If selection is out of range, \"00:00:00.00\" will be chosen.
timecode: "timecode_example", // Frame in video to be used as a placeholder before the video plays. Example: '\"00:01:00.000\" for 1 minute into the video.' Valid Patterns: \"hh:mm:ss.ms\" \"hh:mm:ss:frameNumber\" \"124\" (integer value is reported as seconds) If selection is out of range, \"00:00:00.00\" will be chosen.
};

// Video
Expand Down Expand Up @@ -326,11 +326,37 @@ Name | Type | Description | Notes

### Upload chunks

Large files are broken into chunks for upload. You can control the size of the chunks using the `setUploadChunkSize()` of method of `ApiVideoClient` before uploading:
Large files are broken into chunks for upload. You can control the size of the chunks using the `chunkSize` parameter when you instanciate the ApiVideoClient:

```java
apiVideoClient.setUploadChunkSize(50*1024*1024); // use 50MB chunks
apiVideoClient.videos().uploadWithUploadToken(token, file);
```js
const client = new ApiVideoClient({
apiKey: "YOUR_API_TOKEN",
chunkSize: 50 * 1024 * 1024, // 50mb chunks
});
```

### Progressive uploads

Progressive uploads make it possible to upload a video source "progressively," i.e., before knowing the total size of the video. This is done by sending chunks of the video source file sequentially.
The last chunk is sent by calling a different method, so api.video knows that it is time to reassemble the different chunks that were received.

```js
(async () => {
try {
const client = new ApiVideoClient();
const token = 'to1tcmSFHeYY5KzyhOqVKMKb'; // The unique identifier for the token you want to use to upload a video.

const uploadSession = client.createUploadWithUploadTokenProgressiveSession(token);

await uploadSession.uploadPart('test/data/10m.mp4.part.a');
await uploadSession.uploadPart('test/data/10m.mp4.part.b');
const res = await uploadSession.uploadLastPart('test/data/10m.mp4.part.c'); // Video

console.log(result);
} catch (e) {
console.error(e);
}
})();
```

### Return type
Expand Down Expand Up @@ -361,12 +387,12 @@ apiVideoClient.videos().uploadWithUploadToken(token, file);
title: "Maths video", // The title of your new video.
description: "A video about string theory.", // A brief description of your video.
source: "https://www.myvideo.url.com/video.mp4", // If you add a video already on the web, this is where you enter the url for the video.
_public: true, // Whether your video can be viewed by everyone, or requires authentication to see it. A setting of false will require a unique token for each view.
_public: true, // Whether your video can be viewed by everyone, or requires authentication to see it. A setting of false will require a unique token for each view. Default is true. Tutorials on [private videos](https://api.video/blog/endpoints/private-videos).
panoramic: false, // Indicates if your video is a 360/immersive video.
mp4Support: true, // Enables mp4 version in addition to streamed version.
playerId: "pl45KFKdlddgk654dspkze", // The unique identification number for your video player.
tags: ["maths", "string theory", "video"], // A list of tags you want to use to describe your video.
metadata: [{"key": "Author", "value": "John Doe"}], // A list of key value pairs that you use to provide metadata for your video. These pairs can be made dynamic, allowing you to segment your audience. You can also just use the pairs as another way to tag and categorize your videos.
metadata: [{"key": "Author", "value": "John Doe"}], // A list of key value pairs that you use to provide metadata for your video. These pairs can be made dynamic, allowing you to segment your audience. Read more on [dynamic metadata](https://api.video/blog/endpoints/dynamic-metadata).
};

// Video
Expand Down Expand Up @@ -431,11 +457,39 @@ Name | Type | Description | Notes

### Upload chunks

Large files are broken into chunks for upload. You can control the size of the chunks using the `setUploadChunkSize()` of method of `ApiVideoClient` before uploading:
Large files are broken into chunks for upload. You can control the size of the chunks using the `chunkSize` parameter when you instanciate the ApiVideoClient:

```js
const client = new ApiVideoClient({
apiKey: "YOUR_API_TOKEN",
chunkSize: 50 * 1024 * 1024, // 50mb chunks
});
```

### Progressive uploads

Progressive uploads make it possible to upload a video source "progressively," i.e., before knowing the total size of the video. This is done by sending chunks of the video source file sequentially.
The last chunk is sent by calling a different method, so api.video knows that it is time to reassemble the different chunks that were received.

```js
(async () => {
try {

const client = new ApiVideoClient({ apiKey: "YOUR_API_TOKEN" });

const videoId = 'vi4k0jvEUuaTdRAEjQ4Jfrgz'; // Enter the videoId you want to use to upload your video.

const uploadSession = client.createUploadProgressiveSession(videoId);

```java
apiVideoClient.setUploadChunkSize(50*1024*1024); // use 50MB chunks
apiVideoClient.videos().upload(videoId, file);
await uploadSession.uploadPart('test/data/10m.mp4.part.a');
await uploadSession.uploadPart('test/data/10m.mp4.part.b');
const res = await uploadSession.uploadLastPart('test/data/10m.mp4.part.c'); // Video

console.log(result);
} catch (e) {
console.error(e);
}
})();
```

### Return type
Expand Down
13 changes: 0 additions & 13 deletions doc/model/Account.md

This file was deleted.

14 changes: 0 additions & 14 deletions doc/model/AccountQuota.md

This file was deleted.

2 changes: 1 addition & 1 deletion doc/model/TokenCreationPayload.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**ttl** | **number** | Time in seconds that the token will be active. A value of 0 means that the token has no expiration date. The default is to have no expiration. | [optional]
**ttl** | **number** | Time in seconds that the token will be active. A value of 0 means that the token has no exipration date. The default is to have no expiration. | [optional]



Loading

0 comments on commit 997b01a

Please sign in to comment.