directshow.net


text overlay issue?


by using directshow.net i can able to record the video and with recording i am doing text overlay for this i configured sample grabber and in buffercb method i am working on frames here is the code..
int ISampleGrabberCB.BufferCB(double SampleTime, IntPtr pBuffer, int BufferLen)
{
Graphics g;
String s;
float sLeft;
float sTop;
SizeF d;
g = Graphics.FromImage(bitmapOverlay);
g.Clear(System.Drawing.Color.Transparent);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
// Prepare to put the specified string on the image
g.DrawRectangle(System.Drawing.Pens.Transparent, 0, 0, 240 - 1, 176 - 1);
g.DrawRectangle(System.Drawing.Pens.Transparent, 1, 1, 240 - 3, 176 - 3);
d = g.MeasureString(m_String + "\n" + DateTime.Now.ToString("G"), fontOverlay);
sLeft = (240 - d.Width) / 2;
sTop = (176 - d.Height) / 2;
g.DrawString(m_String + "\n" + DateTime.Now.ToString("G"), fontOverlay, System.Drawing.Brushes.Black,
sLeft, sTop, System.Drawing.StringFormat.GenericTypographic);
// need to flip the bitmap so it's the same orientation as the
// video buffer
bitmapOverlay.RotateFlip(RotateFlipType.RotateNoneFlipY);
// create and copy the video's buffer image to a bitmap
Bitmap v;
v = new Bitmap(240, 176, 1056,
PixelFormat.Format24bppRgb, pBuffer);
g = Graphics.FromImage(v);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
// draw the overlay bitmap over the video's bitmap
g.DrawImage(bitmapOverlay, 0, 0, bitmapOverlay.Width, bitmapOverlay.Height);
// dispose of the various objects
g.Dispose();
v.Dispose();
// Increment frame number. Done this way, frame are zero indexed.
m_Count++;
return 0;
}
my problem is,when i start program it shows me text overlay in preview window but when i open recorded file text overlay is not continues..i think i am missing some frames..on some frames overlay is their but its not continues..its flicking.
can any one help?
ok i got the problem!!
in the above code,BufferCB takes too long time to process the current video frame.its like let frame A is still in middle process before process complete frame B comes in.
so to minimize the processing in BufferCB i have remove the where bitmap image is set
this line of code i put into an function
g = Graphics.FromImage(bitmapOverlay);
g.Clear(System.Drawing.Color.Transparent);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
// Prepare to put the specified string on the image
g.DrawRectangle(System.Drawing.Pens.Transparent, 0, 0, 240 - 1, 176 - 1);
g.DrawRectangle(System.Drawing.Pens.Transparent, 1, 1, 240 - 3, 176 - 3);
d = g.MeasureString(m_String + "\n" + DateTime.Now.ToString("G"), fontOverlay);
sLeft = (240 - d.Width) / 2;
sTop = (176 - d.Height) / 2;
g.DrawString(m_String + "\n" + DateTime.Now.ToString("G"), fontOverlay, System.Drawing.Brushes.Black,
sLeft, sTop, System.Drawing.StringFormat.GenericTypographic);
// need to flip the bitmap so it's the same orientation as the
// video buffer
bitmapOverlay.RotateFlip(RotateFlipType.RotateNoneFlipY);
and this function is called before media.run is called.

Related Links

text overlay issue?
Chaining Shader Effects
MP4 Fast Forward/Rewind
Can I get timecode from directshow video?
Use specific codec or ffdshow folder with DirectShowLib?
File writer filter creating a bigger AVI file then original

Categories

HOME
cocoapods
nam
android-fragments
kendo-dropdown
paypal-ipn
compilation
braintree
risk-management
visual-studio-2010
mirc
dependencies
minecraft
phpseclib
polymer-2.x
scrape
watch-os-3
responsivevoice
grocery-crud
createjs
pushdown-automaton
bundler
asp.net-core-1.0
varnish-vcl
string-formatting
xsl-fo
bluemix-mobile-services
connection-refused
acl
restier
beego
uilocalnotification
sendmessage
laravel-4.2
sales
windows2012
sca
ms-media-foundation
landscape
aurelia-http-client
rdp
assemblies
oauth2
netapp
get-event-store
word-cloud
dbcc
web-inspector
expandablelistview
apache-toree
uiautomatorviewer
watir-webdriver
.when
mpmovieplayercontroller
rustdoc
ndk-build
django-testing
seccomp
callouts
conan
nsdata
groovyfx
static-methods
ajaxmin
utf-16
accessibilityservice
vimperator
wif4.5
phpquery
largenumber
dsa
pythonxy
knife
css-paged-media
wso2ml
com0com
quercus
maven-shade-plugin
configurable-product
cout
xml-signature
property-injection
windows-taskbar
application-blocks
stty
google-code-prettify
node.js-stream
ckeditor.net
linkbutton
popup-blocker
sfinae
image-formats
dropshadow
gwt-celltable
vows
startupscript
firephp
fxruby
external-sorting
icon-language
isapi-redirect
levels
regioninfo
webclient.uploaddata

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App