Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video save to a variable name. Video Combine #363

Open
akshatd007 opened this issue Jan 23, 2025 · 1 comment
Open

Video save to a variable name. Video Combine #363

akshatd007 opened this issue Jan 23, 2025 · 1 comment

Comments

@akshatd007
Copy link

Hey,

So I went through the Video Combine node and in the function, it seems to save the first frame of the video and then sequentially saves the rest of the frames (as far as I understood).

I dont want to save the video, however I want to have the video stored in a variable lets say "final_video" .

vhs_videocombine.combine_video( frame_rate=24, loop_count=0, filename_prefix="cosmos_video", format="video/h264-mp4", pix_fmt="yuv420p", crf=19, save_metadata=False, trim_to_audio=False, pingpong=False, save_output=True, images=get_value_at_index(vaedecode_8, 0), unique_id=2751779949773341927, )

How may I do that. Is it possible? Thank you

@AustinMroz
Copy link
Collaborator

As in, you want a variable that contains the binary data of the output video? The best you could do without making heavy handed changes to the VHS code is to save the output to a temporary location (save_output=False), then read the output file into a variable yourself.

file = vhs.videocombine.combine_video(...)['result'][0][1][-1]
with open(file, 'rb') as f:
    data = f.read()

If temp files are not an option, the required changes would be out of scope for VHS, but to provide some rough guidance, you'd need to:

  • Change the output path for the ffmpeg subprocess to stdout (-), and manually specify the container format, i.e -f webm
  • Modify the subprocess to capture stdout
  • Either continually collect the from stdout pipe, or revert to the older non-streaming (subprocess.run) code, see commit c5de20d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants