WyattBlue / auto-editor

Auto-Editor: Efficient media analysis and rendering
https://auto-editor.com
The Unlicense
2.88k stars 420 forks source link

Make output available while rendering #408

Closed flt6 closed 5 months ago

flt6 commented 10 months ago

Want

Make a link to the rendering video file, and render the video with the audio in spedup0.mp4. So user can watch the video real time, since encode speed is always more than 1x.

Details

Auto-editor is also useful when watching online class for students, since some teacher used to have a lot of meaningless silence in their class (I tried analysis 1 example, and found about 40% is silence.) However, I do not want to wait until all the video is rendered.

Implementation example

An simple example for implementation(haven't take some feathers into consideration, only to explain what I need Replace cmd of https://github.com/WyattBlue/auto-editor/blob/7148db67fc5279f37321931dc1032947b29aec66/auto_editor/render/video.py#L129-L146 to

  cmd = [
        "-hide_banner",
        "-y",
        "-f",
        "rawvideo",
        "-c:v",
        "rawvideo",
        "-pix_fmt",
        target_pix_fmt,
        "-s",
        f"{width}*{height}",
        "-framerate",
        f"{tl.tb}",
        "-i",
        "-",
        "-i",
        os.path.join(temp, "new0.wav"),
        "-map",
        "0:v",
        "-pix_fmt",
        target_pix_fmt,
        "-map",
        "1:a",
    ]

and replace https://github.com/WyattBlue/auto-editor/blob/7148db67fc5279f37321931dc1032947b29aec66/auto_editor/render/video.py#L127 to

spedup = os.path.join(temp, "spedup0.ts")

And you can view the video real time in the TEMP dir, with only part argument are supported. For example: auto-editor example.mp4

WyattBlue commented 5 months ago

This is possible, but in order to do this, I would need to abandon the ffmpeg cli and rely on using the PyAV exclusively. There's nothing wrong with this. I'm a core PyAV maintainer after all, but rewriting all the rendering methods in auto-editor is very involved on my end. I'll circle back on this later when I got the time+motivation.