Skip to content

Commit

Permalink
Merge remote-tracking branch 'github/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Thanh Nguyen committed Nov 26, 2019
2 parents fbeb9af + 799770d commit e9c4c8e
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 3 deletions.
122 changes: 122 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,128 @@ For ready to use installation, please refer to the README file at: https://githu
Once server is started you can access a swagger via http://0.0.0.0:5050/swagger/


### Endpoints

##### List all projects
```bash
curl -X GET http://0.0.0.0:5050/projects/
```

##### Create a project
```bash
curl -X POST http://0.0.0.0:5050/projects/ \
-F file=@/path/to/your/video/SampleVideo.mp4
```

##### Retrieve project details
```bash
curl -X GET http://0.0.0.0:5050/projects/5d7b841764c598157d53ef4a
```
where `5d7b841764c598157d53ef4a` is project's `_id`.

##### Delete a project
```bash
curl -X DELETE http://0.0.0.0:5050/projects/5d7b841764c598157d53ef4a
```
where `5d7b841764c598157d53ef4a` is project's `_id`.


##### Duplicate a project
```bash
curl -X POST http://0.0.0.0:5050/projects/5d7b841764c598157d53ef4a/duplicate
```
where `5d7b841764c598157d53ef4a` is project's `_id` you want to make a duplicate of.

##### Edit

:warning: It's not permitted to edit an original project (version 1), instead use a duplicated project.

##### Trim
```bash
curl -X PUT \
http://0.0.0.0:5050/projects/5d7a35a04be797ba845e7871 \
-d '{
"trim": "2,5"
}'
```
where `2` and `5` are seconds.

##### Rotate
```bash
curl -X PUT \
http://0.0.0.0:5050/projects/5d7a35a04be797ba845e7871 \
-d '{
"rotate": 90
}'
```
where `90` is rotate degree.

##### Scale
```bash
curl -X PUT \
http://0.0.0.0:5050/projects/5d7a35a04be797ba845e7871 \
-d '{
"scale": 480
}'
```
where `480` is width you want to scale video to.

##### Crop
```bash
curl -X PUT \
http://0.0.0.0:5050/projects/5d7a35a04be797ba845e7871 \
-d '{
"crop": "0,0,180,320"
}'
```
where `width` and `height` are respectively width and height of capturing area,
and `x` and `y` are coordinates of top-left point of capturing area.
https://ffmpeg.org/ffmpeg-filters.html#crop

##### Capture timeline thumbnails
```bash
curl -X GET 'http://0.0.0.0:5050/projects/5d7b90ed64c598157d53ef5d/thumbnails?type=timeline&amount=5'
```

##### Capture a thumbnail for a preview at a certain position
```bash
curl -X GET 'http://0.0.0.0:5050/projects/5d7b98f52fac91d2e1ad7512/thumbnails?type=preview&position=5'
```
where `position` is a position in the video (seconds) used to capture a thumbnail.

You can also specify optional `crop` param if you want to crop a preview thumbnail, just add
`crop="0,0,180,320"`.
Example:
```bash
curl -X GET \
'http://0.0.0.0:5050/projects/5d7b98f52fac91d2e1ad7512/thumbnails?type=preview&position=5&crop={%0A%09%09%22height%22:%20180,%0A%09%09%22width%22:%20320,%0A%09%09%22x%22:%200,%0A%09%09%22y%22:%200%0A%09}'
```

##### Upload a custom image file for a preview thumbnail
```bash
curl -X POST \
http://0.0.0.0:5050/projects/5d7b98f52fac91d2e1ad7512/thumbnails \
-F file=@/path/to/your/video/tom_and_jerry.jpg
```

##### Get timeline thumbnail file
```bash
curl -X GET http://0.0.0.0:5050/projects/5d7b98f52fac91d2e1ad7512/raw/thumbnails/timeline/3
```
where `3` is a thumbnail index

##### Get preview thumbnail file
```bash
curl -X GET http://0.0.0.0:5050/projects/5d7b98f52fac91d2e1ad7512/raw/thumbnails/preview
```

##### Get video file
```bash
curl -X GET http://0.0.0.0:5050/projects/5d7b98f52fac91d2e1ad7512/raw/video
```
NOTE: If `HTTP_RANGE` header is specified - chunked video will be streamed, else full file.


## Authors
* **Loi Tran**
* **Oleg Pshenichniy**
Expand Down
2 changes: 1 addition & 1 deletion src/videoserver/lib/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ def configure_logging(file_path):

logging.config.dictConfig(logging_dict)
except Exception:
logger.warn('Cannot load logging config. File: %s', file_path)
logger.warning('Cannot load logging config. File: %s', file_path)
4 changes: 2 additions & 2 deletions tests/storage/test_file_system_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ def test_fs_storage_put_already_exist(test_app, filestreams):

project_id = 'project_one'
with test_app.app_context():
with pytest.raises(Exception):
with pytest.raises(ValueError, match="Argument 'project_id' is required when 'asset_type' is 'project'"):
storage_id = storage.put(
content=mp4_stream,
filename='sample_video.mp4',
asset_type='project'
)
with pytest.raises(Exception):
with pytest.raises(ValueError, match="Argument 'storage_id' is required when 'asset_type' is not 'project'"):
storage.put(
content=jpg_stream_0,
filename='sample_image.jpg',
Expand Down

0 comments on commit e9c4c8e

Please sign in to comment.