I have created a very simple youtube downloader but I have a problem to decide which format should I label as "the best audio" format.
As a reference I have read ytdl-core sourcecode (youtube downloader written in javascript) and they rank audio formats based on bitrate and encodings with high weight put on bitrate but I am wondering if sampling should also be taken into account.
Is there some golden rule I could use to decide based on bitrate, encoding and sampling which format has the best sound quality?
For example:
Here are two "formats" of the same youtube video. Is it possible to decide based on this data which has better sound quality?
A):
{
mimeType: 'video/mp4; codecs="avc1.64001F, mp4a.40.2"',
qualityLabel: '720p',
bitrate: 1309340,
audioBitrate: 192,
itag: 22,
width: 1280,
height: 720,
lastModified: '1617547492322166',
quality: 'hd720',
fps: 30,
projectionType: 'RECTANGULAR',
audioQuality: 'AUDIO_QUALITY_MEDIUM',
approxDurationMs: '743201',
audioSampleRate: '44100',
audioChannels: 2,
hasVideo: true,
hasAudio: true,
container: 'mp4',
codecs: 'avc1.64001F, mp4a.40.2',
videoCodec: 'avc1.64001F',
audioCodec: 'mp4a.40.2',
isLive: false,
isHLS: false,
isDashMPD: false
}
B)
{
mimeType: 'audio/webm; codecs="opus"',
qualityLabel: null,
bitrate: 145005,
audioBitrate: 160,
itag: 251,
initRange: { start: '0', end: '258' },
indexRange: { start: '259', end: '1530' },
lastModified: '1617547286610933',
contentLength: '9831553',
quality: 'tiny',
projectionType: 'RECTANGULAR',
averageBitrate: 105834,
audioQuality: 'AUDIO_QUALITY_MEDIUM',
approxDurationMs: '743161',
audioSampleRate: '48000',
audioChannels: 2,
loudnessDb: -14.280001,
hasVideo: false,
hasAudio: true,
container: 'webm',
codecs: 'opus',
videoCodec: null,
audioCodec: 'opus',
isLive: false,
isHLS: false,
isDashMPD: false
}
A has higher bitrate but B is using better codecs and has higher sample rate. Is it possible to tell which of them has better sound quality?