The result of the power shell window
我在这里看到了一篇关于将 m4s 转换为 mp4 的帖子,我已经按照将所有文件连接到另一个 m4s 文件中的步骤进行操作,我称之为 all.m4s,当我使用命令 ffmpeg -i allm4s.m4s -c copy video.mp4 .我通过编写一个 exe 将所有包含单词 video 的 m4s 文件添加到 m4s 文件中来制作组合的 m4s 文件。这是用c#编写的源代码,如果您编译代码,那么这就是我用来制作m4s的代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace files
{
class Program
{
static void Main(string[] args)
{
string dir = Directory.GetCurrentDirectory();
string[] info = Directory.GetFiles(dir);
Console.WriteLine(dir + "\\allm4s.m4s");
Console.ReadKey();
foreach (string name in info)
{
if (Path.GetFileName(name).Contains(".m4s") && Path.GetFileName(name).Contains("video"))
{
using (Stream srcStream = File.OpenRead(name))
{
using (Stream destStream = File.OpenWrite(dir+"\\allm4s.m4s"))
{
srcStream.CopyTo(destStream);
Console.WriteLine(destStream+name);
}
}
}
}
Console.ReadKey();
}
}
}
我认为如果有问题,这与这个 allm4s.m4s 文件有关,因为文件大小约为 1.5mb,即使每个段 m4s 约为 750kb,而且有很多。如果有人有办法添加通过有用的程序/应用程序将大量文件连接在一起。
最佳答案
您收到该错误是因为您可能正在连接不同尺寸的视频。
所有输入文件的全名都存储在输入数组中
Java程序
String inputStr="";
String stream="";
for(int index=0;index<input.length;index++){
inputStr=inputStr+" -i "+input[index];
stream =stream +"["+index+":v]"+"["+index+":a]"; //gets audio and video stream of file
}
String command = "ffmpeg "+inputStr+" -filter_complex \" "+stream+" concat=n="+(index-1)+ \
":v=1:a=1 [v] [a] \" "+ "-map \"[v]\" -map \"[a]\" outputfile.m4s"
Runtime.getRuntime(command).exec().waitFor();//runs ffmpeg command to concat all files
关于c# - 处理 ffmpeg m4s 上的输入到 mp4 传输时发现无效数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60469923/