polarby / render

A package to render any native static and moving flutter widgets to exportable formats
https://pub.dev/packages/render
MIT License
49 stars 26 forks source link

Video recorded it's very laggy #28

Open NachoL24 opened 7 months ago

NachoL24 commented 7 months ago

Describe the bug i tried to use render to record the camera preview of the dependecy camera with a timer on the screen, at recording it looks normal, but when the video is playing it looks realy laggy, like 1 or 2 frames per seconds. (i modifyed the frames to 60 and the handlers i tried to do it with many or few.)

if you want to look at my code to see if there it's a problem with it: https://github.com/NachoL24/videoapp/blob/main/lib/examples/camera_screen.dart i used recordMotion and stopController.stop() in the _recordVideo() function.

Anyway, if someone has an opinion of a diferent way that i could do this or a way to improve my code or if you want to know more about the app i'm coding contact me at: ignaciolances24@gmail.com

Platform (please complete the following information): render: ^0.1.3+1

Hetal9Brainz commented 4 months ago

@NachoL24 Facing same issue. Did you get any solution?

Near0ne commented 4 months ago

@NachoL24 Thought I set bad settings but glad (or not) that i'm not the only one. Would look forward a solution too please if any have.

polarby commented 4 months ago

This is just a shot in the dark: but I believe the camera plugin may use a native displaying technique (based on Android, iOS, web, etc.). It is a known bug that such native views are usually not possible to capture with rendering of flutter widgets.

You can refer to other screen capturing plugins that have tried (and failed) to target this.

Please refer to #4

Or in the docs of the screenshot package:

Known Issues

Platform Views are not supported. (Example: Google Maps, Camera etc)issue

marvin-kolja commented 4 months ago

@NachoL24 How many times does your widgets re-render inside the Render widget? It seems that you're using different timers, e.g. the countdown one only updates every second. I found that when using recordMotion and there are no updates in the widget tree this package does not add a new image. For example if you use the example of this package and remove the AnimationController the video won't be recorded. It might be that the camera playback doesn't cause new renders/frames? I'd try to add a container near the top of the Render that is forced to re-render every 1000/framrate ms.

Maybe I'm missing something here and the issue here is unrelated to what I'm saying, what would you say @polarby?

EDIT: I didn't have much time to write this, so please excuse any technical inaccuracies

Near0ne commented 4 months ago

@polarby In my case, i'm trying to record a widget that contains a video player, any idea ? Btw, I take the opportunity thank you for the package

EDIT: Like, I'm using directly the videoplayer widget into render, using an animation controller like you do in your example

marvin-kolja commented 4 months ago

@polarby In my case, i'm trying to record a widget that contains a video player, any idea ?

When you say you use the video player directly in the render widget, does that mean there is no other child? Thus, the animation controller is animating something that isn't a child of the render widget?

marvin-kolja commented 4 months ago

@polarby Image we capture something for 10 seconds, but only 10 frames are rendered. Each frame will then be "stretched" to one second. Here is an example of this happening. Only the 11 first frames are captured after that nothing changes in the RepaintBoundary, thus, the addPostFrameCallback won't be triggered. This leads to a "laggy" video or rather a video where the actions performed are not in it's correct timeline.

https://github.com/polarby/render/assets/54174311/a58d1857-f03d-4aa9-bbd6-b0af36b6b046

As the VideoPlayer does not re-render it might make sense to add a disclaimer to the documentation, with a proposed workaround. In any case, maybe we could store the information on how long a frame was still and use a ffmpeg command such as ffmpeg -framerate {framerate} -loop 1 -t {duration} -i {img} {img[:-4]}.mp4 when a frame is still and then concat these videos together. There's probably a better solution though.

Greek-Cp commented 4 months ago

yes i have issue also, when i'm try to render my videoplayer and subtitle(widget subtitle animation) i'm got result output lag