来自 m3u8 HTTP Live Streaming 的 FFMPeg mp4?

如何从 m3u8 HTTP Live Streaming 中提取 mp4:

ffmpeg -i {input file} -f rawvideo -bsf h264_mp4toannexb -vcodec copy out.mp4

我犯了这个错误:

[ NULL@000000002f07060]数据包头不包含在全局外部数据、已损坏的流或无效的 MP4/AVCC 比特流中未能用编解码器拷贝打开流0的比特流过滤器 h264 _ mp4to 膜件: I

216683 次浏览

Your command is completely incorrect. The output format is not rawvideo and you don't need the bitstream filter h264_mp4toannexb which is used when you want to convert the h264 contained in an mp4 to the Annex B format used by MPEG-TS for example. What you want to use instead is the aac_adtstoasc for the AAC streams.

ffmpeg -i http://.../playlist.m3u8 -c copy -bsf:a aac_adtstoasc output.mp4

Aergistal's answer works, but I found that converting to mp4 can make some m3u8 videos broken. If you are stuck with this problem, try to convert them to mkv, and convert them to mp4 later.