问题
I'm trying to make a video from a sequence of .jpg files using Nreco.videoconverter ffmpeg wrapper. I search for answer on this forum and topic that almost help me is
http://stackoverflow.com/questions/15280199/how-to-make-a-video-file-from-images
If you already have image files the best way is using special "image2" format (FFMpeg demuxer) and FFMPeg will read files directly for producing video Video can be produced in real-time with live stream conversion supported by VideoConverter. In this case "rawvideo" should be specified as input format and C# application should pass RAW bitmap bytes (as mentioned in the question) as input for live stream converter.
I try with this code but I always get video with 1 frame (the first one from array):
NReco.VideoConverter.FFMpegConverter c = new FFMpegConverter();
ConcatSettings set = new ConcatSettings();
set.VideoFrameRate = 5;
set.VideoFrameCount = 10;
set.ConcatVideoStream = true;
set.ConcatAudioStream = false;
set.SetVideoFrameSize(704, 576);
string[] _fileNames = new string[25];
_fileNames[0] = "g:\\Storage\\001.jpg";
_fileNames[1] = "g:\\Storage\\002.jpg";
_fileNames[2] = "g:\\Storage\\003.jpg";
_fileNames[3] = "g:\\Storage\\004.jpg";
_fileNames[4] = "g:\\Storage\\005.jpg";
_fileNames[5] = "g:\\Storage\\006.jpg";
_fileNames[6] = "g:\\Storage\\007.jpg";
_fileNames[7] = "g:\\Storage\\008.jpg";
_fileNames[8] = "g:\\Storage\\009.jpg";
_fileNames[9] = "g:\\Storage\\010.jpg";
c.ConcatMedia(_fileNames, "g:\\Storage\\test2.mp4", Format.mp4, set);
I also try to use ConvertMedia() method instead ConcatMedia but with same result.
Is there any way to tell converter this is a sequence of images ?
Is there any other FFMPEG wrraper or way to do this ?
I found AForge class which is good but working only with .NET 3.5
Tnx!
回答1:
FFMpegConverter.ConcatMedia uses concat filter for merging several video files and should not be used for encoding video from images.
Correct way of using ConvertMedia method with ffmpeg image demuxer:
var videoConv = new FFMpegConverter();
videoConv.ConvertMedia(
@"g:\Storage\%03d.jpg", null,
"test.mp4", null,
new ConvertSettings() {
CustomInputArgs = " -framerate 5 ",
// specify any additional ffmpeg parameters for output here
CustomOutputArgs = " -profile:v high "
});
来源:https://stackoverflow.com/questions/37865475/nreco-video-converter-make-video-from-image-sequence