I'm trying to combine two .flv video files together into one, but even though the output file's size is exactly the sum of the two videos I am trying to combine -1, when I try to play the new video file it plays the first file. I'm sure it has to do with an end flag being set after the first video has been read into the output stream but I'm not exactly sure how to fix this and remove it so that the video plays all the way through. I made sure both files were exactly the same encoding wise as I had just recorded some full screen color's from obs as my test videos. Anyways how would I go about fixing this?
package testing.space;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
public class TestingSpace
{
public static void main(String args[])
{
final int BUFFERSIZE = 8192;
String introFilePath = "C:\\ExampleFile1Path\\vid1.flv";
String vodFilePath = "C:\\ExampleFile2Path\\vid2.flv";
String outputFilePath = "C:\\ExampleOutputPath\\output.flv";
try (
FileInputStream intro = new FileInputStream(new File(introFilePath));
FileInputStream vod = new FileInputStream(new File(vodFilePath));
FileOutputStream fout = new FileOutputStream(new File(outputFilePath));
)
{
byte[] introBuffer = new byte[BUFFERSIZE];
int introBytesRead;
while ((introBytesRead = intro.read(introBuffer)) > 0)
{
fout.write(introBuffer, 0, introBytesRead);
}
byte[] vodBuffer = new byte[BUFFERSIZE];
int vodBytesRead;
while ((vodBytesRead = vod.read(vodBuffer)) > 0)
{
fout.write(vodBuffer, 0, vodBytesRead);
}
}
catch (Exception e)
{
System.out.println("Something went wrong! Reason: " + e.getMessage());
}
}
}