All Projects → supervergil → node-m3u8-to-mp4

supervergil / node-m3u8-to-mp4

Licence: other
convert m3u8 to mp4

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to node-m3u8-to-mp4

Sjmediacacheserver
A HTTP Media Caching Framework. It can cache FILE or HLS media. 音视频边播边缓存框架, 支持 HLS(m3u8) 和 FILE(mp4, mp3等).
Stars: ✭ 87 (+128.95%)
Mutual labels:  mp4, m3u8
Webxdownloader
Browser extension to download Webex meeting recordings
Stars: ✭ 52 (+36.84%)
Mutual labels:  mp4, m3u8
Mediasdk
The library is working for downloading video while playing the video, the video contains M3U8/MP4
Stars: ✭ 164 (+331.58%)
Mutual labels:  mp4, m3u8
Media Server
RTSP/RTP/RTMP/FLV/HLS/MPEG-TS/MPEG-PS/MPEG-DASH/MP4/fMP4/MKV/WebM
Stars: ✭ 1,363 (+3486.84%)
Mutual labels:  mp4, m3u8
Atldotnet
Fully managed, portable and easy-to-use C# library to read and edit audio data and metadata (tags) from various audio formats, playlists and CUE sheets
Stars: ✭ 180 (+373.68%)
Mutual labels:  mp4
Fastflix
FastFlix is a free GUI for HEVC and AV1 encoding, GIF/WebP creation, and more!
Stars: ✭ 154 (+305.26%)
Mutual labels:  mp4
Metadata Extractor
Extracts Exif, IPTC, XMP, ICC and other metadata from image, video and audio files
Stars: ✭ 1,972 (+5089.47%)
Mutual labels:  mp4
Mediafile
A unified reader of metadata from audio & video files.
Stars: ✭ 138 (+263.16%)
Mutual labels:  mp4
Tageditor
A tag editor with Qt GUI and command-line interface supporting MP4/M4A/AAC (iTunes), ID3, Vorbis, Opus, FLAC and Matroska
Stars: ✭ 229 (+502.63%)
Mutual labels:  mp4
Gallery shell
📷 Bash Script to generate static responsive image web galleries.
Stars: ✭ 198 (+421.05%)
Mutual labels:  mp4
Magicalexoplayer
The Easiest Way To Play/Stream Video And Audio Using Google ExoPlayer In Your Android Application
Stars: ✭ 171 (+350%)
Mutual labels:  mp4
Isobmff
C++ Library for ISO/IEC 14496-12 - ISO Base Media File Format (QuickTime, MPEG-4, HEIF, etc)
Stars: ✭ 157 (+313.16%)
Mutual labels:  mp4
Griffith
A React-based web video player
Stars: ✭ 2,287 (+5918.42%)
Mutual labels:  mp4
Continuous Audiorecorder
Implementation of the missing feature in Android SDK: audio recorder with a pause.
Stars: ✭ 151 (+297.37%)
Mutual labels:  mp4
Chimee
a video player framework aims to bring wonderful experience on browser
Stars: ✭ 2,332 (+6036.84%)
Mutual labels:  mp4
Go Mp4
Go library for reading and writing MP4 file
Stars: ✭ 139 (+265.79%)
Mutual labels:  mp4
Symphonia
Pure Rust multimedia format demuxing, tag reading, and audio decoding library
Stars: ✭ 191 (+402.63%)
Mutual labels:  mp4
Minimp4
Minimalistic MP4 mux/demux single header library
Stars: ✭ 169 (+344.74%)
Mutual labels:  mp4
Ni Media
NI Media is a C++ library for reading and writing audio streams.
Stars: ✭ 158 (+315.79%)
Mutual labels:  mp4
Audioplayer
Audio Player for Nextcloud and ownCloud
Stars: ✭ 179 (+371.05%)
Mutual labels:  mp4

node-m3u8-to-mp4

可以将远程或本地的 m3u8 文件转换成 MP4 或 MP3 等媒体文件

最新版本

v3.0.0

安装

npm install node-m3u8-to-mp4 -S

用法说明

v3.x 将 node-m3u8-to-mp4 的功能解耦成 4 大部分

  • m3u8 解析器 -> mParser
  • 下载器 -> mDownloader
  • 媒体片段合成器 -> mConverter
  • 进度指示器 -> mIndicator

如下代码:

const { mParser, mDownloader, mConverter, mIndicator } = require("node-m3u8-to-mp4");

开发者可以根据项目具体情况灵活组合各个部分

下载 m3u8 媒体文件的一般过程为:解析视频资源列表(mParser)->下载资源片段(mDownloader)->片段合成文件(mConverter)

大致用法如下:

mParser("m3u8的本地或远程路径").then(list=>{
  const medias = list.map((item) => `${item.url}`);
  mDownloader(medias).then(()=>{
    mConverter("临时缓存路径", "媒体路径");
  });
})

详细用法如下(也可以参考 example.js文件):

const {
  mParser,
  mDownloader,
  mConverter,
  mIndicator,
} = require("node-m3u8-to-mp4");

const path = require("path");
const fse = require("fs-extra");

// 设定进度指示器(可不设置)
mIndicator("downloading", (index, total) => {
  console.log("下载进度:" + ((index / total) * 100).toFixed(2) + "%");
});

mIndicator("converting", (index, total) => {
  console.log("转换进度:" + ((index / total) * 100).toFixed(2) + "%");
});

// 过程:解析视频资源列表(mParser)->下载资源片段(mDownloader)->片段合成文件(mConverter)

// 解析资源列表,第二个参数为远程请求文件时的请求头,可留空
mParser(path.join(__dirname, "./index.m3u8"), {
  referer: "https://www.great-elec.com/",
}).then((list) => {
  // [{url:"",isFull:boolean},...] 资源列表,若url不是完整的互联网路径,可根据isFull字段做二次处理
  const medias = list.map((item) => `${item.url}`);

  console.log("解析完成,开始下载");

  // 下载媒体列表,配置项可留空,targetPath为存储片段的临时文件夹路径默认为'.tmp',headers为远程请求头
  mDownloader(medias, {
    targetPath: path.resolve(".target"),
    headers: {
      referer: "https://www.great-elec.com/",
    },
  })
    .then(() => {
      console.log("下载完成,正在转换");

      // 下载完成后,根据临时文件夹路径,合成视频到指定位置的指定格式,最后一个参数表示是否要在程序运行完后清除临时目录,默认为true
      mConverter(path.resolve(".target"), "./video.mp4").then(() => {
        console.log("已生成文件");
      });
    })
    .catch((e) => {
      console.log("下载出错!");
      // 下载出错,可将指定下载的临时目录删除
      fse.removeSync(path.resolve(".target"));
    });
});

作者联系方式

微信: zaowangxiaoye

技术交流,结交好友

ps:接各种前后端私活,欢迎联系

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].