首页 > 解决方案 > 如何从碎片化的mp4中获取帧信息

问题描述

我正在使用以下命令生成 fmp4 文件

ffmpeg -rtsp_transport tcp -i rtsp://someuser:somepassword@somedomain:someport/Streaming/Channels/101 -acodec copy -vcodec copy -hls_segment_type fmp4 -hls_time 2 -hls_list_size 10 -hls_flags delete_segments+append_list+split_by_time -hls_playlist_type event test.m3u8

我需要知道每个片段的确切持续时间和帧数。不幸的是 -vstats 似乎被忽略了。

我尝试使用

ffprobe -show_frames ./test0.m4s

但我明白了

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fb68e80b000] could not find corresponding track id 1 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fb68e80b000] could not find corresponding trex (id 1) [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fb68e80b000] could not find corresponding track id 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fb68e80b000] trun track id unknown, no tfhd was found [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fb68e80b000] error reading header ./test0.m4s: Invalid data found when processing input

我假设这是因为尚未加载初始化段,但我找不到这样做的选项。

如果我尝试用

ffprobe -show_frames ./init.mp4

我没有得到任何帧信息和错误

Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none, 2560x1440): unspecified pixel format Consider increasing the value for the 'analyzeduration' and 'probesize' options

将不胜感激任何帮助。

标签: ffmpegmp4ffprobefmp4

解决方案


我假设这是因为尚未加载初始化段

正确的。

实现您所需要的一种方法是将cat初始化段和媒体段放在一起并将它们输送到ffprobe

$ cat ./init.mp4 ./test0.m4s | ffprobe -show_frames -

推荐阅读