Click here to Skip to main content
11,411,241 members (64,984 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# Video
public void JoiningVideo()
    string j = @"D:/test2";
    string outputpath = @"D:/test3/beforeEventab1.wmv";
    DirectoryInfo di = new DirectoryInfo(j);
    FileStream fs;
    fs = new FileStream(outputpath, FileMode.Append);
    foreach (FileInfo fi in di.GetFiles(@"*.wmv"))
        byte[] bytesource = System.IO.File.ReadAllBytes(fi.FullName);
        fs.Write(bytesource, 0, bytesource.Length);

This following is a code to join two videos. When I run the program it joins two videos and puts joined video in a folder. The joined video size is correct as it should be.

But when I play the video it plays the first part of the video in WMP but when i play the video in VLC it plays the second part of video.
Posted 5-Feb-13 22:00pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You can't just bolt two files together and expect them to magically work out how to reorganise themselves!

Video files are complex objects, with multiple streams inside - to join two videos, you need to append the video streams together, and append the audio stream together separately. What you have done is weld a car onto the front of your existing car and expect it to magically become a stretched limousine!

If you want to join videos, then look at VirtualDubMod - it's open source (it doesn't join files very well but you can get the source). I use AviDemux[^] when I want to - it's source isn't available, but it's free and does a pretty good job.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 189
1 Maciej Los 108
2 OriginalGriff 88
3 Sascha Lefévre 85
4 BillWoodruff 80
0 Sergey Alexandrovich Kryukov 8,920
1 OriginalGriff 6,918
2 Maciej Los 3,390
3 Abhinav S 3,248
4 Peter Leow 3,059

Advertise | Privacy | Mobile
Web01 | 2.8.150414.5 | Last Updated 6 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100