batch-compress-video-cli


Namebatch-compress-video-cli JSON
Version 0.2.1 PyPI version JSON
download
home_page
SummaryCompress raw video from action cameras from directory or path using ffmpeg, with a simple cli to automate the recurring commands.
upload_time2023-01-19 05:52:56
maintainer
docs_urlNone
author
requires_python
licenseMIT License Copyright (c) [2023] [Rocky Li] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords ffmpeg compress video batch cli
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## Batch Video Compress cli

`pip install batch-compress-video-cli`

This is a cli tool that batch compress all videos in a folder and process in/move to a separate folder if needed. Save the need to craft `ffmpeg` commands, perfect for compressing and storing unused action camera/drone videos.


## Usage

Prerequisite: `ffmpeg` must be installed and be in `PATH`.

```
$ batch_compress_video
```

this will compress all `.mp4` file in the current directory that does not have `compressed` in its name. It does that with default values of `crf=23, preset=slower`.

```
$ batch_compress_video -f $SOURCE_DIR -t $DEST_DIR -p $PROC_DIR -d
```

this will find all `.mp4` file in `$SOURCE_DIR`, individually move them to `$PROC_DIR`, compress it there using the default values, and then move them to `$DEST_DIR`. This is really helpful when the source and destination directories are HDD storage and conflict with read/write operation of `ffmpeg`. The `-d` flag signifies the original videos are to be deleted.

```
$ batch_compress_video --crf 25 --scale 0.5 --preset fast
```

This will compress video with a quality of `crf=25`, reduce the width and height to 50%, and use `fast` preset.

A full example (output when it is running):

```
$ batch_compress_video --source "/Volumes/SSDS1/footage/gopro/PADDLE_2022_12" --process-dir "." --destination "/Volumes/SSDS1/footage/gopro/PADDLE_2022_12" --crf 25 --preset "medium" --scale 0.4
will compress 18 videos, they are ['GX010142.MP4', 'GX010156.MP4', 'GX010157.MP4', 'GX010155.MP4', 'GX010141.MP4', 'GX010140.MP4', 'GX010154.MP4', 'GX010150.MP4', 'GX010144.MP4', 'GX010145.MP4', 'GX010147.MP4', 'GX010153.MP4', 'GX010152.MP4', 'GX010146.MP4', 'GX010148.MP4', 'GX010149.MP4', 'GX010159.MP4', 'GX010158.MP4']
======== PROCESSING VIDEO: GX010142.MP4 ========
SIZE: 267 MB; DURATION: 48.0s; FRAME_RATE: 30000/1001; RESOLUTION: 1920x1080
copying /Volumes/SSDS1/footage/gopro/PADDLE_2022_12/GX010142.MP4 to ./GX010142.MP4 for processing
compressing video ...
frame= 1438 fps=105 q=-1.0 Lsize=    4974kB time=00:00:47.95 bitrate= 849.6kbits/s speed=3.49x
copying ./GX010142_compressed.mp4 to destination /Volumes/SSDS1/footage/gopro/PADDLE_2022_12/GX010142_compressed.mp4
Video compressed to /Volumes/SSDS1/footage/gopro/PADDLE_2022_12/GX010142_compressed.mp4
SIZE: 5093 KB; DURATION: 48.0s; FRAME_RATE: 30000/1001; RESOLUTION: 768x432

======== PROCESSING VIDEO: GX010156.MP4 ========
SIZE: 351 MB; DURATION: 62.9s; FRAME_RATE: 30000/1001; RESOLUTION: 1920x1080
copying /Volumes/SSDS1/footage/gopro/PADDLE_2022_12/GX010156.MP4 to ./GX010156.MP4 for processing
compressing video ...
frame= 1728 fps=101 q=31.0 size=    4096kB time=00:00:57.87 bitrate= 579.8kbits/s speed=3.37x
```

The progress bar is displayed for each video as it is converting. After it is converted, the newly compressed video stats will be displayed. In this case, extreme compression (lossy, scaled down) resulted in video that are less than 2% the size of the original.

Maybe in 2040 GANs, powerful graphic cards and TB sized storage are cheap and plentiful, and we restore our videos to its full (and maybe some extra) glory.

## Rationale

After racking up 100s of GBs of videos in a couple hours of GoPro and DJI videos, I realized that:

1. I don't have enough space to store all of them.
2. The videos are very poorly compressed, if at all. Compressing at a level without reducing quality will yield significantly smaller video. Compressing at higher level will yield very small video compared to original..
3. I don't want to individually use FFMPEG cli commands to compress all of those videos, I want a simple command that can compress all of them.
4. ffmpeg often break down on HDDs due to disk constraints.

This is a tool written to solve all of these problems.


## Developing

`pytest` and `coverage` are used for testing. After cloning, you can invoke them with `make test`.

CLI can be updated with `make install`

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "batch-compress-video-cli",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "ffmpeg,compress,video,batch,cli",
    "author": "",
    "author_email": "Rocky Li <aperocky@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/49/b8/8e1b6b883769ec84bcc748c9c9e76fe604f1a5a278026040b89b0de4e6f9/batch-compress-video-cli-0.2.1.tar.gz",
    "platform": null,
    "description": "## Batch Video Compress cli\n\n`pip install batch-compress-video-cli`\n\nThis is a cli tool that batch compress all videos in a folder and process in/move to a separate folder if needed. Save the need to craft `ffmpeg` commands, perfect for compressing and storing unused action camera/drone videos.\n\n\n## Usage\n\nPrerequisite: `ffmpeg` must be installed and be in `PATH`.\n\n```\n$ batch_compress_video\n```\n\nthis will compress all `.mp4` file in the current directory that does not have `compressed` in its name. It does that with default values of `crf=23, preset=slower`.\n\n```\n$ batch_compress_video -f $SOURCE_DIR -t $DEST_DIR -p $PROC_DIR -d\n```\n\nthis will find all `.mp4` file in `$SOURCE_DIR`, individually move them to `$PROC_DIR`, compress it there using the default values, and then move them to `$DEST_DIR`. This is really helpful when the source and destination directories are HDD storage and conflict with read/write operation of `ffmpeg`. The `-d` flag signifies the original videos are to be deleted.\n\n```\n$ batch_compress_video --crf 25 --scale 0.5 --preset fast\n```\n\nThis will compress video with a quality of `crf=25`, reduce the width and height to 50%, and use `fast` preset.\n\nA full example (output when it is running):\n\n```\n$ batch_compress_video --source \"/Volumes/SSDS1/footage/gopro/PADDLE_2022_12\" --process-dir \".\" --destination \"/Volumes/SSDS1/footage/gopro/PADDLE_2022_12\" --crf 25 --preset \"medium\" --scale 0.4\nwill compress 18 videos, they are ['GX010142.MP4', 'GX010156.MP4', 'GX010157.MP4', 'GX010155.MP4', 'GX010141.MP4', 'GX010140.MP4', 'GX010154.MP4', 'GX010150.MP4', 'GX010144.MP4', 'GX010145.MP4', 'GX010147.MP4', 'GX010153.MP4', 'GX010152.MP4', 'GX010146.MP4', 'GX010148.MP4', 'GX010149.MP4', 'GX010159.MP4', 'GX010158.MP4']\n======== PROCESSING VIDEO: GX010142.MP4 ========\nSIZE: 267 MB; DURATION: 48.0s; FRAME_RATE: 30000/1001; RESOLUTION: 1920x1080\ncopying /Volumes/SSDS1/footage/gopro/PADDLE_2022_12/GX010142.MP4 to ./GX010142.MP4 for processing\ncompressing video ...\nframe= 1438 fps=105 q=-1.0 Lsize=    4974kB time=00:00:47.95 bitrate= 849.6kbits/s speed=3.49x\ncopying ./GX010142_compressed.mp4 to destination /Volumes/SSDS1/footage/gopro/PADDLE_2022_12/GX010142_compressed.mp4\nVideo compressed to /Volumes/SSDS1/footage/gopro/PADDLE_2022_12/GX010142_compressed.mp4\nSIZE: 5093 KB; DURATION: 48.0s; FRAME_RATE: 30000/1001; RESOLUTION: 768x432\n\n======== PROCESSING VIDEO: GX010156.MP4 ========\nSIZE: 351 MB; DURATION: 62.9s; FRAME_RATE: 30000/1001; RESOLUTION: 1920x1080\ncopying /Volumes/SSDS1/footage/gopro/PADDLE_2022_12/GX010156.MP4 to ./GX010156.MP4 for processing\ncompressing video ...\nframe= 1728 fps=101 q=31.0 size=    4096kB time=00:00:57.87 bitrate= 579.8kbits/s speed=3.37x\n```\n\nThe progress bar is displayed for each video as it is converting. After it is converted, the newly compressed video stats will be displayed. In this case, extreme compression (lossy, scaled down) resulted in video that are less than 2% the size of the original.\n\nMaybe in 2040 GANs, powerful graphic cards and TB sized storage are cheap and plentiful, and we restore our videos to its full (and maybe some extra) glory.\n\n## Rationale\n\nAfter racking up 100s of GBs of videos in a couple hours of GoPro and DJI videos, I realized that:\n\n1. I don't have enough space to store all of them.\n2. The videos are very poorly compressed, if at all. Compressing at a level without reducing quality will yield significantly smaller video. Compressing at higher level will yield very small video compared to original..\n3. I don't want to individually use FFMPEG cli commands to compress all of those videos, I want a simple command that can compress all of them.\n4. ffmpeg often break down on HDDs due to disk constraints.\n\nThis is a tool written to solve all of these problems.\n\n\n## Developing\n\n`pytest` and `coverage` are used for testing. After cloning, you can invoke them with `make test`.\n\nCLI can be updated with `make install`\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) [2023] [Rocky Li]  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  ",
    "summary": "Compress raw video from action cameras from directory or path using ffmpeg, with a simple cli to automate the recurring commands.",
    "version": "0.2.1",
    "split_keywords": [
        "ffmpeg",
        "compress",
        "video",
        "batch",
        "cli"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4aa3ba29fb3df3d5f2da26cf1335ad785ef6a3608a51ea54dc2cd425cef82036",
                "md5": "75a43853d56ec6fec553ef8ed20cf701",
                "sha256": "aca54cdfecb8421cf6517e121c059092b4d35c36378f4c15fdc2f95da4e4ae37"
            },
            "downloads": -1,
            "filename": "batch_compress_video_cli-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "75a43853d56ec6fec553ef8ed20cf701",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7620,
            "upload_time": "2023-01-19T05:52:54",
            "upload_time_iso_8601": "2023-01-19T05:52:54.990235Z",
            "url": "https://files.pythonhosted.org/packages/4a/a3/ba29fb3df3d5f2da26cf1335ad785ef6a3608a51ea54dc2cd425cef82036/batch_compress_video_cli-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "49b88e1b6b883769ec84bcc748c9c9e76fe604f1a5a278026040b89b0de4e6f9",
                "md5": "1d3d87278801c8ffbf51f334a1d65449",
                "sha256": "500a304b293c93a8e6cdf9ed977bc3dd3baef0b350fe33dc47715cc7d0b914e8"
            },
            "downloads": -1,
            "filename": "batch-compress-video-cli-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "1d3d87278801c8ffbf51f334a1d65449",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6431,
            "upload_time": "2023-01-19T05:52:56",
            "upload_time_iso_8601": "2023-01-19T05:52:56.778839Z",
            "url": "https://files.pythonhosted.org/packages/49/b8/8e1b6b883769ec84bcc748c9c9e76fe604f1a5a278026040b89b0de4e6f9/batch-compress-video-cli-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-19 05:52:56",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "batch-compress-video-cli"
}
        
Elapsed time: 0.03057s