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
amazon-web-services
generics
mpdf
paypal-ipn
couchdb
tcsh
vsts-build
portable-class-library
dependencies
fedora
timber
wine
hystrix
cmake-gui
opam
angular2-highcharts
gitkraken
acl
websphere-portal
react-dnd
data-collection
python-imageio
bonita
locks
tightvnc
steam-web-api
snap-framework
image-optimization
adminer
express-session
runtimeexception
text-decorations
iscroll
right-click
jacoco-maven-plugin
cloudera-sentry
robust
optionaldataexception
haar-classifier
expandablelistview
deployd
lightning-workbench
skip-lists
ltrace
kendo-treeview
maatwebsite-excel
nitrousio
ternary-operator
portal
s-function
dcount
mathml
android-sdcard
noclassdeffounderror
timestamping
gwt-syncproxy
as3-api
arbre
apache-commons-digester
bjam
screen-orientation
angular-amd
camus
ildasm
device-admin
iplimage
webautomation
csslint
thruway
windows-taskbar
code39
infinite
apache-shindig
xsd2code
grails-2.3
disjoint-union
arel
jbox2d
proc-open
django-filebrowser
system-requirements
idispatch
live-wallpaper
clearinterval
coordinate
image-scanner
pcspim
n-queens
glx
space-partitioning
page-curl
eaccelerator
uninstaller
fxruby
rakudo
server-load

Resources

Encrypt Message