gpt4 book ai didi

ffmpeg - MP4 的实时转码和流式传输在 Android 中有效,但在 Flash 播放器中失败并出现 NetStream.Play.FileStructureInvalid 错误

转载 作者:行者123 更新时间:2023-12-01 19:36:44 25 4
gpt4 key购买 nike

最近我有一个任务是使用 ffmpeg 作为转码和流媒体工具。任务是将文件从给定格式转换为 MP4,并通过从 stdout 捕获它立即流式传输。到目前为止,一切都很好。流媒体适用于 android 选项卡的 native 播放器以及 VLC 播放器。问题出在 Flash 播放器上。它给出了以下错误:

NetStream.Play.FileStructureInvalid : Adobe Flash cannot import files that have invalid file structures.

使用的 ffmpeg 标志是

$ ffmpeg -loglevel quiet -i somefile.avi -vbsf h264_mp4toannexb -vcodec libx264 \
-acodec aac -f MP4 -movflags frag_keyframe+empty_moov -re - 2>&1

最佳答案

如前所述in the docs for -movflags

The mov/mp4/ismv muxer supports fragmentation. Normally, a MOV/MP4 file has all the metadata about all packets stored in one location (written at the end of the file, it can be moved to the start for better playback using the qt-faststart tool). A fragmented file consists of a number of fragments, where packets and metadata about these packets are stored together. Writing a fragmented file has the advantage that the file is decodable even if the writing is interrupted (while a normal MOV/MP4 is undecodable if it is not properly finished), and it requires less memory when writing very long files (since writing normal MOV/MP4 files stores info about every single packet in memory until the file is closed). The downside is that it is less compatible with other applications.

要么切换到可以处理碎片化 MP4 文件的 Flash 播放器,要么使用更好地支持流式传输的不同容器格式。

此外,-re 是一个仅限输入的选项,因此在输入之前指定它比在输出之前指定它更有意义。

关于ffmpeg - MP4 的实时转码和流式传输在 Android 中有效,但在 Flash 播放器中失败并出现 NetStream.Play.FileStructureInvalid 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11616979/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com