ffmpeg将m4s转换为mp4

时间:2018-10-08 14:59:06

标签: video ffmpeg mp4 mpeg-dash

我正在研究DASH,试图为最终用户优化QoE。

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

我想要的是将接收到的来自用户的段合并为一个m4,并将该m4s转换为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在这里。

如何解决此问题?

2 个答案:

答案 0 :(得分:0)

这有效

将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

答案 1 :(得分:0)

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

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