【问题标题】:ffmpeg converting m4s to mp4ffmpeg 将 m4s 转换为 mp4
【发布时间】:2018-10-08 14:59:05
【问题描述】:

我正在开发 DASH,尝试为最终用户优化 QoE。

我有一个视频并使用 ffmpeg 将其编码为不同的比特率,一切都很好,并且可以使用破折号播放视频。

我想要的是将从用户那里收到的片段组合成一个 m4 并将该 m4 转换为 mp4。

我在ffmpeg中尝试了很多方法,但总是给我这个错误:

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x9a9e500] could not find corresponding track id 1
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x9a9e500] could not find corresponding trex
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x9a9e500] error reading header
test2.m4s: Invalid data found when processing input

segment_1.m4s 在那里。

我该如何解决这个问题?

【问题讨论】:

  • 您缺少文件开头的初始化片段。
  • @szatmary 我自己编码了视频,38 个片段都是我得到的。它们都被合并到那个 m4s 文件中,初始化段应该在哪里?

标签: video ffmpeg mp4 mpeg-dash


【解决方案1】:

这行得通

将 m4s 段合并到一个文件中,确保文件顺序正确。例如

cat video-0.m4s >> all.m4s
cat video-1.m4s >> all.m4s
cat video-2.m4s >> all.m4s
cat video-3.m4s >> all.m4s
cat video-4.m4s >> all.m4s
cat video-5.m4s >> all.m4s
cat video-6.m4s >> all.m4s
cat video-7.m4s >> all.m4s
cat video-8.m4s >> all.m4s
cat video-9.m4s >> all.m4s
cat video-10.m4s >> all.m4s

然后一次性完成所有转换。

ffmpeg -i all.m4s -c copy video.mp4

这不是

我在尝试流式传输方法时遇到了同样的问题 (could not find corresponding trex)。

我在 all.txt 文件中拥有我想要的所有文件,其中包含

file 'video-0.m4s'
file 'video-1.m4s'
file 'video-2.m4s'
file 'video-3.m4s'
file 'video-4.m4s'
file 'video-5.m4s'
file 'video-6.m4s'
file 'video-7.m4s'
file 'video-8.m4s'
file 'video-9.m4s'
file 'video-10.m4s'

我尝试了ffmpeg -f concat -safe 0 -i all.txt -c copy video.mp4,导致同样的问题。

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55fde2d0c520] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none, 1280x720): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55fde2d0c520] Auto-inserting h264_mp4toannexb bitstream filter
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55fde2d0c520] could not find corresponding track id 1
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55fde2d0c520] could not find corresponding trex
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55fde2d0c520] error reading header
[concat @ 0x55fde2cff900] Impossible to open 'rifle-1.m4s'
[concat @ 0x55fde2cff900] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none, 1280x720): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, concat, from 'all.txt':
[... omitted ...]
all.txt: Input/output error

【讨论】:

  • 是同样的问题,所有文件都在同一个地方,但仍然报错
  • init 段怎么样?初始化段需要做什么?
  • @user8783065 你在init段之后连接m4s文件,我做for x in *.dash *.m4s; do cat $x >> output.mp4; done,其中init段是.dash文件
【解决方案2】:

要连接初始化段的第一个文件,然后是其他段文件。

windows powershell:

对视频文件进行排序和列出

 Get-ChildItem -name v1*.m4s| Sort-Object { [regex]::Replace($_, '\d+', { $args[0].Value.PadLeft(20) }) } > list.txt

音频文件

 Get-ChildItem -name a1*.m4s| Sort-Object { [regex]::Replace($_, '\d+', { $args[0].Value.PadLeft(20) }) } > list.txt

(参考:How to sort by file name the same way Windows Explorer does?

 type *init*.mp4 list.txt > Filename.mp4

Linux:

 ls -1v v1*.m4s > list.txt
 cat *init*.mp4 list.txt > Filename.mp4

【讨论】:

  • 请检查您的所有数据是否存在 init.mp4 - sps、pps 等。
【解决方案3】:

我同意其他答案,但我发现一个略有不同的案例。 连接 m4s 文件我得到了相同的 could not find corresponding trex 错误。

我得到了这个 m3u8 播放列表:

#EXTM3U
#EXT-X-VERSION:6
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-TARGETDURATION:5
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-MAP:URI="/mypath/something.mp4"
#EXTINF:3.000,
something001.m4s
#EXTINF:3.000,
something002.m4s
#EXTINF:3.000,
something003.m4s
#EXTINF:3.000,
something004.m4s
#EXT-X-ENDLIST

我必须从 mp4 文件开始连接所有这些文件。 mp4 文件只有 1.1kB,我猜没有视频,只有标题。

拼接后的文件可能会被某些软件播放,但兼容性不是很好,所以你必须让ffmpeg为你修复它。

这对我有用:

ffmpeg -i allgluedtogetherinorder.mp4 -vcodec copy -strict -2 video_out.mp4

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-11-04
    • 2015-09-03
    • 2014-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多