.. image:: https://img.shields.io/pypi/v/m3u8-To-MP4?style=flat-square :alt: PyPI
Python downloader for saving m3u8 videos to local MP4 files.
Preparation: configure ffmpeg. (e.g., Win10)
Download <https://ffmpeg.org/download.html>
_ "release full" build. It will have the largest set of libraries with greater functionality.Installation: m3u8_To_MP4
.. code-block:: python
python -m pip install m3u8_To_MP4
git clone https://github.com/songs18/m3u8_To_MP4.git python -m pip install ./m3u8_To_MP4
There are two options to download a m3u8 video into a mp4 file: async and multi-threads.
Multi-thread downloader (recommend)
.. code-block:: python
import m3u8_To_MP4
if name == 'main':
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
.. code-block:: python
import m3u8_To_MP4
if name == 'main':
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:
.. code-block:: python
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)
.. _ffmpeg: http://www.ffmpeg.org/download.html