TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ehtesham Ulla Baig
NA
1
2.6k
Unable to Join WaterMark Video
Jul 27 2010 6:05 AM
I am developing win forms application to split,join,Add watermark(both text and image) to a split video file.i have completed all the above said operations.the problem is when i try to join watermarked videos which i have watermarked with my developed application i get an exception "An invalid Media type was specified" if i try to join the split video without watermark its getting joined without errors.
i am using "DirectShow" for Joining videos
here is the code to join video files
private void FrmVideoJoinStatus_Load(object sender, EventArgs e)
{
LoadList();
try
{
if (ds == null)
{
MyCallback pVideo = new MyCallback(tbVideo, tbTime, tbElapsed, progressBar1);
MyCallback pAudio = new MyCallback(tbAudio);
// FPS, BPP, Width, Height
ds = new DESCombine(30, 24, 1024, 768);
foreach (Chunk c in listBox1.Items)
{
if (c.sVideoFile == c.sAudioFile)
{
ds.AddAVFile(c.sVideoFile, c.lStart, c.lEnd);
}
else
{
if (c.sVideoFile != null)
{
ds.AddVideoFile(c.sVideoFile, c.lStart, c.lEnd);
}
if (c.sAudioFile != null)
{
ds.AddAudioFile(c.sAudioFile, c.lStart, c.lEnd);
}
}
}
IBaseFilter ibfVideoCompressor = GetVideoCompressor(tbCompressor.Text);
ds.RenderToAVI(ClassTransport.FilePath, ibfVideoCompressor, null, pVideo, pAudio);
ds.Completed += new EventHandler(Completed);
ds.FileCompleted += new EventHandler(FileCompleted);
ds.StartRendering();
progressBar1.Maximum = (int)(ds.MediaLength / (DESCombine.UNITS / 10));
progressBar1.Step = progressBar1.Maximum / 20;
progressBar1.Value = 0;
tbStatus.Text = "Running";
}
else
{
ds.Cancel();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
ds.Dispose();
ds = null;
}
}
#region load Videos To list From Table
private void LoadList()
{
DataTable dt = ClassTransport.Table;
foreach (DataRow row in dt.Rows)
{
Chunk c = new Chunk(
row["File"].ToString(),
row["File"].ToString(),
"0",
"-1");
int i = listBox1.Items.Add(c);
listBox1.SelectedIndex = i;
}
}
#endregion
Code for water mark Video
#region WaterMark
[STAThreadAttribute]
private void AddWaterMark(object row)
{
DataRow Drow = (DataRow)(row);
DirectoryInfo info = new DirectoryInfo(Convert.ToString(Drow["FilePath"]));
string[] filename = info.Name.Split('.');
string outputFile = ClassTransport.ClipSavePath + "\\" + filename[0] + "WaterMarked" + info.Extension;
using (ITimeline timeline = new DefaultTimeline(15))
{
timeline.AddAudioGroup().AddTrack();
// add a video group, 32bpp, 320x240 (32bpp required to allow for an alpha channel)
IGroup videoGroup = timeline.AddVideoGroup(32, 720, 480);
// add our default video track
ITrack videoTrack = videoGroup.AddTrack();
// add another video track, this will be used to contain our watermark image
ITrack watermarkTrack = videoGroup.AddTrack();
// add the video in "transitions.wmv" to the first video track, and the audio in "transitions.wmv"
// to the first audio track.
timeline.AddVideoWithAudio(Drow["FilePath"].ToString());
Bitmap image, BImage,TextImage;
image = new Bitmap(int.Parse(ConfigurationSettings.AppSettings["VideoWidth"].ToString()), int.Parse(ConfigurationSettings.AppSettings["VideoHeight"].ToString()));
BImage = new Bitmap(int.Parse(ConfigurationSettings.AppSettings["VideoWidth"].ToString()), int.Parse(ConfigurationSettings.AppSettings["VideoHeight"].ToString()));
TextImage = new Bitmap(int.Parse(ConfigurationSettings.AppSettings["VideoWidth"].ToString()), int.Parse(ConfigurationSettings.AppSettings["VideoHeight"].ToString()));
TextImage = CreateBitmapImage(Drow);
image = CloneImage(TextImage);
//TODO:Adding Logo Call in Form 1
if (Drow["Logo"] != null)
{
BImage = ((Bitmap)Image.FromFile(Drow["Logo"].ToString()));
image = CloneLogoWithImage(BImage, image, Drow);
}
// add the watermark image in, and apply it for the duration of the videoContent
// this image will be stretched to fit the video clip, and in this case is a transparent gif.
IClip watermarkClip = watermarkTrack.AddImage(image, 0, videoTrack.Duration);
// add a alpha setter effect to the image, this will adjust the alpha of the image to be 0.5
// of it's previous value - so the watermark is 50% transparent.
watermarkClip.AddEffect(0, watermarkClip.Duration, StandardEffects.CreateAlphaSetterRamp(((double)Drow["Opacity"])));
// add a transition to the watermark track, this allows the video clip to "shine through" the watermark,
// base on the values present in the alpha channel of the watermark track.
watermarkTrack.AddTransition(0, videoTrack.Duration,
StandardTransitions.CreateKey(KeyTransitionType.Alpha, null, null, null, null, null),
false);
//using (
// render it to windows media
IRenderer renderer = new WindowsMediaRenderer(timeline, outputFile, WindowsMediaProfiles.HighQualityVideo);
// {
using ((System.IDisposable)renderer)
{
renderer.Render();
}
//}
//}
}
Drow["filePath"] = outputFile;
}
#endregion
Please help me if any possible suggestions..thank you
Reply
Answers (
0
)
gettin Button controle through javascript at runtime
What programming languages do you know?