I'm intending to use yt-dlp to download a video and then cut the video down afterward using ffmpeg. But to be able to use ffmpeg I am going to have to know the name of the file that yt-dlp produces. I have read through their documentation but I can't seem to find a way of getting the file name back into my program.
the numbers you mentioned (like .f399
) I believe are temp only and are eventually removed when the final file is merged.
if you want to get the filename:
import subprocess
someFilename = subprocess.getoutput('yt-dlp --print filename https://www.youtube.com/something')
# then pass someFilename to FFmpeg
to use your own filename:
subprocess.run('yt-dlp -o thisIsMyName https://www.youtube.com/something')
# this will likely download a file named thisIsMyName.webm
but if you are not sure of the file type/extension beforehand and just want to get that:
someFileType = subprocess.getoutput('yt-dlp --print filename -o "%(ext)s" https://www.youtube.com/something')
print(someFileType)
it's not very efficient but to help explain it:
import subprocess
someFileType = subprocess.getoutput('yt-dlp --print filename -o "%(ext)s" https://www.youtube.com/something')
subprocess.run('yt-dlp -o "myFileName.%(ext)s" https://www.youtube.com/something')
subprocess.run(f'ffmpeg -i "myFileName.{someFileType}" outputFile.mp4')