Chocobozzz / PeerTube

ActivityPub-federated video streaming platform using P2P directly in your web browser
https://joinpeertube.org/
GNU Affero General Public License v3.0
12.78k stars 1.46k forks source link

View count for short videos #6430

Open xundeenergie opened 1 month ago

xundeenergie commented 1 month ago

Describe the problem to be solved

Since the last version views are counted, if a user watches a video for at least 10 seconds (instead of 30 or so in older versions). If a video is only 9 seconds, views are never counted...

Describe the solution you would like

Make the view-count dependent to the video length. If a video is shorter than the minimum view-length to be counted, every view should be counted.

Chocobozzz commented 1 month ago

If a video is only 9 seconds, views are never counted...

Is it something you notice from a PeerTube instance? PeerTube counts a view if the viewer watches 50% of the video if its length is < 10 seconds

xundeenergie commented 1 month ago

Yes.

It's this video https://tube.fediverse.at/w/a0b6c055-6639-4f51-a178-8f4805c0d1ea

Chocobozzz commented 1 month ago

Can you check in PeerTube logs if there are warnings/errors?

xundeenergie commented 1 month ago

I wrote the admin a message, to have a look on his logs.

ilsd commented 1 month ago

Thanks @xundeenergie for opening this issue! I just opened the log and watched the particular video from an other browser. These are the last lines:

warn[7.6.2024, 12:09:14] Warning in tracker.
{
  "err": {
    "stack": "Error: Unknown infoHash 76e796f1a66b431bf6532050814dd0d828dd654e requested by ip 194.24.158.220\n    at Server.filter [as _filter] (file:///var/www/peertube/versions/peertube-v6.1.0/dist/core/controllers/tracker.js:50:16)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)",
    "message": "Unknown infoHash 76e796f1a66b431bf6532050814dd0d828dd654e requested by ip 194.24.158.220"
  }
}
warn[7.6.2024, 12:12:28] Warning in tracker.
{
  "err": {
    "stack": "Error: Unknown infoHash 76e796f1a66b431bf6532050814dd0d828dd654e requested by ip 194.24.158.220\n    at Server.filter [as _filter] (file:///var/www/peertube/versions/peertube-v6.1.0/dist/core/controllers/tracker.js:50:16)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)",
    "message": "Unknown infoHash 76e796f1a66b431bf6532050814dd0d828dd654e requested by ip 194.24.158.220"
  }
}
warn[7.6.2024, 12:17:11] Warning in tracker.
{
  "err": {
    "stack": "Error: Unknown infoHash 76e796f1a66b431bf6532050814dd0d828dd654e requested by ip 194.24.158.220\n    at Server.filter [as _filter] (file:///var/www/peertube/versions/peertube-v6.1.0/dist/core/controllers/tracker.js:50:16)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)",
    "message": "Unknown infoHash 76e796f1a66b431bf6532050814dd0d828dd654e requested by ip 194.24.158.220"
  }
}
warn[7.6.2024, 12:20:30] Warning in tracker.
{
  "err": {
    "stack": "Error: Unknown infoHash 76e796f1a66b431bf6532050814dd0d828dd654e requested by ip 194.24.158.220\n    at Server.filter [as _filter] (file:///var/www/peertube/versions/peertube-v6.1.0/dist/core/controllers/tracker.js:50:16)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)",
    "message": "Unknown infoHash 76e796f1a66b431bf6532050814dd0d828dd654e requested by ip 194.24.158.220"
  }
}
warn[7.6.2024, 12:25:17] Warning in tracker.
{
  "err": {
    "stack": "Error: Unknown infoHash 76e796f1a66b431bf6532050814dd0d828dd654e requested by ip 2a02:ab8:201:1921:f932:a511:e844:7110\n    at Server.filter [as _filter] (file:///var/www/peertube/versions/peertube-v6.1.0/dist/core/controllers/tracker.js:50:16)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)",
    "message": "Unknown infoHash 76e796f1a66b431bf6532050814dd0d828dd654e requested by ip 2a02:ab8:201:1921:f932:a511:e844:7110"
  }
}
warn[7.6.2024, 12:25:17] Client log: HLS.js error: mediaError - fatal: false - bufferStalledError
{
  "tags": [
    "client"
  ],
  "userAgent": "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",
  "url": "https://tube.fediverse.at/w/a0b6c055-6639-4f51-a178-8f4805c0d1ea"
}

I started watching at about 12:25 local time (GMT+2:00).

My IP is 2a02:0ab8:0201:1921:f932:a511:e844:7110 or 94.136.7.81

Does that help @Chocobozzz to track down the bug?

Chocobozzz commented 1 month ago

Unfortunately no, I need info logs (or debug logs, that need to be enabled in PeerTube config: https://docs.joinpeertube.org/admin/logs)

ilsd commented 1 month ago

Thanks @Chocobozzz, here are files with the two log levels.

info.log debug.log

Chocobozzz commented 1 month ago

Please enable debug logs, restart peertube, watch de video using another web browser and paste them.

Can you also check error in all your logs that may be related to views processing?

ilsd commented 1 month ago

Seems as if restarting peertube (# systemctl restart peertube.service) resets the debug-level to Warnung. My impression is also, that this GUI does not change the debugging level but filters the view on it.

Bildschirmfoto 2024-06-10 um 11 45 22
Chocobozzz commented 1 month ago

Yes, as stated in the documentation you can change the log level in the PeerTube configuration

ilsd commented 1 month ago

Sorry, but I don't get the point. Imho I already did, what you asked me for.

Chocobozzz commented 1 month ago

How have you installed PeerTube? Using Docker or classic install?

ilsd commented 1 month ago

No docker, so probably classic.

Chocobozzz commented 3 weeks ago

Sorry for the late answer.

No docker, so probably classic.

Please ensure /var/www/peertube/config/production.yaml contains log.level: 'debug' (https://github.com/Chocobozzz/PeerTube/blob/develop/config/production.yaml.example#L253)

I suggest to also fix the PeerTube warnings, and so ensure the production.yaml contains all storage keys https://github.com/Chocobozzz/PeerTube/blob/develop/config/production.yaml.example#L147) defined in production.yaml.example as stated in the changelog (for example: https://github.com/Chocobozzz/PeerTube/blob/develop/CHANGELOG.md#important-notes-4)

ilsd commented 3 weeks ago

Thanks, now it makes sense to me :-) Attached the log-file with debug level. I started watching this video (https://tube.fediverse.at/w/a0b6c055-6639-4f51-a178-8f4805c0d1ea) at 11:10 / 11:11 GMT+2 (so 9:10 / 9:11 UTC) with Firefox. My IP was 2a02:ab8:201:1921:7887:15da:b043:5189 or 94.136.7.81.

Thanks also for the hint regarding the storage-paths. I fixed them before. Btw. I moved the whole storage-dir to an external CIFS-Cloud Server:

# ls -la /var/www/peertube/storage
lrwxrwxrwx 1 root root 13 Apr  2 16:25 /var/www/peertube/storage -> storage_cifs/

Would it make sense to e.g. have tmp on a local drive? Can I change that just by editing the production.yaml and write: tmp: '/var/www/peertube/local-storage/tmp/'?

peertube.log.zip

Chocobozzz commented 3 weeks ago

Thanks, I think I understood the problem. Using a remote storage mount point is not really supported by PeerTube that expects "fast" filesystem. You should use https://docs.joinpeertube.org/maintain/remote-storage instead.

For example in your case the IP country detection is too slow resulting in inconsistencies when counting a viewer.

Please try to put bin (https://github.com/Chocobozzz/PeerTube/blob/develop/config/production.yaml.example#L150) directory on your local disk, at least, to check if the issue persists.

ilsd commented 2 weeks ago

Thanks for looking into this and your hint! I changed some of the paths to local ones. (After having stopped peertube and moving the dirs of course.)

storage:
  tmp: '/var/www/peertube/storage_local/tmp/' # Use to download data (imports etc), store uploaded files before and during processing...
  tmp_persistent: '/var/www/peertube/storage_local/tmp-persistent/' # As tmp but the directory is not cleaned up between PeerTube restarts
  bin: '/var/www/peertube/storage_local/bin/'
  avatars: '/var/www/peertube/storage/avatars/'
  web_videos: '/var/www/peertube/storage/web-videos/'
  streaming_playlists: '/var/www/peertube/storage/streaming-playlists/'
  original_video_files: '/var/www/peertube/storage/original-video-files/'
  redundancy: '/var/www/peertube/storage/redundancy/'
  logs: '/var/www/peertube/storage/logs/'
  previews: '/var/www/peertube/storage/previews/'
  thumbnails: '/var/www/peertube/storage/thumbnails/'
  torrents: '/var/www/peertube/storage/torrents/'
  captions: '/var/www/peertube/storage/captions/'
  cache: '/var/www/peertube/storage/cache/'
  plugins: '/var/www/peertube/storage/plugins/'
  well_known: '/var/www/peertube/storage/well-known/'

(Reminder: storage is a symlink to an external cifs-drive)

I am not sure if it solves the problem reported by @xundeenergie.

Here is the logfile from after the change. I started viewing at 12:09 GMT+02 with Firefox. My IP is still 2a02:0ab8:0201:1921:f932:a511:e844:7110 or 94.136.7.81.

peertube.log.zip

S3-Storage

You should use https://docs.joinpeertube.org/maintain/remote-storage instead.

Im not sure how the guide you mentioned relates to my CIFS config. Or do you mean that I need to move away from CIFS? (Which doesn't seem like an easy step for me, as I have absolutely no clue about S3).

Chocobozzz commented 2 weeks ago

Your log stops on June 27 unfortunately. Can you retry to reproduce and paste the latest logs?

Im not sure how the guide you mentioned relates to my CIFS config. Or do you mean that I need to move away from CIFS? (Which doesn't seem like an easy step for me, as I have absolutely no clue about S3).

It's not related to your CIFS config. Network drives are not officially supported by PeerTube and may lead to weird bug like this one. I suggest to move use an external S3 provider instead to store videos.

ilsd commented 2 weeks ago

Thanks for your support so far. I don't want to waste your time by supporting an unsupported configuration. So I will solve this by switching to S3. IMHO you can close this issue. Thanks again!

Chocobozzz commented 2 weeks ago

Thanks for your support so far. I don't want to waste your time by supporting an unsupported configuration. So I will solve this by switching to S3. IMHO you can close this issue. Thanks again!

I'm just want to be sure it's the root cause of the issue: can you try to do the exact same thing you did in https://github.com/Chocobozzz/PeerTube/issues/6430#issuecomment-2186026147?

ilsd commented 2 weeks ago

I did my best. Problem was, that the logfiles were named in an chaotic way now. E.g. the file peertube.log was dated somewhere in June whereas peertube2.log was from today (files timestamp, not the content). Finally I tared all the logs just to be sure, removed all of them, restarted peertube-service and watched this video with firefox. Attached the logfile it created. peertube.log

P.S. log/ is on the CIFS drive as well.