A small script that downloads a video from an X/Twitter post and recreates the original tweet layout around it. The script screenshots the tweet UI, downloads the video with yt-dlp, and stitches everything together with ffmpeg.
The result is a video that looks like the original tweet player.
You’ll need:
- Python 3.9+
yt-dlpffmpegchromium- Python package:
playwright
The script expects a system Chromium installation.
Clone the repo:
git clone https://github.com/yourname/twdownloader.git
cd twdownloaderInstall Python dependencies:
pip install playwrightInstall system dependencies.
sudo apt install chromium ffmpeg yt-dlpsudo pacman -S chromium ffmpeg yt-dlpsudo dnf install chromium ffmpeg yt-dlpMake the script executable (optional):
chmod +x twdownloader.py./twdownloader.py "https://x.com/<user>/status/<tweet_id>"Example:
./twdownloader.py "https://x.com/user/status/1234567890123456789"The final video will be written to the output/ directory.
- Only tweets containing video media will produce a final rendered video.
- Image or text-only tweets will just output the captured layout screenshot.
- Temporary files are cleaned up automatically after rendering.