Code Monkey home page Code Monkey logo

simplerecorder's People

Contributors

lyalindotcom avatar marcant01 avatar robmikh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simplerecorder's Issues

Encoder exception

Some users have this issues with the encoder, it is present also in my fork, if you want I can send you error details from AppCenter via mail.
Users that have this kind of issue can never record the screen (apps are fine)
image

Can you add "Pause/Resume" code in the project

Hi, I'm trying to create a similar screen recorder uwp app for internal use. Your project given me a good demo about how to capture the screen video to a file. I'm wondering can you show me how to "pause/resume" the recording process?
Thanks!

Crashing on video saving

Hi There!

Love your app! But today it starts crashing.

As soon as I click on the Save button, the program closes and an empty file is saved where its supposed to be the video file.

Is there a log anywhere to troubleshoot?

Thanks

Clear the texture used for encoding instead of hoarding a blank texture

Looking back at this code... I'm not sure why I'm using CopyResource instead of a clear. Hell, the blank texture is made blank using a clear!

Definitely should revisit this. This pattern propagated to a few other of my projects too, without thinking (the gif encoders and ffmpeg demo come to mind).

Audio recording

Are you considering the possibility to record audio along with the video? Is that allowed by the APIs you use

audio recording?

Is it possible to record the audio output as well? Could it be added as a feature?

1280x720 resolution issues

Heya,

After the latest (28.08) update the 1280x720 resolution started to produce distorted output.

  1. The app captures a lot less area than it should (both in window and screen mode). It looks like for FHD screen it captures a fraction of it (720/1080).
  2. The colors are well distorted. Some encoding issues?
  3. The sharpness is way off

Changing the bitrate doesn't help. Other resolutions are perfectly OK, but I'm not using them on day-to-day basis (I need smallest file size and 720p is a good choice for me).

Output video for 720p/9mbps/30fps in the zip attached.

Cheers & keep up the good work!

capture.zip

Provide about/info button

Provide an about/info button so that users can be lead back to the source code of the sample. Consider placing some diagnostics here too.

Use without GraphicsCapturePicker

Can we use this without calling GraphicsCapturePicker? What if I want create desktop streaming application, so that the client could connect to host and begin streaming whole screen without the need of calling GraphicsCapturePicker on the host? I see there is CreateForMonitor function in Win32 version of screen capture.

Option to disable upscaling (?)

When I select a certain resolution and record a small window it ends up having the same resolution of the full screen, I suppose a kind of upscaling is performed. Is there a way to disable it and keep the original window resolution? On high res displays (such as 5k) this seems to affect the recording smoothness.

Encoding doesn't stop after failure

Repro steps:

  1. Set a resolution higher than the one in your screen keeping the checkbox disabled;
  2. Select windows recording.

The window still has yellow borders
image

Help on Screen Recording

i am new to windows apps i am working on a screen recorder and i need some help. im using winui3.

  1. Whats the difference between mainwindow and mainpage should i use window or Page in my mainwinodw.xaml file.

  2. So i figured out how to get frames from this project
    `public sealed partial class MainWindow : Window
    {

     private SizeInt32 _lastSize;
     private GraphicsCaptureItem _item;
     private Direct3D11CaptureFramePool _framePool;
     private GraphicsCaptureSession _session;
    
     // Non-API related members.
     private CanvasDevice _canvasDevice;
     private CompositionGraphicsDevice _compositionGraphicsDevice;
     private Compositor _compositor;
     private CompositionDrawingSurface _surface;
     private CanvasBitmap _currentFrame;
     private string _screenshotFilename = "test.png";
     private AppWindow m_AppWindow;
    
     public MainWindow()
     {
    
         this.InitializeComponent();
    
         m_AppWindow = GetAppWindowForCurrentWindow();
         m_AppWindow.Title = "Test";
         m_AppWindow.SetIcon("C:\\Users\\name\\OneDrive\\Pictures\\zup.0849b3176cec0e8f7fe3.ico");
    
         var titleBar = m_AppWindow.TitleBar;
         titleBar.BackgroundColor = Colors.Purple;
         titleBar.ForegroundColor = Colors.Purple;
         titleBar.InactiveBackgroundColor = Colors.Purple;
         titleBar.InactiveForegroundColor = Colors.Purple;
         titleBar.ButtonForegroundColor = Colors.Orange;
         titleBar.ButtonBackgroundColor = Colors.Purple;
         titleBar.ButtonInactiveForegroundColor = Colors.Orange;
         titleBar.ButtonInactiveBackgroundColor = Colors.Purple;
     }
    
     private AppWindow GetAppWindowForCurrentWindow()
     {
         IntPtr hWnd = WindowNative.GetWindowHandle(this);
         WindowId wndId = Win32Interop.GetWindowIdFromWindow(hWnd);
         return AppWindow.GetFromWindowId(wndId);
     }
    
     private async void myButton_Click(object sender, RoutedEventArgs e)
     {
         await StartCaptureAsync();
    
     }
    
     public async Task StartCaptureAsync()
     {
         // The GraphicsCapturePicker follows the same pattern the
         // file pickers do.
         var hWnd = await Task.Run(() => WinRT.Interop.WindowNative.GetWindowHandle(this));
         var picker = new GraphicsCapturePicker();
         InitializeWithWindow.Initialize(picker, hWnd);
         GraphicsCaptureItem item = await picker.PickSingleItemAsync();
    
    
         // The item may be null if the user dismissed the
         // control without making a selection or hit Cancel.
         if (item != null)
         {
             Debug.WriteLine(item.DisplayName);
             StartCaptureInternal(item);
         }
    
     }
    
    
     private void Stop(object sender, RoutedEventArgs e)
     {
         StopCapture();
     }
    
    
         public void StartCaptureInternal(GraphicsCaptureItem item)
     {
         _canvasDevice = new CanvasDevice();
         _item = item;
         _lastSize = _item.Size;
         int i = 1;
         _framePool = Direct3D11CaptureFramePool.Create(
             _canvasDevice, // D3D device
             Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized, // Pixel format
             60, // Number of frames
             _item.Size); // Size of the buffers
         Debug.WriteLine(i);
    
         _framePool.FrameArrived += (s, a) =>
         {
             // The FrameArrived event is raised for every frame on the thread
             // that created the Direct3D11CaptureFramePool. This means we
             // don't have to do a null-check here, as we know we're the only
             // one dequeueing frames in our application.  
    
             // NOTE: Disposing the frame retires it and returns  
             // the buffer to the pool.
    
             using (var frame = _framePool.TryGetNextFrame())
             {
                 ProcessFrame(frame);
                 i++;
                 Debug.WriteLine(i);
                 Debug.WriteLine(frame.GetType().Name);
                 
             }
         };
    
         _item.Closed += (s, a) =>
         {
             StopCapture();
         };
    
         _session = _framePool.CreateCaptureSession(_item);
         _session.StartCapture();
     }
    
    
    
     public void StopCapture()
     {
         _session?.Dispose();
         _framePool?.Dispose();
         _item = null;
         _session = null;
         _framePool = null;
     }
    
    
     private void ProcessFrame(Direct3D11CaptureFrame frame)
     {
         // Resize and device-lost leverage the same function on the
         // Direct3D11CaptureFramePool. Refactoring it this way avoids
         // throwing in the catch block below (device creation could always
         // fail) along with ensuring that resize completes successfully and
         // isn’t vulnerable to device-lost.
         bool needsReset = false;
         bool recreateDevice = false;
    
         if ((frame.ContentSize.Width != _lastSize.Width) ||
             (frame.ContentSize.Height != _lastSize.Height))
         {
    
             needsReset = true;
             _lastSize = frame.ContentSize;
         }
    
         try
         {
             // Take the D3D11 surface and draw it into a  
             // Composition surface.
    
             // Convert our D3D11 surface into a Win2D object.
             CanvasBitmap canvasBitmap = CanvasBitmap.CreateFromDirect3D11Surface(
                 _canvasDevice,
                 frame.Surface);
    
             _currentFrame = canvasBitmap;
    
             // Helper that handles the drawing for us.
             //FillSurfaceWithBitmap(canvasBitmap);
         }
    
         // This is the device-lost convention for Win2D.
         catch (Exception e) when (_canvasDevice.IsDeviceLost(e.HResult))
         {
             // We lost our graphics device. Recreate it and reset
             // our Direct3D11CaptureFramePool.  
             needsReset = true;
             recreateDevice = true;
         }
    
         if (needsReset)
         {
             ResetFramePool(frame.ContentSize, recreateDevice);
         }
     }
    
    
    
     private void ResetFramePool(SizeInt32 size, bool recreateDevice)
     {
         do
         {
             try
             {
                 if (recreateDevice)
                 {
                     _canvasDevice = new CanvasDevice();
                 }
    
                 _framePool.Recreate(
                     _canvasDevice,
                     Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized,
                     2,
                     size);
             }
             // This is the device-lost convention for Win2D.
             catch (Exception e) when (_canvasDevice.IsDeviceLost(e.HResult))
             {
                 _canvasDevice = null;
                 recreateDevice = true;
             }
         } while (_canvasDevice == null);
     }`
    

Up till here everything is working how do i display the frames on my ui page?
This is my UI
`

        <Button x:Name="CaptureButton" Grid.Row="2" Margin="300" HorizontalAlignment="Left" VerticalAlignment="Center" Click="myButton_Click" Background="Black">
                <!--<FontIcon Glyph="&#x25B6;" FontFamily="Segoe UI Emoji" FontSize="24"  />-->
                Capture
        </Button>
        
        <Button x:Name="StopButton" Grid.Row="2" Margin="300" HorizontalAlignment="Right" VerticalAlignment="Center" Click="Stop" Background="Black">
            <!--<FontIcon Glyph="&#x1F6D1;" FontFamily="Segoe UI Emoji" FontSize="24"  />-->
            STOP
        </Button>
        <CheckBox Margin="300 100 0 0" >Check this to display mouse</CheckBox>

`
Please help me im barely understanding what im doing.

Does MediaTranscoder not apply any compression/frame diffing for MP4 profiles?

Hey, Robert.

First, thanks for all your example projects. They've been really helpful!

I can't seem to find an answer anywhere about this, so maybe you can help me. I'm considering using the MediaTranscoding APIs for screen recording/screen sharing purposes, but I'm noticing that the MP4 encoding profile doesn't appear to do any compression or frame diffing.

For example, if I use this project to record a window that has no changes occurring, the file size continues increasing linearly with the length of the video. A 10-second video with no visual changes ends up being about 20 MB.

However, if I use WMV format, the resulting file is about 1.5MB. This is about the size I'd expect from either format after diffing/compression is applied (e.g. about the size of a screenshot).

Is this expected behavior for MP4? Am I missing something?

Thanks! :)

Missing definitions

Hi, I'm trying to build this project from source in VS 2017 on Windows 10 Build 19042.928.

However when I build the solution, the compile complaints about 2 missing definitions:

  1. Missing definition of CreateFreeThreaded in Direct3D11CaptureFramePool
  2. Missing definition of CreateFromDirect3D11Surface in MediaStreamSample

Does someone have an idea why these definitions might be missing? Is a certain directX version required?

Best
Maurice

When monitor/window is selected, it would be a good idea to see its current pixel dimensions

The rationale is this, for example I would like to record 1280x720 clip so I am also interested to have the window of the same size or maybe a multiple. One way is to maybe put a button and offer a resize of the target window to the desired resolution, but I realize it might be tricky in certain aspects like e.g. permissions and UWP app sandbox. So maybe we can at least see current width and height of what will be scaled to target 1280x720 during recording and let user manually size the window to desired matching. This also might apply to aspect ratio (if the app is doing letterboxing in the transcoding session, probably it does not). Or, alternatively maybe one another and good way is to just keep the resolution of original window assuming it won't change or just doing scaling to what we started with.

Latest version started recording with black corner

There seems to be a black pattern that has started to appear when I reinstalled this app.

image

The pattern is different
image

Depending on the size of the window.

I am unsure what has changed recently to have caused this? If it was a windows update (Which I am forced to do by my works admin policies)

Cannot stop recording in this scenario

When I select record an app and I minimize it during the recording, once I go back to Simple Screen Recorder I cannot stop it and pressing the button lets me choose whether to record the screen or an app

Properly handle window resize

Currently if the application that is being captured resizes its window, the rest of the buffer will have stale content in it. I'm not sure how to handle that without introducing a copy.

image

Audio recording

The last missing thing to make this software perfect. Recording the system audio of Windows and maybe a microphone.

Can't record Unigram

For some reasons if I use Unigram the app won't record anything, both using screen capture and app one

"Use source size" causes "cannot find an encoder MFT that accepts the ... output type" exception

"Use source size" option causes "cannot find an encoder MFT that accepts the user preferred output type" exception.
Clicking "start recording" after selecting the "use source size" resolution option causes the recording to fail.

Title: Recording failed
Description: Uh-oh! Something went wrong! 0xC00DA412 - Cannot find an encoder MFT that accepts the user preferred output type. (Exception from HRESULT: 0xC00DA412)
image

Monitor resolution: 3840x2160 (just a single monitor)
OS: Windows 11 22000.318
Using latest version available in Microsoft Store (as of writing).

Let me know if you need any additional information.

stream chunk

Hi Rob,
I am wondering if you can guide me to save chunk of stream (let's say each chunk 5 secs). Very simple way would be dispose encoder object at each 5 secs and re-create encoder with new file stream. I am a bit concerned overhead. I wonder if there is way to interrupt PrepareTranscodeResult.

Remove copy code path

Due to a bug in build 17763, buffers from the capture API cannot be directly handed to the Transcoding API. There's currently a workaround to copy the buffer, but I don't think it's correctly synchronized. When the next release ships, remove the workaround and bump the minimum required build.

why not use win2d?

Hi Rob,

It's really sad that Microsoft time and again doesn't believe in its own projects. You have an awesome lib (win2d), yet you use sharpDX.

Frankly, I would not have minded, but nothing works -- I'm trying to capture Thunderbird or notepad++ (just for testing, of course), and the end result is some part of the title. It seems to work fine 1 out of 10 times. This is completely unuseable code to me.

I can't bear to learn yet another library just for this.

audio???

Why the f*** doesn't it record audio 🤷‍♂️

Recording sound

This is more a feature request than an issue but it would be really great to have an option to record sound too..

P.S. I know it pops up few times already but was curious about the status.

Obtain raw pixels / bitmap for each frame?

Hi Rob,

I just found this recorder sample app and thought it was a promising solution for what I'm trying to do. I want to be able to "record" my application and stream the recorded frames over NDI to a Tricaster hardware. All I need for that is to have a bitmap (or just raw pixels I guess) of each frame of the recording, in real-time (near 60 FPS if possible).

This sample is able to record a video of my app at 60 FPS easily, but I struggle to convert it to my use-case where I need the individual frames (as bitmaps / pixels) in real-time.

Would it be possible to grab each frame in real-time and somehow get the pixels in some format that I can use? I am not interested in storing a video, or even an image file, I just need to have the pixels so I can stream them over NDI.

Global D3D device

Move to a global D3D device, we end up creating a new one when going back to the MainPage.

Handle device lost

The application should either end the current recording or properly recover from losing the D3D device.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.