py-m3u8-to-mp4


Namepy-m3u8-to-mp4 JSON
Version 1.0 PyPI version JSON
download
home_pagehttps://github.com/olivialba
SummaryPython package to convert m3u8 playlists to mp4 videos using FFMPEG
upload_time2024-05-15 04:52:31
maintainerNone
docs_urlNone
authorAlba (Alberto Olivi)
requires_pythonNone
licenseMIT
keywords m3u8 mp4 python m3u8 to mp4 convert m3u8 playlist
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # M3U8-to-MP4
Python package to convert m3u8 playlists to mp4 videos using FFMPEG

## Install
Install using `pip install `

It also requires the user to have FFMPEG in their PATH, Download it [here](https://ffmpeg.org/download.html)

## Usage
Create an object using **`file = M3U8_Playlist('path_to_file.m3u8')`**\
For the path you can input a path to a local m3u8 file or a remote web link to it by using the prefix  "*URL:*"

Afterward, to convert the playlist to mp4, you can call **`file.to_mp4('output.mp4')`**.

*NOTE*: Using a weblink will automatically download the m3u8 file temporarily; the file will then get deleted when the mp4 is compiled.

Example:
```
m3u8 = M3U8_Playlist('playlist-1.m3u8')
m3u8.to_mp4('test-1.mp4')
```
### Special Case:
Segments without full links
```
m3u8 = M3U8_Playlist('URL:https://vz-cea98c59-23c.b-cdn.net/c309129c-27b6-4e43-8254-62a15c77c5ee/842x480/video.m3u8')
m3u8.append_to_segments('https://vz-cea98c59-23c.b-cdn.net/c309129c-27b6-4e43-8254-62a15c77c5ee/842x480/')
m3u8.to_mp4('test-2.mp4')
```
In this case, the link used as path will link to a m3u8 that has segments without full links:
```
#EXTINF:4.000000,
video0.ts
#EXTINF:4.000000,
video1.ts
#EXTINF:4.000000,
video2.ts
```
To get the .ts files of those segments and compile them together to a mp4, we need to get the full link\
You can use **append_to_segments()** to append a starting URL to each; which will result in this:
```
#EXTINF:4.000000,
https://vz-cea98c59-23c.b-cdn.net/c309129c-27b6-4e43-8254-62a15c77c5ee/842x480/video0.ts
#EXTINF:4.000000,
https://vz-cea98c59-23c.b-cdn.net/c309129c-27b6-4e43-8254-62a15c77c5ee/842x480/video1.ts
#EXTINF:4.000000,
https://vz-cea98c59-23c.b-cdn.net/c309129c-27b6-4e43-8254-62a15c77c5ee/842x480/video2.ts
```
Now we can call **to_mp4()** to compile it into a full mp4 video

## Details
`to_mp4(destination, delete_after, frame_rate, whitelist, run_async)`\
Convert the playlist to a mp4 video
- *destination* - path to the output mp4 file
- *delete_after* - will delete the m3u8 file after conversion, default for links ( URL: ) supplied as path is true
- *frame_rate* - frame/seconds of the resulting video
- *whitelist* - string of protocols allowed
- *run_async* - run conversion asynchronously

`append_to_segments(append_str)`\
Some m3u8 file may not have full URLs for each segments, use this to append a starting URL to the start of each segment in the m3u8 playlist.
This function will check if each segment starts with a valid http link. If it does, it will not append!
- *append_str* - prefix that is appended to each segment

`setHeaders(headers)`\
Set the header that will be used when making a GET request in the case of using a weblink for the m3u8 file and not local
- *headers* - header used for get request

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/olivialba",
    "name": "py-m3u8-to-mp4",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "m3u8, mp4, python, m3u8 to mp4, convert m3u8, playlist",
    "author": "Alba (Alberto Olivi)",
    "author_email": "olivialberto02@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/a8/48/d9af6ae08f4c5b8f89cfdd63c9c80f17127e19cea9134dc5c06b0facb3dd/py_m3u8_to_mp4-1.0.tar.gz",
    "platform": null,
    "description": "# M3U8-to-MP4\nPython package to convert m3u8 playlists to mp4 videos using FFMPEG\n\n## Install\nInstall using `pip install `\n\nIt also requires the user to have FFMPEG in their PATH, Download it [here](https://ffmpeg.org/download.html)\n\n## Usage\nCreate an object using **`file = M3U8_Playlist('path_to_file.m3u8')`**\\\nFor the path you can input a path to a local m3u8 file or a remote web link to it by using the prefix  \"*URL:*\"\n\nAfterward, to convert the playlist to mp4, you can call **`file.to_mp4('output.mp4')`**.\n\n*NOTE*: Using a weblink will automatically download the m3u8 file temporarily; the file will then get deleted when the mp4 is compiled.\n\nExample:\n```\nm3u8 = M3U8_Playlist('playlist-1.m3u8')\nm3u8.to_mp4('test-1.mp4')\n```\n### Special Case:\nSegments without full links\n```\nm3u8 = M3U8_Playlist('URL:https://vz-cea98c59-23c.b-cdn.net/c309129c-27b6-4e43-8254-62a15c77c5ee/842x480/video.m3u8')\nm3u8.append_to_segments('https://vz-cea98c59-23c.b-cdn.net/c309129c-27b6-4e43-8254-62a15c77c5ee/842x480/')\nm3u8.to_mp4('test-2.mp4')\n```\nIn this case, the link used as path will link to a m3u8 that has segments without full links:\n```\n#EXTINF:4.000000,\nvideo0.ts\n#EXTINF:4.000000,\nvideo1.ts\n#EXTINF:4.000000,\nvideo2.ts\n```\nTo get the .ts files of those segments and compile them together to a mp4, we need to get the full link\\\nYou can use **append_to_segments()** to append a starting URL to each; which will result in this:\n```\n#EXTINF:4.000000,\nhttps://vz-cea98c59-23c.b-cdn.net/c309129c-27b6-4e43-8254-62a15c77c5ee/842x480/video0.ts\n#EXTINF:4.000000,\nhttps://vz-cea98c59-23c.b-cdn.net/c309129c-27b6-4e43-8254-62a15c77c5ee/842x480/video1.ts\n#EXTINF:4.000000,\nhttps://vz-cea98c59-23c.b-cdn.net/c309129c-27b6-4e43-8254-62a15c77c5ee/842x480/video2.ts\n```\nNow we can call **to_mp4()** to compile it into a full mp4 video\n\n## Details\n`to_mp4(destination, delete_after, frame_rate, whitelist, run_async)`\\\nConvert the playlist to a mp4 video\n- *destination* - path to the output mp4 file\n- *delete_after* - will delete the m3u8 file after conversion, default for links ( URL: ) supplied as path is true\n- *frame_rate* - frame/seconds of the resulting video\n- *whitelist* - string of protocols allowed\n- *run_async* - run conversion asynchronously\n\n`append_to_segments(append_str)`\\\nSome m3u8 file may not have full URLs for each segments, use this to append a starting URL to the start of each segment in the m3u8 playlist.\nThis function will check if each segment starts with a valid http link. If it does, it will not append!\n- *append_str* - prefix that is appended to each segment\n\n`setHeaders(headers)`\\\nSet the header that will be used when making a GET request in the case of using a weblink for the m3u8 file and not local\n- *headers* - header used for get request\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python package to convert m3u8 playlists to mp4 videos using FFMPEG",
    "version": "1.0",
    "project_urls": {
        "Homepage": "https://github.com/olivialba"
    },
    "split_keywords": [
        "m3u8",
        " mp4",
        " python",
        " m3u8 to mp4",
        " convert m3u8",
        " playlist"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8122a4f1a5e340f8ef333e4d82077f05abc0cc1c3cb276b999717fe85437b4ad",
                "md5": "e82e58c01695fa729ff6b84fab03e698",
                "sha256": "bac920d278a9b63e9e915d602b1549ae988bc004d9477e35ed5934ab65aaac76"
            },
            "downloads": -1,
            "filename": "py_m3u8_to_mp4-1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e82e58c01695fa729ff6b84fab03e698",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 5423,
            "upload_time": "2024-05-15T04:52:29",
            "upload_time_iso_8601": "2024-05-15T04:52:29.631083Z",
            "url": "https://files.pythonhosted.org/packages/81/22/a4f1a5e340f8ef333e4d82077f05abc0cc1c3cb276b999717fe85437b4ad/py_m3u8_to_mp4-1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a848d9af6ae08f4c5b8f89cfdd63c9c80f17127e19cea9134dc5c06b0facb3dd",
                "md5": "fa9346eaecc4bf2adf7a5ff2b78ca5f3",
                "sha256": "58ca786584996e2cc3cb068f1dad1c94130e6637aefe9f52e2ee726874cf8867"
            },
            "downloads": -1,
            "filename": "py_m3u8_to_mp4-1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "fa9346eaecc4bf2adf7a5ff2b78ca5f3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4696,
            "upload_time": "2024-05-15T04:52:31",
            "upload_time_iso_8601": "2024-05-15T04:52:31.322988Z",
            "url": "https://files.pythonhosted.org/packages/a8/48/d9af6ae08f4c5b8f89cfdd63c9c80f17127e19cea9134dc5c06b0facb3dd/py_m3u8_to_mp4-1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-15 04:52:31",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "py-m3u8-to-mp4"
}
        
Elapsed time: 0.30513s