iv-org / invidious

Invidious is an alternative front-end to YouTube
https://invidious.io
GNU Affero General Public License v3.0
16.17k stars 1.78k forks source link

[Question] "The media could not be loaded, either because the server or network failed or because the format is not supported." - inv_sig_helper missing #4947

Closed DUOLabs333 closed 2 days ago

DUOLabs333 commented 2 days ago

Solution here: https://github.com/iv-org/invidious/issues/4947#issuecomment-2373219716


Describe the bug For almost all videos (shorts and a few other videos seem to be immune), I started getting this error: "The media could not be loaded, either because the server or network failed or because the format is not supported." This started about 2 days ago.

Steps to Reproduce

  1. Go to https:///watch?v=tPTvG0Se7L8
  2. See error

Logs

Screenshots

Additional context

I tried adding the po_token and visitor_data from https://github.com/iv-org/youtube-trusted-session-generator, but it didn't help.

Switching to master-arm64 also didn't help.

DUOLabs333 commented 2 days ago

This seems to be a duplicate of iv-org/invidious#4889.

thebozzcl commented 2 days ago

I don't know, I'm experiencing a similar issue and the workaround described in iv-org/invidious#4889 doesn't seem to work for me.

Here's an example: https://mysupercoolinvidious/watch?v=a4RKGuTL7NE

It seems a bit sporadic - eventually I manage to make it through and watch the video, but it can take several attempts or even waiting for a few hours. I've managed to repro this in several combinations of devices and browsers:

It's also happened for me using both latest-arm64 and master-arm64.

These lines in the browser console seem interesting:

WARN: Specified “type” attribute of “application/dash+xml” is not supported. Load of media resource /api/manifest/dash/id/a4RKGuTL7NE?local=true&unique_res=1 failed. Trying to load from next <source> element.
ERROR: VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) The media could not be loaded, either because the server or network failed or because the format is not supported. 
Object { code: 4, message: "The media could not be loaded, either because the server or network failed or because the format is not supported." }
[video.js:163:49](https://mysupercoolinvidious/videojs/video.js/video.js?v=a021b93)
    LogByTypeFactory https://mysupercoolinvidious/videojs/video.js/video.js?v=a021b93:163
    error https://mysupercoolinvidious/videojs/video.js/video.js?v=a021b93:351
    error https://mysupercoolinvidious/videojs/video.js/video.js?v=a021b93:28175
    handleTechError_ https://mysupercoolinvidious/videojs/video.js/video.js?v=a021b93:26287
    loadTech_ https://mysupercoolinvidious/videojs/video.js/video.js?v=a021b93:25292
    dispatcher https://mysupercoolinvidious/videojs/video.js/video.js?v=a021b93:2250

If this is really a config issue, I'd love to learn how to fix it!

DUOLabs333 commented 2 days ago

@thebozzcl Interesting --- I don't have any error in my logs, I'll check the console.

kkwpsi commented 2 days ago

Some videos play, some don't. If video doesn't play Invidious logs line like this:

[info] 403 GET /videoplayback?expire=1727226407&ei=xw3zZrH4BoKP6dsPzNiXgQI&ip=%exitip%&id=o-AK-S98aTvLIXROYgmqOHSXcf1A_wjXpqznWX_FcmFE-F&itag=18&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&mh=Ou&mm=31%2C29&mn=sn-5hne6ns6%2Csn-5hnekn7s&ms=au%2Crdu&mv=m&mvi=2&pl=24&initcwndbps=403750&bui=AXLXGFRxdtpmMpZit8qpksdmwFjHIUY27eihhqA0U3tODpkaliI6vrmRE3rWJBAep96f8DrDyPR8G9LD&spc=54MbxYwQGsKvF50aSjefFb5JFfsHLg-Tk9HnxpW3wR3ZZoaofNBDCEI8oHbj&vprv=1&svpuc=1&mime=video%2Fmp4&ns=5xxgFfmUwq_0z_LxdBMEo5AQ&rqh=1&gir=yes&clen=11846072&ratebypass=yes&dur=304.227&lmt=1692988678086191&mt=1727204477&fvip=3&fexp=51300761&c=WEB&sefc=1&txp=1319224&n=eNRVLEVo1KBZalTeVV&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cbui%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cns%2Crqh%2Cgir%2Cclen%2Cratebypass%2Clmt&sig=AJfQdSswRQIhAPBAI78F80BK5md8Ol_t5ffQGWIuq9oj7GJKbGZMoN9iAiAJL7HFz8oIMUIdTyXgSOue70qheQoSGNOGH0v4wpd3Qg%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=ABPmVW0wRQIhAP1O3Z_9f8qz-4E4yeXK8zS6L0wuG0buvAZBWkASMQBqAiBvQKLQR7ROqAsqLlkkK5r8VT1EfBXhwQYtb4mtdqewbg%3D%3D&host=rr2---sn-5hne6ns6.googlevideo.com 226.0ms

It's completely random

danvolchek commented 2 days ago

I'm getting the same error as @kkwpsi both for normal videos and for live streams using the latest release.

iv-org/invidious#4889 looks different to me, the The media could not be loaded, either because the server or network failed or because the format is not supported error is the generic browser error for when something goes wrong. That issue doesn't post server logs, and moreover the original video they have issues playing works fine on my instance.

The comment/logs on that issue from today are the same as this one, but they seem unrelated to the original post.

danvolchek commented 2 days ago

This may be due to https://github.com/iv-org/invidious/issues/4734#issuecomment-2365205990

unixfox commented 2 days ago

Check the devtools to see what's the status code of each request. If it's 403 then inv sig helper may need an update.

DUOLabs333 commented 2 days ago

@unixfox I'm not sure which requests are important, but I can see at least 3 that return a 403: /latest_version, and two calls to /videoplayback.

unixfox commented 2 days ago

Ok then this is most likely it. Sig decryption needs an update.

unixfox commented 2 days ago

Ping @techmetx11

TropicZL1 commented 2 days ago

Was having the same issue today. Stumbled across this issue but was able to fix it by amending my compose yaml. Had to add inv_sig_helper from the https://docs.invidious.io/installation/ (docker-compose method (production)) and then subsequently add visitor data and po token. @DUOLabs333 Did you also do this or did you only add the token and data?

DUOLabs333 commented 2 days ago

I didn't set up the sig_helper --- I didn't even know that existed until today.

TropicZL1 commented 2 days ago

I suspect that your issue then is probably that you set up your token and data but are not running the sig helper. Add signature_server: inv_sig_helper:12999 to your yaml under Invidious and then add

inv_sig_helper:
    image: quay.io/invidious/inv-sig-helper:latest
    command: ["--tcp", "0.0.0.0:12999"]
    environment:
      - RUST_LOG=info
    restart: unless-stopped
    cap_drop:
      - ALL
    read_only: true
    security_opt:
      - no-new-privileges:true

Then recreate.

Edit: Formatting

DUOLabs333 commented 2 days ago

I set up everything (at least I think so --- I can see the sig helper running), and I get the same error.

DUOLabs333 commented 2 days ago

Oh, I think it does work, but cached videos (even those that were opened unsuccessfully) are not sent to the helper.

DUOLabs333 commented 2 days ago

@unixfox How do you drop cached videos from the database? I used to have it in my container-compose.py, but I must have deleted it (probably because I had no need for it).

TropicZL1 commented 2 days ago

Was just about to comment with my compose.yaml. Mine seems to be opening even videos that didn't successfully open before. Did you fully bring down the containers using docker compose down and bringing it back up with docker compose up -d?

DUOLabs333 commented 2 days ago

Yes --- after stop, I checked that no Invidious-related processes are running and that the container is no longer mounted.

TropicZL1 commented 2 days ago

Are you managing your containers in Portainer?

DUOLabs333 commented 2 days ago

Oh, I think it does work, but cached videos (even those that were opened unsuccessfully) are not sent to the helper.

Yeah, truncation was needed (I remembered the command --- psql -d invidious -c 'TRUNCATE TABLE videos')

Are you managing your containers in Portainer?

No, I use my own scripts.

TropicZL1 commented 2 days ago

Gotcha. So it seems sig helper must be necessary now for normal function of Invidious. Since I first posted about an hour ago I haven't run into any issues so please keep us all updated if you run into any issues yourself.

DUOLabs333 commented 2 days ago

Yeah, disabling the helper brings back the error.

DUOLabs333 commented 2 days ago

Should this be closed now, with maybe an update to invidious' README?

danvolchek commented 2 days ago

Also fixed the problem for me (also for previously failed videos); also did not know that this was needed. It's in the install docs already, but I didn't know it changed/had an update.

Some sort of notification for new install requirements would be cool!

Thanks for the info/fix :)

UltraBlackLinux commented 2 days ago

wtf how can an old issue be a duplicate of a new issue?? AI-ification is making everything worse

The above fix doesn't appear to be working for me. I don't know how I'd check if the sig helper is actually doing anything however. I do see some sig and lsig tags in the requests to google, though no idea if that's relevant.

I have tried clearing out the cached videos, but

postgres@9ff3c0e5b3f8:/$ psql invidious -c "TRUNCATE TABLE videos"
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  role "postgres" does not exist

(no idea what to make of that either :/ )

unixfox commented 2 days ago

Also fixed the problem for me (also for previously failed videos); also did not know that this was needed. It's in the install docs already, but I didn't know it changed/had an update.

Some sort of notification for new install requirements would be cool!

Thanks for the info/fix :)

Invidious has releases now! With a changelog of what changed: https://github.com/iv-org/invidious/releases/tag/v2.20240825

So there were technically an announcement back in the end of august.


So you need to add inv_sig_helper and potoken now. By following the updated documentation: https://docs.invidious.io/installation/


potoken and inv_sig_helper are not an hard requirement since some IP address may still work on the old method.

If you haven't followed there were actually a constant fight against youtube from June to September: https://github.com/iv-org/invidious/issues/4734.

Invidious lost for the moment and the IP addresses of most datacenter are blocked.

thebigbone commented 1 day ago

After adding po_token and visitor_data, I am getting this error:

audio append of 61410b failed for segment #0 in playlist 0-placeholder-uri-AUDIO-audio-main

Edit: after restarting for a few times, it's working now! (incase you want to use my instance: https://yt.hcrypt.net)

gigq commented 1 day ago

Getting the same error, installing inv_sig_helper and potoken haven't made a difference. I'm running outside of docker if that matters but have all the requirements mentioned in this thread running and still get the "The media could not be loaded, either because the server or network failed or because the format is not supported."

DUOLabs333 commented 1 day ago

@gigq Make sure the signature_helper key is in the yaml config, and that you truncated the videos database.

red0bear commented 1 day ago

In reality i cant watch any video anymore on using this program because of "The media could not be loaded, either because the server or network failed or because the format is not supported." cant listen audio/ download too . This error started last week here. I see youtube_dl cant be used too this time to get videos.

gigq commented 1 day ago

@gigq Make sure the signature_helper key is in the tank config, and that you truncated the videos database.

Thank you that worked. For anyone else running outside docker these are the additional steps:

Pull the latest invidious, recompile.

Generate po_token and visitor_data identities (https://docs.invidious.io/installation/#generate-po_token-and-visitor_data-identities)

Add the po_token and visitor_data to your config.yml

Build and run inv_sig_helper (https://docs.invidious.io/installation/#run-inv_sig_helper-in-background)

Add signature_server to your config.yml If you are running it locally this should be "signature_server: 127.0.0.1:12999" however I also had to specify this at start up when running inv_sig_helper even though that port is supposed to be the default: inv_sig_helper_rust --tcp 127.0.0.1:12999

Anyways this got me back up and running hope it helps others.

thebigbone commented 1 day ago

If anyone wants to keep rotating the tokens, I wrote this small script which you can run in a cronjob:

output=$(docker run quay.io/invidious/youtube-trusted-session-generator)

visitor_data=$(echo "$output" | awk -F': ' '/visitor_data/ {print $2}')
po_token=$(echo "$output" | awk -F': ' '/po_token/ {print $2}')

sed -i "s/visitor_data:.*/visitor_data: $visitor_data/" docker-compose.yml
sed -i "s/po_token:.*/po_token: $po_token/" docker-compose.yml

docker compose up -d invidious
techmetx11 commented 1 day ago

@gigq Make sure the signature_helper key is in the tank config, and that you truncated the videos database.

Thank you that worked. For anyone else running outside docker these are the additional steps:

Pull the latest invidious, recompile.

Generate po_token and visitor_data identities (https://docs.invidious.io/installation/#generate-po_token-and-visitor_data-identities)

Add the po_token and visitor_data to your config.yml

Build and run inv_sig_helper (https://docs.invidious.io/installation/#run-inv_sig_helper-in-background)

Add signature_server to your config.yml If you are running it locally this should be "signature_server: 127.0.0.1:12999" however I also had to specify this at start up when running inv_sig_helper even though that port is supposed to be the default: inv_sig_helper_rust --tcp 127.0.0.1:12999

Anyways this got me back up and running hope it helps others.

If you're running it locally (and outside of Docker), you should use a UNIX socket instead, since it'll be more performant and usable than TCP

thebozzcl commented 1 day ago

Confirmed working after adding the signature helper! Now I need to find a setup that can rotate the trusted sessions automatically within Docker Swarm.

MenacingMight commented 1 day ago

Hello I added the signature helper but most videos still don't work and I get 403 GET /videoplayback error. Weirdly enough I found that MKBHD videos work with a 206 GET /videoplayback status but anything else does not.

Signature helper at log startup

inv_sig_helper-1  | [2024-09-26T00:00:29Z INFO  inv_sig_helper_rust] Fetching player
inv_sig_helper-1  | [2024-09-26T00:00:30Z INFO  inv_sig_helper_rust::player] Fetching player JS URL: https://www.youtube.com/s/player/c9dd45ed/player_ias.vflset/en_US/base.js
inv_sig_helper-1  | [2024-09-26T00:00:30Z WARN  inv_sig_helper_rust::player] nsig function ending did not work: =\s*function(\([\w]+\)\{\s*var\s+[\w\s]+=[\w\.\s]+?\.call\s*\([\w\s$]+?,[\(\)\",\s]+\)[\S\s]*?\}\s*return [\w\.\s$]+?\.call\s*\([\w\s$]+?\s*,[\(\)\",\s]+\)\s*\}\s*;)
inv_sig_helper-1  | [2024-09-26T00:00:30Z INFO  inv_sig_helper_rust::player] sig code: var iCa;var iL={Z2:function(a,b){a.splice(0,b)},
inv_sig_helper-1  |     h5:function(a){a.reverse()},
inv_sig_helper-1  |     YZ:function(a,b){var c=a[0];a[0]=a[b%a.length];a[b%a.length]=c}};iCa=function(a){a=a.split("");iL.h5(a,0);iL.Z2(a,3);iL.YZ(a,4);iL.YZ(a,25);iL.h5(a,21);iL.Z2(a,2);iL.YZ(a,17);iL.YZ(a,29);return a.join("")}
inv_sig_helper-1  | [2024-09-26T00:00:30Z INFO  inv_sig_helper_rust] Successfully fetched player
DUOLabs333 commented 1 day ago

@MenacingMight Did you add the signature_helper to your yaml?

cleancoda commented 1 day ago

Adding to the thread - went through the process of running the session generator via docker run quay.io/invidious/youtube-trusted-session-generator, got the two keys

plugged them into docker-compose.yml and added those two new keys, along with sig helper and adding signature_server: inv_sig_helper:12999 as well.

`` inv_sig_helper: image: quay.io/invidious/inv-sig-helper:latest command: ["--tcp", "0.0.0.0:12999"] environment:

observations:

  1. If no account is logged into the instance, every video plays.
  2. if you're logged into an existing account with subs/playlists, no video plays.
  3. if you create a brand new account, with no subs or playlists, every video plays.
  4. if you export invidious settings from import/export under settings, and import into the new account you just created, no video plays.

items # 3. and 4. have thrown me off in a loop. Not sure what is causing that. Any clues on what could be the reason?

Thank you all for your incredible hard work!! we shall prevail!! :)

MenacingMight commented 1 day ago

@DUOLabs333 yes I have it in my docker compose yaml. I even tried using the exact same compose file in the documentation and it's still the same. I also tried using a fresh backend but it didn't do anything.

MSWS commented 1 day ago

If anyone wants to keep rotating the tokens, I wrote this small script which you can run in a cronjob:

output=$(docker run quay.io/invidious/youtube-trusted-session-generator)

visitor_data=$(echo "$output" | awk -F': ' '/visitor_data/ {print $2}')
po_token=$(echo "$output" | awk -F': ' '/po_token/ {print $2}')

sed -i "s/visitor_data:.*/visitor_data: $visitor_data/" docker-compose.yml
sed -i "s/po_token:.*/po_token: $po_token/" docker-compose.yml

docker compose up -d invidious

A small enhancement I made to this script allows for specifying these variables in a .env instead of in the compose directly. Also added the --rm flag so we don't create a dangling container every time.

#!/usr/bin/env bash

output=$(docker run --rm quay.io/invidious/youtube-trusted-session-generator)

visitor_data=$(echo "$output" | awk -F': ' '/visitor_data/ {print $2}')
po_token=$(echo "$output" | awk -F': ' '/po_token/ {print $2}')

sed -i "s/VISITOR_DATA=.*/VISITOR_DATA=$visitor_data/" [PATH]/.env
sed -i "s/PO_TOKEN=.*/PO_TOKEN=$po_token/" [PATH]/.env

docker compose -f [PATH]/compose.yml up --force-recreate -d
DX37 commented 1 day ago

Any idea how to combine this inv_sig_helper with gluetun?

porchthecoder commented 11 hours ago

Have the same 403 issue as everyone else with an docker install. Started a few days ago. Added inv-sig-helper and that gets Medium/HD720/Small working with but not DASH. Proxy videos has no effect.

cpumaxx commented 7 hours ago

I'm having the same issue, and Debian stable doesn't have new enough rust to build inv-sig-helper. Is there another workaround?

kkwpsi commented 1 hour ago

Install rust & cargo locally:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh