Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flv的封装格式有什么特殊要求么? #62

Closed
meowmiaomiaomiao opened this issue Dec 21, 2016 · 5 comments
Closed

flv的封装格式有什么特殊要求么? #62

meowmiaomiaomiao opened this issue Dec 21, 2016 · 5 comments

Comments

@meowmiaomiaomiao
Copy link

作者你好,我之前没有做过类似视频的工作,所以有几个基础的问题想问一下
flv-demuxer.js对flv的封装格式有什么特殊要求么?
我试了下b站的flv的确可以转,但是我自己用flash做出来的flv是转换不了的
我用的flash cc 2015做的但是不支持直接导出flv,我就导出了avi再转flv..
这个flv放在你的代码里可以得到ArrayBuffer这一步,但是浏览器是没办法播放的

@xqq
Copy link
Contributor

xqq commented Dec 21, 2016

请提供具体的控制台logcat

@meowmiaomiaomiao
Copy link
Author

作者大人你好!控制台是没有报错的 我这里是是这么使用的
先用reader.readAsArrayBuffer()去读取一个flv
然后用下面两个模块
import FLVDemuxer from './demux/flv-demuxer.js';
import MP4Remuxer from './remux/mp4-remuxer.js';
const demuxer = new FLVDemuxer(arrayBuffer);
const remuxer = new MP4Remuxer();
remuxer.bindDataSource(demuxer);
remuxer.onMediaSegment = (type, mediaSegment) => {
const blob = new Blob(new Uint8Array(mediaSegment.data))
const video = document.querySelector('video');
video.src = URL.createObjectURL(blob,{ type: "video/mp4" });
}
demuxer.parseChunks(arrayBuffer, 0);
这样是否正确?
mediaSegment.data里数据看起来都正常,我怀疑是我用第三方软件去转FLV的问题B站的FLV是怎么处理的呢?

@xqq
Copy link
Contributor

xqq commented Dec 21, 2016

这是什么鬼?
请仔细阅读 flv.js 代码。

@meowmiaomiaomiao
Copy link
Author

是这样,因为我以前没接触过视频类的工作,所以一开始以为这个开源代码是可以接收任意h264格式的flv的
于是我用HTML5的FileReader去读了本地的一个flv
然后用FLVDemuxer MP4Remuxer 这两个模块去换了封装生成了一个blob丢进了video了
控制台上提示
[FLVDemuxer] > Parsed onMetaData
[FLVDemuxer] > Parsed AVCDecoderConfigurationRecord
这两行,但是并不可以播放

现在我把我的flv用B站官网提供的压制工具又压了一遍,可以正常运行了
控制台提示出了下面的三行
[FLVDemuxer] > Parsed onMetaData
[FLVDemuxer] > Parsed AVCDecoderConfigurationRecord
[FLVDemuxer] > Parsed AudioSpecificConfig

我的flv是没有声音的,所以我怀疑代码处理声音的部分可能有些小BUG吧,这里我也不太懂...
现在换了压制工具就正常了,看你的代码学到很多关于视频的知识 感谢:)

@xqq
Copy link
Contributor

xqq commented Dec 21, 2016

生成的每个 Segment 不是让你丢给 video 标签直接播的。参阅 Media Source Extensions

@xqq xqq closed this as completed Jan 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants