cenc


Namecenc JSON
Version 0.2.0 PyPI version JSON
download
home_page
Summary
upload_time2022-12-02 18:45:42
maintainer
docs_urlNone
authorAziz Berkay Yesilyurt
requires_python>=3.7,<4.0
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Start an encoding task with passing the full ffmpeg command to the `cenc` command.

A trivial example that prints the version of ffmpeg on our system:

```bash
cenc ffmpeg --help
```

A more complex example that resizes a video file hosted on a remote server:

```bash
cenc ffmpeg -i 'https://storage.googleapis.com/kapan_public_videos/SampleVideo_1280x720_1mb%20(1).mp4' -vf scale=320:240 output.mp4
```

Task ID is returned immediately after the task is created. 
You can use the task ID to check the status of the task.
The logs will be printed to the standard output until the task is finished.

You can download the outputs of the task, after the task is finished.
The url for the each output file will be printed to the console, such as:

```
{
  "id": "b6c0d5607f224dc3b646068710d2e08a",
  "output.mp4": "https://storage.googleapis.com/store/tmp/ffmpeg/b6c0d5607f224dc3b646068710d2e08a/output.mp4",
  "returncode": "0",
  "status": "done"
}
```


## Using the API directly

The API is available at `https://ffmpeg-kopg2w5bka-ez.a.run.app`.
You can start a task by sending a POST request to the `/ffmpeg` endpoint with the full ffmpeg command in the params.

```python
endpoint = "https://ffmpeg-kopg2w5bka-ez.a.run.app"
command = "ffmpeg -i 'https://storage.googleapis.com/kapan_public_videos/SampleVideo_1280x720_1mb%20(1).mp4' -vf scale=320:240 output.mp4"
response = requests.post(endpoint, params={"command": command})
task_id = response.json()["id"]
```

You can check the status of the task by sending a GET request to the `/ffmpeg/<task_id>` endpoint.

```python
while True:
    time.sleep(2)
    response = requests.get(f"{endpoint}/ffmpeg/{task_id}")
    if response.status_code != 200:
        # Task has not been started processing yet
        continue
    
    results = response.json()

    if results.get("returncode"):
        # Task has finished processing
        print(results)
        break
```
            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "cenc",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Aziz Berkay Yesilyurt",
    "author_email": "abyesilyurt@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/83/6a/c79bb356adc9fb9861c137e561402958f30403330a663afe3e2057a89924/cenc-0.2.0.tar.gz",
    "platform": null,
    "description": "Start an encoding task with passing the full ffmpeg command to the `cenc` command.\n\nA trivial example that prints the version of ffmpeg on our system:\n\n```bash\ncenc ffmpeg --help\n```\n\nA more complex example that resizes a video file hosted on a remote server:\n\n```bash\ncenc ffmpeg -i 'https://storage.googleapis.com/kapan_public_videos/SampleVideo_1280x720_1mb%20(1).mp4' -vf scale=320:240 output.mp4\n```\n\nTask ID is returned immediately after the task is created. \nYou can use the task ID to check the status of the task.\nThe logs will be printed to the standard output until the task is finished.\n\nYou can download the outputs of the task, after the task is finished.\nThe url for the each output file will be printed to the console, such as:\n\n```\n{\n  \"id\": \"b6c0d5607f224dc3b646068710d2e08a\",\n  \"output.mp4\": \"https://storage.googleapis.com/store/tmp/ffmpeg/b6c0d5607f224dc3b646068710d2e08a/output.mp4\",\n  \"returncode\": \"0\",\n  \"status\": \"done\"\n}\n```\n\n\n## Using the API directly\n\nThe API is available at `https://ffmpeg-kopg2w5bka-ez.a.run.app`.\nYou can start a task by sending a POST request to the `/ffmpeg` endpoint with the full ffmpeg command in the params.\n\n```python\nendpoint = \"https://ffmpeg-kopg2w5bka-ez.a.run.app\"\ncommand = \"ffmpeg -i 'https://storage.googleapis.com/kapan_public_videos/SampleVideo_1280x720_1mb%20(1).mp4' -vf scale=320:240 output.mp4\"\nresponse = requests.post(endpoint, params={\"command\": command})\ntask_id = response.json()[\"id\"]\n```\n\nYou can check the status of the task by sending a GET request to the `/ffmpeg/<task_id>` endpoint.\n\n```python\nwhile True:\n    time.sleep(2)\n    response = requests.get(f\"{endpoint}/ffmpeg/{task_id}\")\n    if response.status_code != 200:\n        # Task has not been started processing yet\n        continue\n    \n    results = response.json()\n\n    if results.get(\"returncode\"):\n        # Task has finished processing\n        print(results)\n        break\n```",
    "bugtrack_url": null,
    "license": "",
    "summary": "",
    "version": "0.2.0",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "7a1fed7ce2e6d4dc87cf2554741bd97a",
                "sha256": "526aeb92a9aafb62541deeb27437aed83ec7a5fe57a5782064bc6c93471e21fc"
            },
            "downloads": -1,
            "filename": "cenc-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7a1fed7ce2e6d4dc87cf2554741bd97a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 2988,
            "upload_time": "2022-12-02T18:45:41",
            "upload_time_iso_8601": "2022-12-02T18:45:41.242715Z",
            "url": "https://files.pythonhosted.org/packages/db/50/3d57b4489d7204c458683168553560a77791c7fd4ae32ae2294351506ab1/cenc-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "9627267336ff7ca6952da06d5f820304",
                "sha256": "6f60cf74467f3a1edb1394a12b6ab7a61995e09f38f1afb5d8e5eb71270f84c4"
            },
            "downloads": -1,
            "filename": "cenc-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9627267336ff7ca6952da06d5f820304",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 2718,
            "upload_time": "2022-12-02T18:45:42",
            "upload_time_iso_8601": "2022-12-02T18:45:42.729507Z",
            "url": "https://files.pythonhosted.org/packages/83/6a/c79bb356adc9fb9861c137e561402958f30403330a663afe3e2057a89924/cenc-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-02 18:45:42",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "cenc"
}
        
Elapsed time: 0.01566s