Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to stream video using html5 video #356

Open
pjebs opened this issue Feb 2, 2025 · 3 comments
Open

Trying to stream video using html5 video #356

pjebs opened this issue Feb 2, 2025 · 3 comments

Comments

@pjebs
Copy link

pjebs commented Feb 2, 2025

import "github.com/kkdai/youtube/v2"
import "github.com/davecgh/go-spew/spew"

	videoID := "O2RB_8ircdE" // https://www.youtube.com/watch?v=O2RB_8ircdE
	client := youtube.Client{}

	video, err := client.GetVideo(videoID)
	if err != nil {
		panic(err)
	}

	formats := video.Formats.WithAudioChannels()

	spew.Dump(formats)

I get this response:

(youtube.FormatList) (len=5 cap=8) {
 (youtube.Format) {
  ItagNo: (int) 18,
  URL: (string) (len=1174) "https://rr1---sn-v2u0n-hxar.googlevideo.com/videoplayback?expire=1738501761&ei=IRqfZ-fUJP-FssUPgKe-uAQ&ip=175.33.95.213&id=o-AL5LfFqO2SokVnUh-ieq3LgMeCo862LgE9chCb-wEyOc&itag=18&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&met=1738480161%2C&mh=F2&mm=31%2C29&mn=sn-v2u0n-hxar%2Csn-v2u0n-ntqd&ms=au%2Crdu&mv=m&mvi=1&pl=19&rms=au%2Cau&initcwndbps=2588750&bui=AY2Et-OArs6C71T1DAS7_2iqcxugRDuGWKFWTRvq8nTot_jlVYOMy-Xq59xI6n-Rm0QWra5dBfCVoook&spc=9kzgDbo8lGxTzjTxJBtz-946LEj1hgnmCuFS9h9wIIIHgkCQR5n2SsVDD4QboYWTDGWabro&vprv=1&svpuc=1&mime=video%2Fmp4&ns=IuWJ_tCEgoEtih8Gy4wDz-EQ&rqh=1&cnr=14&ratebypass=yes&dur=1415.929&lmt=1687669853583248&mt=1738479666&fvip=4&fexp=51326932%2C51371294&c=WEB_EMBEDDED_PLAYER&sefc=1&txp=6219224&n=RJFKB8zlkcOXoHlxs&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cbui%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cns%2Crqh%2Ccnr%2Cratebypass%2Cdur%2Clmt&sig=AJfQdSswRgIhAK6U0W9zSjHxOmLzxn26Pb9r86_KVg1ylKtRtbaYIzfqAiEA3aMMSqlyiXvBmexcFHvyumcq9SqOf-V99iD51r2dhj8%3D&lsparams=met%2Cmh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Crms%2Cinitcwndbps&lsig=AGluJ3MwRAIgFDttDLHL1r74HgHjbZR7KrCEMGOosmmSpXQcozc8VNUCIAWWiuKCC0YxU7uXu-QCRssTJgBbhZEkKl3FQjUtwS3d",
  MimeType: (string) (len=42) "video/mp4; codecs=\"avc1.42001E, mp4a.40.2\"",
  Quality: (string) (len=6) "medium",
  Cipher: (string) "",
  Bitrate: (int) 201130,
  FPS: (int) 25,
  Width: (int) 640,
  Height: (int) 360,
  LastModified: (string) (len=16) "1687669853583248",
  ContentLength: (int64) 0,
  QualityLabel: (string) (len=4) "360p",
  ProjectionType: (string) (len=11) "RECTANGULAR",
  AverageBitrate: (int) 0,
  AudioQuality: (string) (len=17) "AUDIO_QUALITY_LOW",
  ApproxDurationMs: (string) (len=7) "1415929",
  AudioSampleRate: (string) (len=5) "44100",
  AudioChannels: (int) 2,
  InitRange: (*struct { Start string "json:\"start\""; End string "json:\"end\"" })(<nil>),
  IndexRange: (*struct { Start string "json:\"start\""; End string "json:\"end\"" })(<nil>),
  AudioTrack: (*struct { DisplayName string "json:\"displayName\""; ID string "json:\"id\""; AudioIsDefault bool "json:\"audioIsDefault\"" })

i then ran a webpage on a local server (using the URL from above):

<video height="300px" width="300px" controls autoplay  >

<source src="https://rr1---sn-v2u0n-hxar.googlevideo.com/videoplayback?expire=1738501761&ei=IRqfZ-fUJP-FssUPgKe-uAQ&ip=175.33.95.213&id=o-AL5LfFqO2SokVnUh-ieq3LgMeCo862LgE9chCb-wEyOc&itag=18&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&met=1738480161%2C&mh=F2&mm=31%2C29&mn=sn-v2u0n-hxar%2Csn-v2u0n-ntqd&ms=au%2Crdu&mv=m&mvi=1&pl=19&rms=au%2Cau&initcwndbps=2588750&bui=AY2Et-OArs6C71T1DAS7_2iqcxugRDuGWKFWTRvq8nTot_jlVYOMy-Xq59xI6n-Rm0QWra5dBfCVoook&spc=9kzgDbo8lGxTzjTxJBtz-946LEj1hgnmCuFS9h9wIIIHgkCQR5n2SsVDD4QboYWTDGWabro&vprv=1&svpuc=1&mime=video%2Fmp4&ns=IuWJ_tCEgoEtih8Gy4wDz-EQ&rqh=1&cnr=14&ratebypass=yes&dur=1415.929&lmt=1687669853583248&mt=1738479666&fvip=4&fexp=51326932%2C51371294&c=WEB_EMBEDDED_PLAYER&sefc=1&txp=6219224&n=RJFKB8zlkcOXoHlxs&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cbui%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cns%2Crqh%2Ccnr%2Cratebypass%2Cdur%2Clmt&sig=AJfQdSswRgIhAK6U0W9zSjHxOmLzxn26Pb9r86_KVg1ylKtRtbaYIzfqAiEA3aMMSqlyiXvBmexcFHvyumcq9SqOf-V99iD51r2dhj8%3D&lsparams=met%2Cmh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Crms%2Cinitcwndbps&lsig=AGluJ3MwRAIgFDttDLHL1r74HgHjbZR7KrCEMGOosmmSpXQcozc8VNUCIAWWiuKCC0YxU7uXu-QCRssTJgBbhZEkKl3FQjUtwS3d" type="video/mp4" />


</video>

But it doesn't load or play on Chrome. There is also nothing in the console.

Image
@pjebs
Copy link
Author

pjebs commented Feb 2, 2025

@kkdai What am I doing wrong?

@trollLemon
Copy link

@pjebs What HTTP code are you getting when you use that URL? If its a 403 it's probably related to #354.

@pjebs
Copy link
Author

pjebs commented Feb 7, 2025

@trollLemon I believe it is a 403.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants