gatecrasher777 / ytcog-dl

Command line interface (CLI) for the ytcog innertube library
MIT License
3 stars 1 forks source link

Specify Audio Codec on .audioStreams[0] (Enhancement) #5

Open r0hin opened 2 years ago

r0hin commented 2 years ago

When running something like

await video.fetch()
console.log(video.audioStreams[0])

it returns something like

 quality: 'AUDIO_QUALITY_LOW',
 container: 'webm',
 bitrate: 54075,
 size: 1121689,
 type: 'audio',
 url: '...',
 decipher: true

Yet, I don't know if the specific audio codec is opus, aac, etc. It would be good to add a field specifying what codec the webm file is. In the meantime, is there any temporary solution to this?

Thank you!

gatecrasher777 commented 2 years ago

Although it is not explicit: Container webm indicates that it is opus (webm being vp9 video / opus audio) Container mp4 indicates that it is aac (mp4 being h264 video / aac audio)

r0hin commented 2 years ago

Although it is not explicit:

Container webm indicates that it is opus (webm being vp9 video / opus audio)

Container mp4 indicates that it is aac (mp4 being h264 video / aac audio)

Ah I see. Are you sure this consistent across all videos? I remember some videos were encoded differently but that was with a different library and about three months ago.

gatecrasher777 commented 2 years ago

It is totally consistent at the videoStream/audioStream stage. webm will always be opus. mp4 will always be aac. So if you are choosing what streams to download, you can be assured.

If you chose 'mkv' for container, then during the download stage it can create files with an mkv extension. In those cases, the audio could be either opus or aac.

But after downloading you can always check video.audioCodec and video.videoCodec to see what was downloaded.

r0hin commented 2 years ago

Oh I see, well that makes things a lot easier to work with :) Thanks for your help!

On Nov 3, 2021, at 9:07 AM, gatecrasher777 @.***> wrote:

It is totally consistent at the videoStream/audioStream stage. webm will always be opus. mp4 will always be aac. So if you are choosing what streams to download, you can be assured.

If you chose 'mkv' for container, then during the download stage it can create files with an mkv extension. In those cases, the audio could be either opus or aac.

But after downloading you can always check video.audioCodec and video.videoCodec to see what was downloaded.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/gatecrasher777/ytcog-dl/issues/5#issuecomment-959028806, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALFUATW45JNKHV3TWP45MDTUKEX2DANCNFSM5HH6OVWQ.

r0hin commented 2 years ago

On the video of ID "PkKOdE1eaX4", only two audio streams are returned:

[
  {
    quality: 'AUDIO_QUALITY_MEDIUM',
    container: 'mp4',
    bitrate: 130980,
    size: 4105494,
    type: 'audio',
    url: (url),
    decipher: true
  },
  {
    quality: 'AUDIO_QUALITY_LOW',
    container: 'mp4',
    bitrate: 327836,
    size: 10389133,
    type: 'both',
    url: (url)
    decipher: true
  }
]

I have previously only used webm files of type opus. I was just wondering if you know about the codecs used in these mp4 files. VLC shows the following:

image

I am using the MediaSource Web API and also need to know the "mimeType" if you know it as well. Thank you for your help!

gatecrasher777 commented 2 years ago

Generally, audio container "mp4" will be "aac". However, I will add mimeType and the codec label to the videoStreams and audioStreams on the next update.

r0hin commented 2 years ago

Think you're right, although there's also a video stream in the mp4 it seems. Anyhow, mime type would definitely be helpful here. Thank you for your help!

Also- let me know if you've got a donation link somewhere as this library and your quick support has been extremely helpful!!