ToddFrankson 8 Posted February 5 (edited) The title system ist ... Edited February 6 by TBx Changes title. It was really insignificant. Share this post Link to post
Anders Melander 1969 Posted February 5 There's the old TMediaPlayer but AFAIR it's a pain (but possible) to get to work with TStream. A better alternative would be to import the type library for the Windows Media Player ActiveX and use that. https://chapmanworld.com/windows-media-player-in-delphi/ Share this post Link to post
Der schöne Günther 335 Posted February 5 Maybe just a TWebBrowser (preferably using the Edge/WebView2 engine) is an option? Share this post Link to post
Rollo62 569 Posted February 6 9 hours ago, Der schöne Günther said: Maybe just a TWebBrowser (preferably using the Edge/WebView2 engine) is an option? This is interesting blog https://blogs.embarcadero.com/execute-scripts-and-view-source-with-tedgebrowser/ Perhaps this might work for showing videos, but there is also the possibility that certain Codecs or Plugins were missing, like HLS (.m3u8) : var HTMLContent: string; begin HTMLContent := '<!DOCTYPE html>' + '<html>' + '<body>' + '<video width="640" height="480" controls>' + //either local file '<source src="file:///C:/Pfad/zum/Video.mp4" type="video/mp4">' + //or stream '<source src="https://example.com/stream.m3u8" type="application/x-mpegURL">' + 'Dein Browser unterstützt das Video-Tag nicht.' + '</video>' + '</body>' + '</html>'; EdgeBrowser1.NavigateToString(HTMLContent); end; For accessing local files, there could be the need to add AdditionalBrowserArgument flags https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/working-with-local-content?tabs=dotnetcsharp#loading-local-content-by-navigating-to-a-file-url https://docwiki.embarcadero.com/Libraries/Athens//de/Vcl.Edge.TCustomEdgeBrowser.AdditionalBrowserArguments Share this post Link to post
Lars Fosdal 1848 Posted February 6 @ToddFrankson Pls change title of topic from "Does anyone know of...." to "Play a video from a stream". Descriptive topic titles help users with finding relevant posts. 1 Share this post Link to post
Attila Kovacs 652 Posted February 6 4 minutes ago, Lars Fosdal said: Pls change title of topic from "Does anyone know of...." to "Play a video from a stream". ?!? How can you change the title? Share this post Link to post
ToddFrankson 8 Posted February 6 4 hours ago, Lars Fosdal said: @ToddFrankson Pls change title of topic from "Does anyone know of...." to "Play a video from a stream". Descriptive topic titles help users with finding relevant posts. I was attempting to lure people in with curiosity.... Share this post Link to post
ToddFrankson 8 Posted February 6 15 hours ago, Anders Melander said: There's the old TMediaPlayer but AFAIR it's a pain (but possible) to get to work with TStream. A better alternative would be to import the type library for the Windows Media Player ActiveX and use that. https://chapmanworld.com/windows-media-player-in-delphi/ Neither currently allows a stream outside of a server side video..... 5 hours ago, Rollo62 said: This is interesting blog https://blogs.embarcadero.com/execute-scripts-and-view-source-with-tedgebrowser/ Perhaps this might work for showing videos, but there is also the possibility that certain Codecs or Plugins were missing, like HLS (.m3u8) : var HTMLContent: string; begin HTMLContent := '<!DOCTYPE html>' + '<html>' + '<body>' + '<video width="640" height="480" controls>' + //either local file '<source src="file:///C:/Pfad/zum/Video.mp4" type="video/mp4">' + //or stream '<source src="https://example.com/stream.m3u8" type="application/x-mpegURL">' + 'Dein Browser unterstützt das Video-Tag nicht.' + '</video>' + '</body>' + '</html>'; EdgeBrowser1.NavigateToString(HTMLContent); end; For accessing local files, there could be the need to add AdditionalBrowserArgument flags https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/working-with-local-content?tabs=dotnetcsharp#loading-local-content-by-navigating-to-a-file-url https://docwiki.embarcadero.com/Libraries/Athens//de/Vcl.Edge.TCustomEdgeBrowser.AdditionalBrowserArguments I need the ability to do this locally, without any file. For example, the same way you can load an image from a stream. The videos are small and are stored as proprietary objects. They are extracted to a MemoryStream. To play them I currently have to write them to a file (Memorystream.savetofile) and then load them in a player (WindowsMediaPlayer.URL). I'm looking for something to cut out the write to file Share this post Link to post
Patrick PREMARTIN 121 Posted February 6 Hi You can use FFmpeg (perhaps with http://www.delphiffmpeg.com/) or VLC (check https://github.com/HemulGM repositories) if you want. Boian Mitov has a video stream player in his components packs (https://mitov.com/products/videolab). Share this post Link to post
DelphiUdIT 224 Posted February 6 You can try also with https://prog.olsztyn.pl/paslibvlc/ It has the ability to play stream audio and video, but you need VLC installed on system. Share this post Link to post
Anders Melander 1969 Posted February 6 (edited) 4 hours ago, ToddFrankson said: Neither currently allows a stream outside of a server side video..... I have some code that I use in my resource editor to display video from a memory stream, so it's definitely possible. I just looked and it's about 500-600 lines of code and involves a custom I/O handler among other horrors. Here's a screenshot: And here's a video: Hmm. Never mind with the video. I can't figure out how to create a video this forum supports. Edited February 6 by Anders Melander Share this post Link to post
ToddFrankson 8 Posted February 6 55 minutes ago, Anders Melander said: I have some code that I use in my resource editor to display video from a memory stream, so it's definitely possible. I just looked and it's about 500-600 lines of code and involves a custom I/O handler among other horrors. Here's a screenshot: And here's a video: Hmm. Never mind with the video. I can't figure out how to create a video this forum supports. Do you have it available somewhere so I can at least take a look? Share this post Link to post
Anders Melander 1969 Posted February 6 6 minutes ago, ToddFrankson said: Do you have it available somewhere so I can at least take a look? The application is closed source but I have attached the relevant unit (and one dependency). There are a lot of unrelated dependencies in that unit, since it is a part of a large resource editor framework, so unfortunately it's not as readable as it could be. The unit implements a viewer for video and sound media resources. amResourceViewMedia.pas amResourceViewMedia.dfm VFW.pas 1 Share this post Link to post
Anders Melander 1969 Posted February 6 Another option is to use DirectShow. I know that can also be made to load from a stream. Google "Delphi DirectShow" Share this post Link to post
Yaron 60 Posted February 20 You can do this using DirectShow, but as far as I know, there is no DirectShow filter (component) that can load from a TStream, you would have to write one yourself or use an AI to write one for you. I believe there are sources for the "File Source Async" DirectShow filter, you can use that as a base, replacing the disk IO with TStream commands. But it will be much easier to write the stream to a file in a temp folder and then play it. Share this post Link to post
ToddFrankson 8 Posted February 20 I broke down and went with http://www.delphiffmpeg.com/ Awesome stuff, even though its got a few minor bugs and some older code (Also compatible back to D7). 1 Share this post Link to post
Wak 1 Posted April 8 Gabriel Corneanu wrote a DirectShow filter for this purpose: https://cc.embarcadero.com/Item/21110 Back in the day, I modified it and successfully got it running with DirectShow9 and Delphi 2009. I used it to play encrypted videos, decrypting them on-the-fly. With the codecs installed, it plays avi, mpeg, mkv, ogg, rmvb, mp4... Playing wmv videos requires some tricks. The catch: DirectShow9 seems to briefly load the whole video into memory, so it cannot play large videos (like 1GB). Share this post Link to post
Tom F 85 Posted April 8 Mitov's VideoLab will do this. It comes with sample projects that show how to do this with just a few lines of code. We've used his tools for 15 years. His libraries are unbelievably powerful. And GREAT support. Share this post Link to post
ToddFrankson 8 Posted April 8 52 minutes ago, Tom F said: Mitov's VideoLab will do this. It comes with sample projects that show how to do this with just a few lines of code. We've used his tools for 15 years. His libraries are unbelievably powerful. And GREAT support. I've been working with him to get them up and running. Haven't had the time to get back with him 1 Share this post Link to post
Tom F 85 Posted April 8 If you haven't tried his demo projects yet, I've attached a screen recording I just made that shows to do a simple playback with Mitov's VideoLab. It literally couldn't be easier! Although I show a no-code example here, you can definitely add code using the extensive flexibility he provides. One especially important thing when implementing any video application is to keep your app responsive. Mitov has done a wonderful job using threads to keep apps responsive. And he provides hooks where your app can get access to the video frames in real-time if you want to examine them, etc. MitovVideoDemo.mp4 Share this post Link to post