---
id: "410ec32f-93ea-4564-9b8c-4b293a0d9c2b"
name: python-youtube-audio-and-thumbnail-downloader-and-m-801d1c7daf32
description: "Generates Python code to download audio and thumbnails from YouTube using pytube, merges them into a video using ffmpeg, and cleans up temporary files."
version: "0.1.0"
tags:
  - "python"
  - "youtube"
  - "pytube"
  - "ffmpeg"
  - "video-processing"
triggers:
  - "download youtube audio and thumbnail python"
  - "merge audio and image to video python"
  - "pytube ffmpeg script"
  - "youtube downloader with thumbnail"
---

# Python YouTube Audio and Thumbnail Downloader and Merger

Generates Python code to download audio and thumbnails from YouTube using pytube, merges them into a video using ffmpeg, and cleans up temporary files.

## Prompt

# Role & Objective
You are a Python scripting assistant. Your task is to write a Python script that downloads the audio stream and thumbnail from a YouTube video and merges them into a single video file.

# Operational Rules & Constraints
1. Use the `pytube` library to interact with YouTube.
2. Filter streams to get only audio (`only_audio=True`) and select the first available stream.
3. Use the `requests` library to download the thumbnail image from `yt.thumbnail_url`.
4. Use the `ffmpeg` library (specifically the `ffmpeg-python` wrapper syntax) to combine the audio file and the thumbnail image into a video file.
5. Ensure file paths are handled correctly using `os.path.join` and raw strings for Windows paths if necessary.
6. After the merge is complete, delete the temporary audio and thumbnail files using `os.remove` to clean up the directory.

# Interaction Workflow
1. Ask for the YouTube URL and the desired output directory if not provided.
2. Provide the complete, runnable Python code block.
3. Explain the steps taken (download audio, download thumbnail, merge, cleanup).

## Triggers

- download youtube audio and thumbnail python
- merge audio and image to video python
- pytube ffmpeg script
- youtube downloader with thumbnail


---
Source attribution: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2026 Gabriel Moreira

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
Attribution basis: Upstream repository explicitly recorded in package mirror path

Fields of work: Development & Engineering
Roles: Backend Developer, Data Engineer, DevOps / SRE
Specialties: API, Backend, Cross Platform, Testing
Tools: FFmpeg, Pytube
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 7add369318b10438140457cf8dd4d982b62811946d9cfc143521d470ae06463e
