I have downloaded two files using pytube from Youtube. One is audio file .webm extension. While the is adaptive stream 8k video with .mp4 extension. I have to combine audio with videos more than 720p resolution generally. For this I use following FFmpeg code
os.system("ffmpeg -i vid.mp4 -i aud.webm -c copy \""+ title +"\".mkv")
This worked for many mp4 videos I have downloaded. Why it gives error could not find codec parameters for 8k. I dont know much about ffmpeg. If I am doing something wrong please fix this code for the 8k video. The stream output for 8k video is
<Stream: itag="571" mime_type="video/mp4" res="4320p" fps="30fps" vcodec="av01.0.16M.08" progressive="False"
type="video">
The stream output for webm audio is.
<Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus" progressive="False" type="audio"> #webm **same for all videos**
The following are the codec I was able to join successfully with same audio
<Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401f" progressive="False" type="video">
the other video I was able to merge has the following stream
<Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028" progressive="False" type="video">
The question is why ffmpeg giving error and how can this be fixed The code to download video and audio is
from pytube import YouTube
url = "https://www.youtube.com/watch?v=Zv11L-ZfrSg"
yt = YouTube(url)
yt = yt.streams
stream=yt.order_by('resolution').desc().filter(mime_type="video/mp4").first()
stream.download(filename="vid.mp4" , skip_existing=False)
stream = yt.get_by_itag(251)
stream.download(filename="aud.webm" , skip_existing=False)
Note: I am using python to run ffmpeg.