Skip to content

[Discussion] Bottleneck of the project #157

Description

@MasterInQuestion

    After some analysis [ https://github.com/richtr/NoSleep.js/issues/68#issuecomment-1510390259 ], the bottleneck (reliability, performance, etc.) of the project appears much originated from the video used to exploit the WakeLock.
    .
    To address which, the following has to be determined:
    |1| What video (both container and stream) format to use, that should best fit the needs?
    |1.1| The format should be supported by as many browsers as possible. [ Only Chromium and Firefox, and mostly mobile: need to be considered. ]
    |1.2| Ideally, the decoding should consume as little resource as possible. (least possible arithmetic complexity)
    |1.3| Would uncompressed formats work? (as the content doesn't really matter)
    |1.4| What's the minimum possible image size? And frame rate? (how long can a single frame be stretched (through time metadata manipulation) to last?)
    .
    |2| Is the presence of audio stream really necessary?
    |2.1| If audio must present, would a single frame audio (duration unmatching the video) just suffice?

    @GyanD, @boardhead,
    Would you mind providing some insights?


=== Reference info ===

    NoSleep.js @ 2ebb9011f7849d033e0c9250e49b9e2f09dc6bf6 (CE 2020-12-15 23:58:20 UTC):
[[
> ffprobe -hide_banner -threads 0 -show_entries "stream=time_base:format=size" -of "flat=h=0" "0.m4v"

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '0.m4v':
  Metadata:
    major_brand     : M4V
    minor_version   : 512
    compatible_brands: isomiso2avc1
    encoder         : Lavf55.33.100
  Duration: 00:00:01.06, start: 0.000000, bitrate: 28 kb/s
  Stream #0:0[0x1](und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(progressive), 176x144 [SAR 1:1 DAR 11:9], 8 kb/s, 29.97 fps, 29.97 tbr, 30k tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 3 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
stream.0.time_base="1/30000"
stream.1.time_base="1/48000"
format.size="3753"

> ffprobe -hide_banner -threads 0 -show_entries "stream=time_base:format=size" -of "flat=h=0" "0.webm"

Input #0, matroska,webm, from '0.webm':
  Metadata:
    encoder         : Lavf55.33.100
  Duration: 00:00:01.05, start: 0.000000, bitrate: 42 kb/s
  Stream #0:0: Video: vp8, yuv420p(progressive), 176x144, SAR 1:1 DAR 11:9, 25 fps, 25 tbr, 1k tbn (default)
  Stream #0:1: Audio: vorbis, 48000 Hz, stereo, fltp (default)
stream.0.time_base="1/1000"
stream.1.time_base="1/1000"
format.size="5577"
]]
(same files as @ 7a34e29dc5608193b999ecd1825f421d4a270a64)
    .
    NoSleep.js @ 7a34e29dc5608193b999ecd1825f421d4a270a64 (CE 2015-04-21 08:11:15 UTC):
[[
> ffprobe -hide_banner -threads 0 -show_entries "stream=time_base:format=size" -of "flat=h=0" "0.ogv"

Input #0, ogg, from '0.ogv':
  Duration: 00:00:01.05, start: 0.000000, bitrate: 60 kb/s
  Stream #0:0: Video: theora, yuv444p, 176x144 [SAR 1:1 DAR 11:9], 25 fps, 25 tbr, 25 tbn
    Metadata:
      encoder         : Lavf55.33.100
  Stream #0:1: Audio: vorbis, 48000 Hz, stereo, fltp, 112 kb/s
    Metadata:
      encoder         : Lavf55.33.100
stream.0.time_base="1/25"
stream.1.time_base="1/48000"
format.size="7854"
]]

    NoSleep.js @ 4cc289bea129b0351e6290fba9bdb2ad0bd127da (CE 2015-04-23 13:36:54 UTC):
[[
> ffprobe -hide_banner -threads 0 -show_entries "stream=time_base:format=size" -of "flat=h=0" "1.mp4"

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    creation_time   : 1970-01-01T00:00:00.000000Z
    encoder         : Lavf52.78.3
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0[0x1](und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 8x8 [SAR 1:1 DAR 1:1], 1k tbn (default)
    Metadata:
      creation_time   : 1970-01-01T00:00:00.000000Z
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
stream.0.time_base="1/1000"
format.size="808"

> ffprobe -hide_banner -threads 0 -show_entries "stream=time_base:format=size" -of "flat=h=0" "1.webm"

Input #0, matroska,webm, from '1.webm':
  Metadata:
    encoder         : whammy
  Duration: 00:00:01.00, start: 0.000000, bitrate: 1 kb/s
  Stream #0:0: Video: vp8, yuv420p(progressive), 8x8, SAR 1:1 DAR 1:1, 1k tbr, 1k tbn (default)
stream.0.time_base="1/1000"
format.size="185"

> ffprobe -hide_banner -threads 0 -show_entries "stream=time_base:format=size" -of "flat=h=0" "1.ogv"

Input #0, ogg, from '1.ogv':
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: theora, yuv420p, 8x8 [SAR 1:1 DAR 1:1], 1k tbr, 1k tbn
    Metadata:
      encoder         : Lavf52.78.3
stream.0.time_base="1/1000"
format.size="3402"
]]
    The very WebM was added back @ 016580ddd200ff6e7a12f0904c314e3ee2c9bae1 (CE 2018-12-04 07:12:10 UTC); also used by StayAwake.js.
    The MP4 may not play normally in the browser.

    NoSleep.js @ 83edf7779fa1b4a87b67587da5d8250ca14c40f9 (CE 2017-07-04 00:31:09 UTC):
[[
> ffprobe -hide_banner -threads 0 -show_entries "stream=time_base:format=size" -of "flat=h=0" "2.mp4"

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '2.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 2017-07-03T23:23:11.000000Z
    encoder         : HandBrake 0.10.2 2015061100
  Duration: 00:00:02.04, start: 0.000000, bitrate: 18 kb/s
  Stream #0:0[0x1](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 202x202, 6 kb/s, 30 fps, 30 tbr, 90k tbn (default)
    Metadata:
      creation_time   : 2017-07-03T23:23:11.000000Z
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
    Metadata:
      creation_time   : 2017-07-03T23:23:11.000000Z
      handler_name    : Stereo
      vendor_id       : [0][0][0][0]
stream.0.time_base="1/90000"
stream.1.time_base="1/44100"
format.size="4841"
]]
(also used by StayAwake.js)

    mil-no-sleep:
[[
> ffprobe -hide_banner -threads 0 -show_entries "stream=time_base:format=size" -of "flat=h=0" "mil-no-sleep.mp4"

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'mil-no-sleep.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.42.101
  Duration: 00:00:03.00, start: 0.000000, bitrate: 7 kb/s
  Stream #0:0[0x1](und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(progressive), 20x20, 5 kb/s, 23.98 fps, 23.98 tbr, 24k tbn (default)
    Metadata:
      handler_name    : L-SMASH Video Handler
      vendor_id       : [0][0][0][0]
stream.0.time_base="1/24000"
format.size="3000"
]]
(also used by lovelace-wallpanel before)

    lovelace-wallpanel @ 69ec1c29531665ca266c279b8e3dd82abb69d94e (CE 2023-03-31 18:11:41 UTC):
[[
> ffprobe -hide_banner -threads 0 -show_entries "stream=time_base:format=size" -of "flat=h=0" "lovelace-wallpanel.mp4"

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'lovelace-wallpanel.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf59.27.100
  Duration: 00:00:10.00, start: 0.000000, bitrate: 1 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 8x8 [SAR 1:1 DAR 1:1], 0 kb/s, 1 fps, 1 tbr, 16384 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
      encoder         : Lavc59.37.100 libx264
stream.0.time_base="1/16384"
format.size="1838"
]]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions