c# - FFplay successfully moved inside my Winform, how to set it borderless? -
with code: show tcp video stream (from ffplay / ffmpeg) in c# application
i grabbed ffmpeg output inside c# winform. changing args possible play video directly (without streaming)... here complete (short) code:
using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; using system.diagnostics; using system.threading; using system.io; using system.reflection; using system.runtime.interopservices; using system.drawing.text; using system.text.regularexpressions; using system.configuration; using microsoft.win32; using system.windows.forms.visualstyles; namespace xffplay { public partial class form1 : form { [dllimport("user32.dll", setlasterror = true)] private static extern bool movewindow(intptr hwnd, int x, int y, int nwidth, int nheight, bool brepaint); [dllimport("user32.dll")] private static extern intptr setparent(intptr hwndchild, intptr hwndnewparent); //process ffplay = null; public form1() { initializecomponent(); application.enablevisualstyles(); this.doublebuffered = true; } public process ffplay = new process(); private void xxxffplay() { // start ffplay /*var ffplay = new process { startinfo = { filename = "ffplay.exe", arguments = "revenge.mp4", // hides command window createnowindow = true, // redirect input, output, , error streams.. //redirectstandarderror = true, redirectstandardoutput = true, useshellexecute = false } }; * */ //public process ffplay = new process(); ffplay.startinfo.filename = "ffplay.exe"; ffplay.startinfo.arguments = "revenge.mp4"; ffplay.startinfo.createnowindow = true; ffplay.startinfo.redirectstandardoutput = true; ffplay.startinfo.useshellexecute = false; ffplay.enableraisingevents = true; ffplay.outputdatareceived += (o, e) => debug.writeline(e.data ?? "null", "ffplay"); ffplay.errordatareceived += (o, e) => debug.writeline(e.data ?? "null", "ffplay"); ffplay.exited += (o, e) => debug.writeline("exited", "ffplay"); ffplay.start(); thread.sleep(500); // need wait/check process started, then... // child, new parent // make 'this' parent of ffmpeg (presuming in scope of form or control) setparent(ffplay.mainwindowhandle, this.handle); // window, x, y, width, height, repaint // move ffplayer window top-left corner , set size 320x280 movewindow(ffplay.mainwindowhandle, 0, 0, 320, 280, true); } private void button1_click(object sender, eventargs e) { xxxffplay(); } private void form1_formclosed(object sender, formclosedeventargs e) { try { ffplay.kill(); } catch { } } } }
unfortunately ffmpeg output standard bordertype need have borderless or, @ least, without title bar , minimize/maximize/close button.
i don't know handles can see have complete handle window:
movewindow(ffplay.mainwindowhandle, 0, 0, 320, 280, true);
well, there easy way remove ffplay borders?
thanks patience, moved mplayer (super-easy encapsulate inside winforms) because seem less compatible files...
edit: allready checked ffplay options there not 'borderless' one.
ffplay
allows borderless windows -noborder
option (as of commit 15d7e31).
Comments
Post a Comment