sprockets frosted donut medals buildings Rubik's Cube Nidaros Cathedral Tongue Sandwich A:M Composite
sprockets
Recent Posts | Unread Content | Previous Banner Topics
Jump to content
Hash, Inc. - Animation:Master

All Activity

This stream auto-updates

  1. Today
  2. I've been messing about with a 'watchfolder' script (in python) that monitors a directory and when it finds a new sequence of PNG images it converts the sequence to MP4 video and moves the PNG sequence to a datetime stamped directory inside a 'processed' directory. There are a number of things that are still rough about the program. Firstly, the majority of people will not install python, set it up, run python programs etc. right? Correct. So, I compiled it into an executable .exe file. That seems to work pretty well. The python script has a watchfolder.ini file where users can quickly adjust settings. If no .ini file is found default locations and values are used. [settings] watch_dir = F:/watch_folder ffmpeg_path = ffmpeg framerate = 24 timeout = 5 video_basename = video max_runtime_minutes = 30 reset_timeout_on_video = true Here we can see: - The script uses a specific directory/folder so that's where the PNG sequence would need to be rendered to - The script uses FFMPEG for the conversion and the path here suggests it is in the users environmental settings. Perhaps better to specifically state where the FFMPEG executable files are located. For example: C:/ffmpeg/bin - Framerate can be changed to allow more (or less) frames to be generated. - The timeout is in seconds and suggests how long the utility waits to see if another frame is being generated. If frames are expected to take longer than 5 seconds to render this value should be increased. - The base name of the output video can be changed here (it's just named video by default and new videos get incremented with a number each time a new video is created (video1.mp4, video2.mp4, etc.) - Max runtime (if set) limits how long the watchfolder program will monitor the folder. - The timer for the max runtime can be set to refresh each time a new video is created so a new 30 minute timer starts. Set to false if a reset of the timer is not desired. The actual python script: import os import time import shutil import keyboard import subprocess import re from datetime import datetime import configparser # === DEFAULT CONFIG === DEFAULTS = { "watch_dir": "F:/watch_folder", "ffmpeg_path": "ffmpeg", "framerate": "24", "timeout": "5", "video_basename": "video", "max_runtime_minutes": "0", "reset_timeout_on_video": "false" } INI_FILE = "watchfolder.ini" def load_config(): config = configparser.ConfigParser() if not os.path.exists(INI_FILE): config["settings"] = DEFAULTS with open(INI_FILE, "w") as f: config.write(f) print(f"[i] Created default {INI_FILE}") else: config.read(INI_FILE) for key, val in DEFAULTS.items(): if key not in config["settings"]: config["settings"][key] = val return config["settings"] def get_png_files(watch_dir): return sorted([f for f in os.listdir(watch_dir) if f.lower().endswith('.png')]) def get_next_video_filename(watch_dir, basename): count = 1 while True: candidate = f"{basename}_{count:04d}.mp4" if not os.path.exists(os.path.join(watch_dir, candidate)): return candidate count += 1 def guess_pattern(filename): match = re.search(r"([^.]+)\.(\d+)\.png$", filename) if match: prefix, digits = match.groups() return f"{prefix}.%0{len(digits)}d.png" return None def convert_sequence_to_mp4(watch_dir, first_file, ffmpeg_path, framerate, video_basename): pattern = guess_pattern(first_file) if not pattern: print(f"[!] Could not determine pattern from {first_file}") return output_name = get_next_video_filename(watch_dir, video_basename) output_path = os.path.join(watch_dir, output_name) print(f"[+] Converting to MP4: {output_name}") try: subprocess.run([ ffmpeg_path, "-y", "-framerate", str(framerate), "-i", pattern, "-c:v", "libx264", "-pix_fmt", "yuv420p", output_path ], cwd=watch_dir, check=True) print(f"[✓] Video saved as: {output_name}") except subprocess.CalledProcessError as e: print(f"[!] FFmpeg failed: {e}") def move_sequence_to_archive(watch_dir, png_files): now = datetime.now().strftime("%Y%m%d_%H%M%S") archive_dir = os.path.join(watch_dir, "processed", now) os.makedirs(archive_dir, exist_ok=True) for f in png_files: shutil.move(os.path.join(watch_dir, f), os.path.join(archive_dir, f)) print(f"[→] Moved PNGs to: {archive_dir}") def monitor(settings): watch_dir = settings["watch_dir"] ffmpeg_path = settings["ffmpeg_path"] framerate = int(settings.get("framerate", 24)) timeout = int(settings.get("timeout", 5)) video_basename = settings["video_basename"] max_runtime = int(settings.get("max_runtime_minutes", "0").strip()) * 60 reset_on_video = settings.get("reset_timeout_on_video", "false").lower() == "true" print(f"👁️ Monitoring folder: {watch_dir}") print(f"[i] FFmpeg: {ffmpeg_path}, timeout: {timeout}s, framerate: {framerate}fps") if max_runtime > 0: print(f"[i] Will auto-exit after {max_runtime // 60} minutes (unless reset)") start_time = time.time() previous_files = set(get_png_files(watch_dir)) last_change_time = time.time() while True: # Check for Escape key press if keyboard.is_pressed("esc"): print("[✋] Escape key pressed. Exiting.") break time.sleep(1) # Auto-exit if timer exceeded if max_runtime > 0 and (time.time() - start_time > max_runtime): print("[!] Max runtime reached. Exiting.") break current_files = set(get_png_files(watch_dir)) if current_files != previous_files: previous_files = current_files last_change_time = time.time() continue if current_files and (time.time() - last_change_time > timeout): png_files = sorted(current_files) print(f"[⏳] Sequence complete: {len(png_files)} files") convert_sequence_to_mp4(watch_dir, png_files[0], ffmpeg_path, framerate, video_basename) move_sequence_to_archive(watch_dir, png_files) previous_files = set() last_change_time = time.time() if reset_on_video: print("[i] Timer reset after video creation.") start_time = time.time() print("[✓] Monitoring stopped.") if __name__ == "__main__": try: settings = load_config() monitor(settings) except KeyboardInterrupt: print("\n[✓] Monitoring stopped by user.") My take is that this option for a hotwatch directory and execution of ffmpeg script would be best added to Animation:Master itself but if there is interest we can pursue this and more. This script only converts PNG sequences to MP4 video but all manner of video formats is possible and even gif animation. The utility currently does not have an interface/GUI but that would be a next step that allows the user to adjust settings in the interface and even opt for different outputs. Here's the sequence I was testing with: video_0017.mp4
      • 2
      • Thanks
      • Like
  3. Yesterday
  4. Last week
  5. Ohhhhhh.... you were using Lasso Line mode and I was using Lasso Draw mode! Yeah, I notice now that in v19.5 the Lasso Line mode behaves oddly, although it works correctly in v19.0. Try using the Lasso Draw mode if you are in v19.5 I'll make a bug report.
  6. See attached. All settings reset and perspective is OFF. Ok now for some reason I cannot attach a jpg, is there something funky going on with
  7. Hi Edward... It works OK for me. Try these -make sure you're not in perspective Mode. Numeric Keypad-9 toggles that on and off. -make sure the slash or comma keys are not stuck. -make sure no additional pointing devices are active, like a trackpad or a touch screen. -try a different mouse. -Nuke the whole thing with Help>ResetSettings and restart. Any change?
  8. Just me or did something happen to the Lasso tool? See attached .prj. On my machine no matter how I use the lasso tool it selects all sorts of seemingly random CPs - other than the ones I'm trying to select. Did I activate an unseen "moron mode" somehow? Is it just on my machine? Please see attached .prj and try it - any help appreciated. LassoTest.prj
  9. Thank you rob! Very helpful for what I am trying to do. Apologies for not being able to join as I had something going on today, but this answers my question so thank you once again.
  10. @Andres Trujillo Today at LAT we looked at this task...
  11. that produces the ball of gears?
  12. probe Master_64_BsKEoTxal5.mp4
  13. for example, the same as everywhere else - coordinates, quantity, size
  14. I dusted off A:M the other day just to scratch an itch to create, and 48 hours later I'm still here. Then I notice on the forum a contest happened when I wasn't looking! The entries are amzing, and congratulations to the winners. You all are amazing artists, and I am humbled be your talents.
  15. What would the input parameters be of this device?
  16. Congratulations! I really enjoyed the creativity and originality of the entries. Robert did a great job presenting the winners. This was fun.
  17. The duplicate master is rarely used because it does not allow changing its parameters in realtime. AM has a good procedural core in the form of a pose creation mechanism. But it would be good to have a lower-level mechanism for procedural creation of a point, spline segment, patch, at least in the same pose paradigm.
  18. Hi Andres, Short answer, yes. Medium answer: There is a sample PRJ in this post that demonstrates making a Pose slider to control a surface color... https://forums.hash.com/topic/35590-rgb-slider-controls/ Longer answer: if you still have questions, do ask!
  19. Yeah I think that was it.
  20. Context: I want to create a simple on/off toggle control that switches a selected group's surface color (on being red, off being black). I'm still pretty new to animation:master so I'm still discovering new stuff each day but have spent some time on this and just wasn't sure if it's possible or not.
  21. @Roger is this the same presentation that you saw?
  22. What I'm asking is... what would be added? I don't use any of those other programs. There is quite a bit of parametric power in the duplicator wizard (and yet people rarely use that.) I'm also thinking that, since A:M models are all-text, a spreadsheet could be made to calculate unusual shapes when needed.
  23. Unfortunately, AM does not have a straightforward procedural/parametric toolkit for non-destructive editing and generative reproduction of model variants and animations. But due to some well-thought-out moments, AM can also work wonders. But it is not yet possible to compare it with Rhino's Grasshopper, AutoCAD's Dynamo, Houdini, Maya's Bifrost and other parametric designers, but I will always cherish the hope that AM will also acquire parametric tools, just as it once had extensions from Peter Sorfa and Gremlinscript.
  24. What would procedurality be in A:M?
  25. Ah, you noticed, eh? Yes, her magic nipple gems are very eye-catching. Her mission is to use their power to save the world.
  26. Yes - cubes are generated in AM - the question is, how to generate something like that in blender? I generated gears in blender in geonodes. AM also has many unfinished versions of these gears.
  27. Chuck, your Angel character is certainly giving literal meaning to the slang term "headlights".
  1. Load more activity
×
×
  • Create New...