ThreadGens is a local Java tool for turning Reddit-style threads or X-style posts/replies into 9:16 short-form video assets.
It can:
- read one text file and create one 1080x1920 PNG frame per line
- generate a fresh Reddit thread locally with Ollama
- generate a fresh X post and replies locally with Ollama
- generate an optional AI image for the original post through local ComfyUI / RealVisXL
- generate local voice audio with Kokoro or Piper
- render per-frame MP4 clips with FFmpeg
- stitch clips into one final MP4
- generate profile pictures and usernames for fake Reddit/X-style accounts
The default layout is built for TikTok, YouTube Shorts, and Reels-style vertical videos.
X output with OP image:
Reddit output with OP image:
On Windows, double-click:
setup_windows.bat
The setup script will:
- check/install Java JDK 21 with
winget - check/install Python for Kokoro
- check/install Ollama with
winget - start Ollama and pull
llama3.1:8b - download Piper TTS for Windows
- download the
en_US-lessac-mediumPiper voice - create an isolated
.venv-kokoroenvironment - install Kokoro TTS requirements
- build ThreadGens into
out/ - check profile-generator support
After setup finishes, double-click:
run_ai_windows.bat
That runner asks for platform/thread style, TTS engine, prompt text, count, optional OP image generation, and optional final video output.
For Reddit:
post title
post body
For X:
optional hidden reply style
visible original X post text
Normal and batch Windows runners keep Ollama loaded by default so repeated generations are faster. They only unload Ollama if you choose that option.
Default outputs:
output/script/generated_comments.txt
output/*.png
output/images/*.png
output/cache/images/*.txt
output/audio/*.wav
output/video/*.mp4
output/video/final.mp4
javac -d out src/redditTxtToImg/*.javaOr with Gradle:
gradle buildUse CheckedRunner for scripts and normal command-line runs:
java -cp out redditTxtToImg.CheckedRunner data/comments.txt outputCheckedRunner delegates to the selected renderer, then verifies that the expected fresh PNG/WAV/MP4 files were actually created. This prevents failed runs from looking successful.
Use OpImageVideoSafeRunner when OP image generation and video creation are both enabled. It delays MP4 creation until after the OP image has been overlaid onto the original post PNG.
java -cp out redditTxtToImg.OpImageVideoSafeRunner --platform x --auto --topic "I just saw something weird and I need someone else to explain it." --count 10 --image-mode comfyui --tts kokoro --tts-command .venv-kokoro/Scripts/python.exe --voice af_heart --video --concat-videoSelect a platform with --platform:
java -cp out redditTxtToImg.CheckedRunner data/comments.txt output --platform reddit
java -cp out redditTxtToImg.CheckedRunner data/comments.txt output --platform xSupported values:
redditxtwitteras an alias forx
The older renderer entrypoints still exist:
java -cp out redditTxtToImg.RedditScreenshotGenerator data/comments.txt output
java -cp out redditTxtToImg.XThreadGenerator data/comments.txt outputUse them only when you want raw renderer behavior without checked artifact validation.
java -cp out redditTxtToImg.GuiAppThe GUI lets you choose an input text file, choose an output folder, and generate images. It uses the checked runner so missing output files show as failures instead of false success.
Basic Reddit image generation:
java -cp out redditTxtToImg.CheckedRunner data/comments.txt output --platform reddit --count 3 --prefix sample --style light --shuffle --centerBasic X image generation:
java -cp out redditTxtToImg.CheckedRunner data/comments.txt output --platform x --count 3 --prefix xsample --topImage options:
--platform reddit|xchooses the screenshot/thread style. Default:reddit.--count Nlimits how many frames are generated.--prefix NAMEchanges output file names. Files are named like0NAME.png,1NAME.png, etc.--style dark|lightchooses a Reddit template fromtemplates/.--shuffleshuffles input lines before rendering.--centercenters Reddit comments in the vertical card.--topkeeps text closer to the top of the card.--no-watermarkhides the small watermark.--guiopens the GUI.
Make sure Ollama is running locally and the model is already pulled:
ollama pull llama3.1:8bReddit auto-generation:
java -cp out redditTxtToImg.CheckedRunner --platform reddit --auto --post-title "Finish this story in the comments" --topic "I found a locked box behind my dryer." --count 10 --llm-model llama3.1:8bX auto-generation:
java -cp out redditTxtToImg.CheckedRunner --platform x --auto --post-title "Wrong answers only" --topic "Why is there a shopping cart in my living room?" --count 10 --llm-model llama3.1:8bFor X, --post-title is not displayed. It is only a hidden reply style/instruction. The visible X post is --topic.
X example with no hidden style:
java -cp out redditTxtToImg.CheckedRunner --platform x --auto --topic "I just saw something weird and I need someone else to explain it." --count 5 --llm-model llama3.1:8bLocal AI options:
--autoasks the local LLM to generate a fresh script before rendering.--post-title TEXTsets the visible Reddit title, or hidden X reply style.--topic TEXTsets the Reddit post body/story, or visible X post text.--llm-model MODELsets the Ollama model name. Default:llama3.1:8b.--llm-url URLsets the Ollama generate endpoint. Default:http://localhost:11434/api/generate.--script-out FILEchanges where generated text is saved.--keep-ollama-loadedkeeps Ollama loaded after script generation. The Windows runners anddefaults.txtalready use keep-loaded behavior by default.
OP image generation is optional and off by default for smoke tests and text-only runs.
Two modes are supported:
--image-mode comfyuigenerates an OP image locally through ComfyUI.--image-mode local --op-image path/to/image.pnguses an existing local image for testing the overlay.
ComfyUI mode uses Ollama to expand the OP title/body into an SDXL prompt, then sends that prompt to local ComfyUI. The default checkpoint is:
RealVisXL_V5.0_fp32.safetensors
ComfyUI must already be running at:
http://127.0.0.1:8188
Reddit OP image example:
java -cp out redditTxtToImg.OpImageVideoSafeRunner --platform reddit --auto \
--post-title "Finish this story in the comments" \
--topic "weird everyday stories" \
--count 10 \
--image-mode comfyui \
--tts kokoro \
--tts-command .venv-kokoro/Scripts/python.exe \
--voice af_heart \
--video \
--concat-videoX OP image example:
java -cp out redditTxtToImg.OpImageVideoSafeRunner --platform x --auto \
--topic "I just saw something weird and I need someone else to explain it." \
--count 10 \
--image-mode comfyui \
--tts kokoro \
--tts-command .venv-kokoro/Scripts/python.exe \
--voice af_heart \
--video \
--concat-videoOP image options:
--image-mode none|local|comfyuicontrols OP image behavior.--op-image FILEsupplies a local test image when using--image-mode local.--image-dir DIRchanges where generated OP images are saved.--image-cache-dir DIRchanges where generated prompt cache files are saved.--comfy-url URLchanges the ComfyUI server URL.--image-checkpoint NAMEchanges the ComfyUI checkpoint name.--image-width Nand--image-height Nchange generated image dimensions.--image-steps N,--image-cfg N,--image-sampler NAME, and--image-scheduler NAMEtune ComfyUI generation.--image-negative TEXTchanges the negative prompt.--image-timeout SECONDSchanges the ComfyUI polling timeout.
ThreadGens supports:
--tts kokorofor Kokoro voices such asaf_heart,af_bella,am_adam, etc.--tts piperfor Piper.onnxvoice models.--tts noneto skip audio.
Kokoro Reddit example:
java -cp out redditTxtToImg.CheckedRunner --platform reddit --auto \
--post-title "Finish this story in the comments" \
--topic "I found a second phone hidden in my car." \
--count 10 \
--tts kokoro \
--tts-command .venv-kokoro/Scripts/python.exe \
--voice af_heartKokoro X example:
java -cp out redditTxtToImg.CheckedRunner --platform x --auto \
--post-title "Wrong answers only" \
--topic "Why is there a shopping cart in my living room?" \
--count 10 \
--tts kokoro \
--tts-command .venv-kokoro/Scripts/python.exe \
--voice af_heartPiper example:
java -cp out redditTxtToImg.CheckedRunner --platform reddit --auto \
--post-title "Finish this story in the comments" \
--topic "creepy small town stories" \
--count 10 \
--tts piper \
--voice voices/en_US-lessac-medium.onnxTTS options:
--tts none|piper|kokoroenables or disables voice generation.--voice NAME_OR_PATHsets the Kokoro voice name or Piper voice path/name.--voice-dir DIRsets the Piper voice directory.--list-voiceslists local Piper voices and common Kokoro voices.--tts-command CMDchanges the executable used by the selected TTS engine.--audio-dir DIRchanges where WAV files are saved.--tts-timeout SECONDSchanges the per-line TTS timeout.
Video generation requires FFmpeg and FFprobe on PATH, or a direct path passed with --video-command.
java -cp out redditTxtToImg.CheckedRunner --platform x --auto \
--post-title "Wrong answers only" \
--topic "Why is there a shopping cart in my living room?" \
--count 10 \
--tts kokoro \
--tts-command .venv-kokoro/Scripts/python.exe \
--voice af_heart \
--video \
--concat-videoWhen --image-mode comfyui and video are both enabled, prefer OpImageVideoSafeRunner so the final MP4 includes the OP image overlay.
Video options:
--videorenders one MP4 clip per PNG/WAV pair.--concat-videoalso stitches those clips into one final MP4.--video-dir DIRchanges where clips and final videos are saved.--video-command CMDchanges the FFmpeg executable path.--fps 30sets video FPS.--video-timeout SECONDSchanges the FFmpeg timeout.--final-video NAME.mp4changes the stitched final video name.
Create or edit:
data/batch_videos.txt
Format uses two non-empty lines per video.
For Reddit:
line 1 = post title
line 2 = post body
line 3 = next post title
line 4 = next post body
For X:
line 1 = hidden reply style
line 2 = visible X post text
line 3 = next hidden reply style
line 4 = next visible X post text
Then run:
batch_create_videos_windows.bat
The batch runner asks whether to generate OP images for each video. It keeps Ollama loaded between videos by default.
Batch outputs go under:
output/batch_videos/<platform>_<timestamp>/
Final MP4 copies are collected in:
output/batch_videos/<platform>_<timestamp>/final_videos/
Run:
generate_profiles_windows.bat
Choose either:
- AI face/selfie profile pictures through local ComfyUI.
- Fast procedural fallback avatars with no AI model.
Direct procedural mode:
python tools/generate_profiles.py --count 100 --size 256Direct ComfyUI mode:
python tools/generate_comfy_profiles.py --count 25 --size 512 --comfy-url http://127.0.0.1:8188Generated profile pictures go to:
assets/pfp/
Generated usernames go to:
data/author_names.txt
src/redditTxtToImg/contains the Java source.src/redditTxtToImg/CheckedRunner.javais the safe CLI/script entrypoint.src/redditTxtToImg/OpImageVideoSafeRunner.javais the safe entrypoint for OP-image plus video runs.src/redditTxtToImg/RedditScreenshotGenerator.javarenders Reddit-style frames.src/redditTxtToImg/XThreadGenerator.javarenders X-style frames.src/redditTxtToImg/LocalLlmTextGenerator.javahandles Reddit Ollama generation.src/redditTxtToImg/XLocalLlmTextGenerator.javahandles X Ollama generation.src/redditTxtToImg/OpImagePipeline.javacoordinates OP image prompting, generation, and overlay.src/redditTxtToImg/ComfyUiImageGenerator.javacalls the local ComfyUI API.src/redditTxtToImg/OpImagePromptGenerator.javaasks Ollama to write the image prompt.data/author_names.txtcontains sample names.data/comments.txtcontains sample input lines.defaults.txtcontains default render and local pipeline settings.templates/contains simple Reddit color templates.assets/contains optional images.docs/x-op-image-example.pngshows the X README output example.docs/reddit-op-image-example.pngshows the Reddit README output example.tools/kokoro_tts.pyis the Kokoro helper used by Java.tools/generate_profiles.pycreates procedural avatars and usernames.tools/generate_comfy_profiles.pycreates ComfyUI profile images and usernames.tools/batch_create_videos.ps1powers batch video creation.tools/run_ai_windows.ps1powers the normal Windows AI runner.setup_windows.batlaunches Windows setup.run_ai_windows.batlaunches the normal local AI pipeline.
gradle jar
java -jar build/libs/ThreadGens-0.4.2-op-image-generation.jar data/comments.txt outputRunnable jar with local AI:
java -jar build/libs/ThreadGens-0.4.2-op-image-generation.jar --platform x --auto --post-title "Wrong answers only" --topic "Why is there a shopping cart in my living room?" --count 10 --tts kokoro --voice af_heart
