Skip to content

Instantly share code, notes, and snippets.

@doxyf
Created March 15, 2025 08:11
Show Gist options
  • Save doxyf/cfd1d3a78d0b94a57ad0036f88ea5fc9 to your computer and use it in GitHub Desktop.
Save doxyf/cfd1d3a78d0b94a57ad0036f88ea5fc9 to your computer and use it in GitHub Desktop.
Download song from SoundCloud and export it as video with cover easily using the power of python, ytdl(p) and ffmpeg. You need to have them installed as terminal commands.
import requests
import os
from bs4 import BeautifulSoup
ydl_opts = {}
url = input('sc track url: ')
def dwl_vid(url):
r = requests.get(url)
soup = BeautifulSoup(r.content, 'html.parser')
s = soup.find("meta", property="og:image")
print(s["content"])
img_data = requests.get(s["content"]).content
with open('temp_pic.png', 'wb') as handler:
handler.write(img_data)
os.system(f'ytdl {url} -o temp_audio') ## Or yt-dlp if you will
os.system('ffmpeg -loop 1 -i temp_pic.png -i temp_audio -c:v libx264 -c:a aac -b:a 192k -shortest result.mp4')
os.remove('temp_pic.png')
os.remove('temp_audio')
dwl_vid(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment