farhan ahmed FCS
farhan ahmed FCS

Reputation: 71

ffmpeg combining audio and video error: could not find codec parameters

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.

Upvotes: 3

Views: 1316

Answers (1)

codeslord
codeslord

Reputation: 2368

The 8k video you are trying to download uses AV1 https://en.wikipedia.org/wiki/AV1 https://aomediacodec.github.io/av1-isobmff/#codecsparam coding format

To better understand it, video codec av01.0.16M.08 means the following

  • av01 is the AV1 codec
  • 0 indicates Profile 0
  • 16M indicates level 6.0 identifier 16
  • 08 indicates an 8 bit bit depth

The key is in the level identifier 16 (6.0) A level 4.0 decoder can decode 1080p video @30fps but it won't be able to decode 1080p@60fps and it requires level 4.1 Similarly for 4k@30fps we need level 5.0 and 60fps need level 5.1 and 8k requires a level 6.0 or higher

Refer below for more information about these levels

https://en.wikipedia.org/wiki/AV1#Levels

Level 7 has not been defined yet.

You can see that some of these levels are fairly new as 8k is yet to be mainstream. ffmpeg only started supporting AV1 codec from version 4.0 and more decoder supports are being added as and when they come in newer versions.

So, in order to answer your question, you just need to update your ffmpeg to the latest version and it should solve the issue. Or you can download a video with a lower decoder level requirement and it will suffice. The added information is for reference so that someone who stumbles upon the question can better understand why the issue has happened and I hope it will help troubleshoot similar issues in the future.

Upvotes: 7

Related Questions