Skip to main content

biliffm4s: A tool to merge Bilibili cached .m4s files into .mp4

Project description

biliffm4s: Android哔哩哔哩缓存视频合并

简介

biliffm4sbilibili-ffmpeg-m4s(to-mp4)的缩写.顾名思义,该项目提供了一个Python库,将Android手机哔哩哔哩缓存的视频(为.m4s)格式转化为.mp4格式.文件转化功能由ffmpeg实现,见github链接
项目已经发布在PyPi上.因此,使用pip install biliffm4s即可使用.biliffm4s是即开即用的,不需要安装第三方依赖(如配置ffmpeg环境等).

仅适配Windows 64位平台

使用

biliffm4s的使用非常简单:按需使用提供的convert()combine()即可.
具体使用见下:

convert()

convert函数接受输入的音视频.m4s文件,合并并输出为.mp4.

  • 参数
    • video: 输入的视频路径.后缀.m4s可以省略.缺省值为video.m4s
    • audio: 输入的音频路径.后缀.m4s可以省略.缺省值为audio.m4s
    • output: 输出的视频路径.后缀.mp4可以省略.缺省值为output.mp4
  • 返回值: bool 合并成功与否

combine()

convert函数需要手动找到对应的.m4s,有时这并不够方便.combine函数提供了一种更简单的方式:只需要提供包含对应video.m4saudio.m4s(哔哩哔哩的缓存视频文件夹始终是这两个名称)的文件夹路径即可,其会自动的进行查找并合并.

在使用combine()时,确保路径下只有唯一的video.m4saudio.m4s

  • 参数
    • directory: 包含video.m4saudio.m4s的文件夹路径
    • output: 输出的视频路径.后缀.mp4可以省略.缺省值为output.mp4
  • 返回值: bool 合并成功与否

示例:

import biliffm4s

biliffm4s.convert('video.m4s', 'audio.m4s', 'result.mp4') # 将video.m4s和audio.m4s合并为result.mp4  
biliffm4s.convert(output='result2') # 将video.m4s和audio.m4s合并为result2.mp4 
biliffm4s.convert() # 将video.m4s和audio.m4s合并为output.mp4  
biliffm4s.combine('sample') # 自动读取sample文件夹下的video.m4s和audio.m4s并合并为output.mp4

如何获取Android设备缓存的.m4s文件

按照以下步骤进行操作:

  1. 将视频缓存到你的Android设备上
  2. 使用数据线将其链接至电脑,并进入USB文件传输模式
  3. 访问\Android\data\tv.danmaku.bili\download路径
  4. 你会看到一堆以数字命名的文件夹,每个文件夹都是一个缓存的视频.通过文件大小和时间判断对应的缓存视频
  5. 至对应文件夹的最深层次处,你会看到video.m4s,audio.m4s,index.json文件,分别对应哔哩哔哩视频的视频,音频和弹幕.拷贝两个.m4s到你的电脑上

如果你使用的是哔哩哔哩概念版,那路径为\Android\data\com.bilibili.app.blue\download
如果你使用的是combine(),直接复制\download路径下的对应子文件夹即可

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

biliffm4s-1.5.tar.gz (48.7 MB view details)

Uploaded Source

Built Distribution

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

biliffm4s-1.5-py3-none-any.whl (99.7 MB view details)

Uploaded Python 3

File details

Details for the file biliffm4s-1.5.tar.gz.

File metadata

  • Download URL: biliffm4s-1.5.tar.gz
  • Upload date:
  • Size: 48.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for biliffm4s-1.5.tar.gz
Algorithm Hash digest
SHA256 16c68d7e504f12f15c8a7d0522013c6f0fbbdcf4e202b8b3cd80ee24c5faac7b
MD5 db85086eab03b19b9dfdf926051111ba
BLAKE2b-256 20b5acf6a481e635996d6521c5533ef600a5f5e58e3ab4a275ccf0f73a854b50

See more details on using hashes here.

File details

Details for the file biliffm4s-1.5-py3-none-any.whl.

File metadata

  • Download URL: biliffm4s-1.5-py3-none-any.whl
  • Upload date:
  • Size: 99.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for biliffm4s-1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 dffcd5f2b4ea29a3a715d2807320834f96e1e4dfcb52367b01d81eca1906b33c
MD5 610a4e4bc57999d95cab97365a2fa55d
BLAKE2b-256 f086c0ee8dfce4475d05c7446982b6611657c2dafd217616eb1999eb4b73654e

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