Skip to main content

Python downloader for saving m3u8 video to local MP4 file.

Project description

https://img.shields.io/pypi/v/m3u8-To-MP4?style=flat-square:alt:PyPI

M3u8-To-MP4

Python downloader for saving m3u8 videos to local MP4 files.

QuickStart

Install m3u8_To_MP4 via pip

  1. Preparation: configure ffmpeg. (e.g., Win10)

    • Download “release full” build. It will have the largest set of libraries with greater functionality.

    • Extract the contents in the ZIP file to a folder of your choice.

    • To add FFmpeg to Win10 path. (User variables -> Path -> New and add)

    • Verify. Open the Command Prompt or PowerShell window, type ffmpeg, and press Enter.

  2. Installation: m3u8_To_MP4

    pip install m3u8_To_MP4

Download a mp4 video

There are two options to download a m3u8 video into a mp4 file: async and multi-threads.

Multi-thread downloader (recommend)

import m3u8_To_MP4

if __name__ == '__main__':
    # 1. Download videos from uri.
    m3u8_To_MP4.multithread_download('http://videoserver.com/playlist.m3u8')

    # 2. Download videos from existing m3u8 files.
    m3u8_To_MP4.multithread_file_download('http://videoserver.com/playlist.m3u8',m3u8_file_path)

    # For compatibility, i reserve this api, but i do not recommend to you again.
    # m3u8_To_MP4.download('http://videoserver.com/playlist.m3u8')

Asynchronous downloader

import m3u8_To_MP4

if __name__ == '__main__':
    # 1. Download mp4 from uri.
    m3u8_To_MP4.async_download('http://videoserver.com/playlist.m3u8')

    # 2. Download mp4 from existing m3u8 files.
    m3u8_To_MP4.async_file_download('http://videoserver.com/playlist.m3u8',m3u8_file_path)

Resuming

If you use default tmp dir, resuming the transfer from the point of interruption will be executed automatically (based on crc32 hashing).

Custom http request header

In some cases, customized http request headers help to match some website requirements. For the available APIs, you can pass in a dictionary type header, which overrides the settings in the program. A simple example is:

import m3u8_To_MP4

if __name__ == '__main__':
    customized_http_header=dict()
    customized_http_header['Referer']='https://videoserver.com/'

    m3u8_To_MP4.multithread_download('http://videoserver.com/playlist.m3u8',customized_http_header=customized_http_header)

Features

  1. Treat ffmpeg as a system service to achieve cross-platform.

  2. If ffmpeg is not found, archiving is also supported. (v0.1.3 new features)

  3. Resume from interruption. (based on crc32 temp directory path)

  4. Use system tmp folder.

  5. Concurrent requests based on the thread pool.

  6. Concurrent requests based on efficient coroutines (v0.1.3 new features).

  7. The retry strategy is carried out collectively after the whole cycle is repeated, avoiding the problem of short retry interval.

  8. Download videos from existing m3u8 files.

  9. Anti-crawler parameters based on customized request headers.

  10. Clean codes based on inheritance.

TODO

  • Errors: application data after close notify (related to the Python interpreter).

  • Extract independent asynchronous http package.

  • Support IPv6.

  • Compare ffmpeg/avconv/mencoder/moviepy.

  • Support bilibili etc.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

m3u8-To-MP4-0.1.10.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

m3u8_To_MP4-0.1.10-py3-none-any.whl (30.5 kB view details)

Uploaded Python 3

File details

Details for the file m3u8-To-MP4-0.1.10.tar.gz.

File metadata

  • Download URL: m3u8-To-MP4-0.1.10.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.7

File hashes

Hashes for m3u8-To-MP4-0.1.10.tar.gz
Algorithm Hash digest
SHA256 722364424f42b0539b5c96e080ee9269f777f077917299d10f84fffbfe01d275
MD5 40e221e20d00a35a976ab61db464300a
BLAKE2b-256 2b3058eb9b8af0c3f5e6f7d42c45af28de3e61c8e31fceed60458dd466ea54cd

See more details on using hashes here.

File details

Details for the file m3u8_To_MP4-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: m3u8_To_MP4-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 30.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.7

File hashes

Hashes for m3u8_To_MP4-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 1737f7d7d4ed155cb92e4d75fc765c767295a2533c0d2d8bc4dc243e1f5ed73e
MD5 5f288c743f2be8a426652fcfe825d5ab
BLAKE2b-256 6970e583ffe116ce8ce297238db6e55420f53842026105ca1bd5ae39b610a09f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page