easy-media-utils


Nameeasy-media-utils JSON
Version 0.1.5 PyPI version JSON
download
home_pagehttps://github.com/aceliuchanghong/easy-media-utils.git
SummaryA collection of Python utilities for handling media files.
upload_time2024-01-08 06:37:30
maintainer
docs_urlNone
authorSisconsavior
requires_python>=3.6
licenseLICENSE
keywords media handling image audio video conversion editing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## image-utils

When I am dealing pics,mp3,mp4. I always want a media utils to help me work, that's why this project start

### mp4处理

* 转png/jpg等
* 转mp3
* 转gif
* 转竖屏
* 其他格式视频转mp4

### mp3处理

* 转文字
* 转srt
* mp3裁剪
* mp3其他格式,eg:flac,WAV,AAC,Ogg,等互相转换

### 图片png/jpg处理

* 添加文字
* 图片文字识别
* 图片按比例放缩/图片旋转
* 图片转灰白
* 图片按比例剪切
* 图片格式相互转换

### install

```
pip install easy-media-utils
```

<details>
<summary>源码安装(点击展开) </summary>
# pip freeze > requirements.txt

git clone https://github.com/aceliuchanghong/easy-media-utils.git

conda create -n dealMedia python=3.11

conda activate dealMedia

pip install -r requirements.txt
</details>

### ffmpeg

前往官网,下载对应版本的文件,解压放在本地文件并且配置环境变量,确保可以访问到

```
ffmpeg -version
```

### 项目结构

<details>
<summary>项目结构生成(点击展开) </summary>
from tree_utils.struct_tree_out import print_tree

path = r'D:\aprojectPython\pythonProject\easy-media-utils'

print_tree(path)
</details>

```
easy-media-utils/
|
├── LICENSE
├── README.md
├── requirements.txt
├── setup.py
├── base_model/
│   ├── MediaHandler.py
│   └── __init__.py
├── image_utils/
│   ├── __init__.py
│   ├── gpt_prompt.md
│   ├── converters/
│   │   ├── __init__.py
│   │   ├── format_converter.py
│   │   ├── image_to_text.py
│   │   └── text_add_to_image.py
│   ├── core/
│   │   ├── __init__.py
│   │   ├── exceptions.py
│   │   └── image_handler.py
│   ├── editors/
│   │   ├── __init__.py
│   │   ├── cropper.py
│   │   └── resizer.py
│   ├── tests/
│   │   ├── __init__.py
│   │   ├── test_converters.py
│   │   ├── test_editors.py
│   │   └── test_utils.py
│   └── utils/
│       ├── __init__.py
│       └── image_utils.py
├── mp3_utils/
│   ├── __init__.py
│   ├── gpt_prompt.md
│   ├── converters/
│   │   ├── __init__.py
│   │   ├── audio_format_converter.py
│   │   └── mp3_to_text.py
│   ├── core/
│   │   ├── __init__.py
│   │   ├── exceptions.py
│   │   └── mp3_handler.py
│   ├── editors/
│   │   ├── __init__.py
│   │   ├── effects.py
│   │   └── trimmer.py
│   ├── tests/
│   │   ├── __init__.py
│   │   ├── test_converters.py
│   │   └── test_editors.py
│   └── utils/
│       ├── __init__.py
│       └── mp3_utils.py
├── mp4_utils/
│   ├── __init__.py
│   ├── gpt_prompt.md
│   ├── converters/
│   │   ├── __init__.py
│   │   ├── mp4_to_gif.py
│   │   ├── mp4_to_mp3.py
│   │   ├── mp4_to_pngs.py
│   │   └── tv_to_mp4.py
│   ├── core/
│   │   ├── __init__.py
│   │   ├── exceptions.py
│   │   └── mp4_handler.py
│   ├── editors/
│   │   ├── __init__.py
│   │   ├── orientation.py
│   │   └── resizer.py
│   ├── tests/
│   │   ├── __init__.py
│   │   ├── test_converters.py
│   │   └── test_editors.py
│   └── utils/
│       ├── __init__.py
│       ├── file_utils.py
│       └── mp4_utils.py
├── testfiles/
└── tree_utils/
    ├── __init__.py
    └── struct_tree_out.py
```

### e.g.

```mp4
from mp4_utils.converters.mp4_to_gif import MP4ToGIFConverter
from mp4_utils.converters.mp4_to_mp3 import MP4ToMP3Converter
from mp4_utils.converters.mp4_to_pngs import MP4ToPNGsConverter
from mp4_utils.converters.tv_to_mp4 import TVToMP4Converter
from mp4_utils.core.mp4_handler import MP4Handler

def main(converter_type, file_path='../../testfiles/onboard_cover.mp4') -> MP4Handler:
    """
    Convert MP4 each frame.
    :param converter_type:
    :param file_path:
    """
    Converter = {
        "gif": MP4ToGIFConverter,
        "mp3": MP4ToMP3Converter,
        "img": MP4ToPNGsConverter,
        "other": TVToMP4Converter,
    }
    # converter = Converter[converter_type](file_path)
    converter = Converter.get(converter_type)(file_path)
    return converter

if __name__ == "__main__":
    file_path = '../../testfiles/out/onboard_cover.mp4'
    gif_out_path = '../../testfiles/out/output.gif'
    mp3_out_path = '../../testfiles/out/output.mp3'
    pngs_out_path = '../../testfiles/out/pngs_output'
    mp4_out_path = '../../testfiles/out/Sample.mp4'

    conv_file = '../../testfiles/out/Sample.mkv'

    converter_type = "img"
    ans_path = pngs_out_path
    converter = main(converter_type, file_path)
    converter.process(ans_path)
```

```mp3
from mp3_utils.converters.audio_format_converter import AudioFormatConverter
from mp3_utils.core.mp3_handler import MP3Handler

def main(converter_type, file_path='../../testfiles/out/output.mp3') -> MP3Handler:
    """
    Convert MP4 each frame.
    :param converter_type:
    :param file_path:
    """
    Converter = {
        "format": AudioFormatConverter,
    }
    converter = Converter.get(converter_type)(file_path)
    return converter

if __name__ == "__main__":
    mp3_path = '../../testfiles/out/output.mp3'
    wav_path = '../../testfiles/out/output.wav'
    flac_path = '../../testfiles/out/output.flac'

    converter_type = "format"
    ans_path = flac_path

    converter = main(converter_type, wav_path)
    converter.process(ans_path, 'flac')
```

```img
from image_utils.converters.format_converter import FormatConverter

test_image_path = "../../testfiles/out/pngs_output/frame_0001.png"
output_path = "../../testfiles/out/imgs_output"
txt = "你好"

if __name__ == '__main__':
    converter = FormatConverter(test_image_path)
    converter.process(output_path, "png")

```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/aceliuchanghong/easy-media-utils.git",
    "name": "easy-media-utils",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "media handling image audio video conversion editing",
    "author": "Sisconsavior",
    "author_email": "aceliuchanghong@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/70/5c/e9539ef40bdaeb7ab742e68dbdf25e22abcea252dc503f2e59c597b8d4a4/easy-media-utils-0.1.5.tar.gz",
    "platform": null,
    "description": "## image-utils\r\n\r\nWhen I am dealing pics,mp3,mp4. I always want a media utils to help me work, that's why this project start\r\n\r\n### mp4\u5904\u7406\r\n\r\n* \u8f6cpng/jpg\u7b49\r\n* \u8f6cmp3\r\n* \u8f6cgif\r\n* \u8f6c\u7ad6\u5c4f\r\n* \u5176\u4ed6\u683c\u5f0f\u89c6\u9891\u8f6cmp4\r\n\r\n### mp3\u5904\u7406\r\n\r\n* \u8f6c\u6587\u5b57\r\n* \u8f6csrt\r\n* mp3\u88c1\u526a\r\n* mp3\u5176\u4ed6\u683c\u5f0f,eg:flac,WAV,AAC,Ogg,\u7b49\u4e92\u76f8\u8f6c\u6362\r\n\r\n### \u56fe\u7247png/jpg\u5904\u7406\r\n\r\n* \u6dfb\u52a0\u6587\u5b57\r\n* \u56fe\u7247\u6587\u5b57\u8bc6\u522b\r\n* \u56fe\u7247\u6309\u6bd4\u4f8b\u653e\u7f29/\u56fe\u7247\u65cb\u8f6c\r\n* \u56fe\u7247\u8f6c\u7070\u767d\r\n* \u56fe\u7247\u6309\u6bd4\u4f8b\u526a\u5207\r\n* \u56fe\u7247\u683c\u5f0f\u76f8\u4e92\u8f6c\u6362\r\n\r\n### install\r\n\r\n```\r\npip install easy-media-utils\r\n```\r\n\r\n<details>\r\n<summary>\u6e90\u7801\u5b89\u88c5(\u70b9\u51fb\u5c55\u5f00) </summary>\r\n# pip freeze > requirements.txt\r\n\r\ngit clone https://github.com/aceliuchanghong/easy-media-utils.git\r\n\r\nconda create -n dealMedia python=3.11\r\n\r\nconda activate dealMedia\r\n\r\npip install -r requirements.txt\r\n</details>\r\n\r\n### ffmpeg\r\n\r\n\u524d\u5f80\u5b98\u7f51,\u4e0b\u8f7d\u5bf9\u5e94\u7248\u672c\u7684\u6587\u4ef6,\u89e3\u538b\u653e\u5728\u672c\u5730\u6587\u4ef6\u5e76\u4e14\u914d\u7f6e\u73af\u5883\u53d8\u91cf,\u786e\u4fdd\u53ef\u4ee5\u8bbf\u95ee\u5230\r\n\r\n```\r\nffmpeg -version\r\n```\r\n\r\n### \u9879\u76ee\u7ed3\u6784\r\n\r\n<details>\r\n<summary>\u9879\u76ee\u7ed3\u6784\u751f\u6210(\u70b9\u51fb\u5c55\u5f00) </summary>\r\nfrom tree_utils.struct_tree_out import print_tree\r\n\r\npath = r'D:\\aprojectPython\\pythonProject\\easy-media-utils'\r\n\r\nprint_tree(path)\r\n</details>\r\n\r\n```\r\neasy-media-utils/\r\n|\r\n\u251c\u2500\u2500 LICENSE\r\n\u251c\u2500\u2500 README.md\r\n\u251c\u2500\u2500 requirements.txt\r\n\u251c\u2500\u2500 setup.py\r\n\u251c\u2500\u2500 base_model/\r\n\u2502   \u251c\u2500\u2500 MediaHandler.py\r\n\u2502   \u2514\u2500\u2500 __init__.py\r\n\u251c\u2500\u2500 image_utils/\r\n\u2502   \u251c\u2500\u2500 __init__.py\r\n\u2502   \u251c\u2500\u2500 gpt_prompt.md\r\n\u2502   \u251c\u2500\u2500 converters/\r\n\u2502   \u2502   \u251c\u2500\u2500 __init__.py\r\n\u2502   \u2502   \u251c\u2500\u2500 format_converter.py\r\n\u2502   \u2502   \u251c\u2500\u2500 image_to_text.py\r\n\u2502   \u2502   \u2514\u2500\u2500 text_add_to_image.py\r\n\u2502   \u251c\u2500\u2500 core/\r\n\u2502   \u2502   \u251c\u2500\u2500 __init__.py\r\n\u2502   \u2502   \u251c\u2500\u2500 exceptions.py\r\n\u2502   \u2502   \u2514\u2500\u2500 image_handler.py\r\n\u2502   \u251c\u2500\u2500 editors/\r\n\u2502   \u2502   \u251c\u2500\u2500 __init__.py\r\n\u2502   \u2502   \u251c\u2500\u2500 cropper.py\r\n\u2502   \u2502   \u2514\u2500\u2500 resizer.py\r\n\u2502   \u251c\u2500\u2500 tests/\r\n\u2502   \u2502   \u251c\u2500\u2500 __init__.py\r\n\u2502   \u2502   \u251c\u2500\u2500 test_converters.py\r\n\u2502   \u2502   \u251c\u2500\u2500 test_editors.py\r\n\u2502   \u2502   \u2514\u2500\u2500 test_utils.py\r\n\u2502   \u2514\u2500\u2500 utils/\r\n\u2502       \u251c\u2500\u2500 __init__.py\r\n\u2502       \u2514\u2500\u2500 image_utils.py\r\n\u251c\u2500\u2500 mp3_utils/\r\n\u2502   \u251c\u2500\u2500 __init__.py\r\n\u2502   \u251c\u2500\u2500 gpt_prompt.md\r\n\u2502   \u251c\u2500\u2500 converters/\r\n\u2502   \u2502   \u251c\u2500\u2500 __init__.py\r\n\u2502   \u2502   \u251c\u2500\u2500 audio_format_converter.py\r\n\u2502   \u2502   \u2514\u2500\u2500 mp3_to_text.py\r\n\u2502   \u251c\u2500\u2500 core/\r\n\u2502   \u2502   \u251c\u2500\u2500 __init__.py\r\n\u2502   \u2502   \u251c\u2500\u2500 exceptions.py\r\n\u2502   \u2502   \u2514\u2500\u2500 mp3_handler.py\r\n\u2502   \u251c\u2500\u2500 editors/\r\n\u2502   \u2502   \u251c\u2500\u2500 __init__.py\r\n\u2502   \u2502   \u251c\u2500\u2500 effects.py\r\n\u2502   \u2502   \u2514\u2500\u2500 trimmer.py\r\n\u2502   \u251c\u2500\u2500 tests/\r\n\u2502   \u2502   \u251c\u2500\u2500 __init__.py\r\n\u2502   \u2502   \u251c\u2500\u2500 test_converters.py\r\n\u2502   \u2502   \u2514\u2500\u2500 test_editors.py\r\n\u2502   \u2514\u2500\u2500 utils/\r\n\u2502       \u251c\u2500\u2500 __init__.py\r\n\u2502       \u2514\u2500\u2500 mp3_utils.py\r\n\u251c\u2500\u2500 mp4_utils/\r\n\u2502   \u251c\u2500\u2500 __init__.py\r\n\u2502   \u251c\u2500\u2500 gpt_prompt.md\r\n\u2502   \u251c\u2500\u2500 converters/\r\n\u2502   \u2502   \u251c\u2500\u2500 __init__.py\r\n\u2502   \u2502   \u251c\u2500\u2500 mp4_to_gif.py\r\n\u2502   \u2502   \u251c\u2500\u2500 mp4_to_mp3.py\r\n\u2502   \u2502   \u251c\u2500\u2500 mp4_to_pngs.py\r\n\u2502   \u2502   \u2514\u2500\u2500 tv_to_mp4.py\r\n\u2502   \u251c\u2500\u2500 core/\r\n\u2502   \u2502   \u251c\u2500\u2500 __init__.py\r\n\u2502   \u2502   \u251c\u2500\u2500 exceptions.py\r\n\u2502   \u2502   \u2514\u2500\u2500 mp4_handler.py\r\n\u2502   \u251c\u2500\u2500 editors/\r\n\u2502   \u2502   \u251c\u2500\u2500 __init__.py\r\n\u2502   \u2502   \u251c\u2500\u2500 orientation.py\r\n\u2502   \u2502   \u2514\u2500\u2500 resizer.py\r\n\u2502   \u251c\u2500\u2500 tests/\r\n\u2502   \u2502   \u251c\u2500\u2500 __init__.py\r\n\u2502   \u2502   \u251c\u2500\u2500 test_converters.py\r\n\u2502   \u2502   \u2514\u2500\u2500 test_editors.py\r\n\u2502   \u2514\u2500\u2500 utils/\r\n\u2502       \u251c\u2500\u2500 __init__.py\r\n\u2502       \u251c\u2500\u2500 file_utils.py\r\n\u2502       \u2514\u2500\u2500 mp4_utils.py\r\n\u251c\u2500\u2500 testfiles/\r\n\u2514\u2500\u2500 tree_utils/\r\n    \u251c\u2500\u2500 __init__.py\r\n    \u2514\u2500\u2500 struct_tree_out.py\r\n```\r\n\r\n### e.g.\r\n\r\n```mp4\r\nfrom mp4_utils.converters.mp4_to_gif import MP4ToGIFConverter\r\nfrom mp4_utils.converters.mp4_to_mp3 import MP4ToMP3Converter\r\nfrom mp4_utils.converters.mp4_to_pngs import MP4ToPNGsConverter\r\nfrom mp4_utils.converters.tv_to_mp4 import TVToMP4Converter\r\nfrom mp4_utils.core.mp4_handler import MP4Handler\r\n\r\ndef main(converter_type, file_path='../../testfiles/onboard_cover.mp4') -> MP4Handler:\r\n    \"\"\"\r\n    Convert MP4 each frame.\r\n    :param converter_type:\r\n    :param file_path:\r\n    \"\"\"\r\n    Converter = {\r\n        \"gif\": MP4ToGIFConverter,\r\n        \"mp3\": MP4ToMP3Converter,\r\n        \"img\": MP4ToPNGsConverter,\r\n        \"other\": TVToMP4Converter,\r\n    }\r\n    # converter = Converter[converter_type](file_path)\r\n    converter = Converter.get(converter_type)(file_path)\r\n    return converter\r\n\r\nif __name__ == \"__main__\":\r\n    file_path = '../../testfiles/out/onboard_cover.mp4'\r\n    gif_out_path = '../../testfiles/out/output.gif'\r\n    mp3_out_path = '../../testfiles/out/output.mp3'\r\n    pngs_out_path = '../../testfiles/out/pngs_output'\r\n    mp4_out_path = '../../testfiles/out/Sample.mp4'\r\n\r\n    conv_file = '../../testfiles/out/Sample.mkv'\r\n\r\n    converter_type = \"img\"\r\n    ans_path = pngs_out_path\r\n    converter = main(converter_type, file_path)\r\n    converter.process(ans_path)\r\n```\r\n\r\n```mp3\r\nfrom mp3_utils.converters.audio_format_converter import AudioFormatConverter\r\nfrom mp3_utils.core.mp3_handler import MP3Handler\r\n\r\ndef main(converter_type, file_path='../../testfiles/out/output.mp3') -> MP3Handler:\r\n    \"\"\"\r\n    Convert MP4 each frame.\r\n    :param converter_type:\r\n    :param file_path:\r\n    \"\"\"\r\n    Converter = {\r\n        \"format\": AudioFormatConverter,\r\n    }\r\n    converter = Converter.get(converter_type)(file_path)\r\n    return converter\r\n\r\nif __name__ == \"__main__\":\r\n    mp3_path = '../../testfiles/out/output.mp3'\r\n    wav_path = '../../testfiles/out/output.wav'\r\n    flac_path = '../../testfiles/out/output.flac'\r\n\r\n    converter_type = \"format\"\r\n    ans_path = flac_path\r\n\r\n    converter = main(converter_type, wav_path)\r\n    converter.process(ans_path, 'flac')\r\n```\r\n\r\n```img\r\nfrom image_utils.converters.format_converter import FormatConverter\r\n\r\ntest_image_path = \"../../testfiles/out/pngs_output/frame_0001.png\"\r\noutput_path = \"../../testfiles/out/imgs_output\"\r\ntxt = \"\u4f60\u597d\"\r\n\r\nif __name__ == '__main__':\r\n    converter = FormatConverter(test_image_path)\r\n    converter.process(output_path, \"png\")\r\n\r\n```\r\n",
    "bugtrack_url": null,
    "license": "LICENSE",
    "summary": "A collection of Python utilities for handling media files.",
    "version": "0.1.5",
    "project_urls": {
        "Homepage": "https://github.com/aceliuchanghong/easy-media-utils.git"
    },
    "split_keywords": [
        "media",
        "handling",
        "image",
        "audio",
        "video",
        "conversion",
        "editing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "de4b8f216ce00412274d1a03f987227e962fd89d43ec276b5696d82c47225674",
                "md5": "3d1d33c5ce76283c76b0d66cac99487e",
                "sha256": "32ed795c1696af6757d36e37206c3be7f3a8e2ec93c68cf7dc7795e9b9b211cf"
            },
            "downloads": -1,
            "filename": "easy_media_utils-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3d1d33c5ce76283c76b0d66cac99487e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 47229,
            "upload_time": "2024-01-08T06:37:28",
            "upload_time_iso_8601": "2024-01-08T06:37:28.487109Z",
            "url": "https://files.pythonhosted.org/packages/de/4b/8f216ce00412274d1a03f987227e962fd89d43ec276b5696d82c47225674/easy_media_utils-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "705ce9539ef40bdaeb7ab742e68dbdf25e22abcea252dc503f2e59c597b8d4a4",
                "md5": "5d050939da983892980503f22549d125",
                "sha256": "79aff499620ea24ceb2c303684592c53fc6c4df77d993b745c24c04287d2d0e8"
            },
            "downloads": -1,
            "filename": "easy-media-utils-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "5d050939da983892980503f22549d125",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 34824,
            "upload_time": "2024-01-08T06:37:30",
            "upload_time_iso_8601": "2024-01-08T06:37:30.514818Z",
            "url": "https://files.pythonhosted.org/packages/70/5c/e9539ef40bdaeb7ab742e68dbdf25e22abcea252dc503f2e59c597b8d4a4/easy-media-utils-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-08 06:37:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "aceliuchanghong",
    "github_project": "easy-media-utils",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "easy-media-utils"
}
        
Elapsed time: 0.16467s