Skip to content

Conversation

@mback2k
Copy link
Contributor

@mback2k mback2k commented Jul 7, 2025

I had to create a fresh branch and PR due to being unable to check coverage with a PR originating from a branch named dev.

Description:

Support livestreaming of MPEG-TS based on the work described in #343:

Related issue (if applicable): fixes #343

Replaces #1051

Checklist:

  • Local tests with tox run successfully PR cannot be meged unless tests pass
  • Changes tested locally to ensure platform still works as intended
  • Tests added to verify new code works

@mback2k
Copy link
Contributor Author

mback2k commented Jul 7, 2025

@fronzbot I thought re-creating the PR from a different source branch would fix the coverage issue, but unfortunately it doesn't:
https://github.com/fronzbot/blinkpy/actions/runs/16125052803/job/45499949405?pr=1078

@mback2k mback2k marked this pull request as ready for review July 7, 2025 21:23
@mback2k
Copy link
Contributor Author

mback2k commented Jul 7, 2025

@fronzbot The tests are now 100% complete and this PR is ready for review, but there is one caveat: asyncio.timeout requires Python 3.11+, so if timing out reading the data is preferred which I would recommend, that would be needed.

Here again the code example to launch the MPEG-TS TCP server for a given camera:

import asyncio
import os.path
from aiohttp import ClientSession
from blinkpy.blinkpy import Blink
from blinkpy.auth import Auth, BlinkTwoFARequiredError
from blinkpy.helpers.util import json_load

async def start():
    session = ClientSession()
    blink = Blink(session=session)
    if os.path.exists("blink.json"):
        auth = Auth(await json_load("blink.json"), session=session)
        blink.auth = auth
    try:
        await blink.start()
    except BlinkTwoFARequiredError:
        await blink.prompt_2fa()
    await blink.save("blink.json")
    camera = blink.cameras["MyCamera"]
    stream = await camera.init_livestream()
    await stream.start()
    print(stream.url)
    await stream.feed()
    await session.close()


asyncio.run(start())

ffplay no longer requires additional arguments and just works with the stable stream like this:

ffplay tcp://127.0.0.1:<random-port>

I am looking forward to your feedback.

@mback2k mback2k force-pushed the livestreaming branch 2 times, most recently from 855b3d5 to 8768fe4 Compare July 31, 2025 19:58
@mback2k
Copy link
Contributor Author

mback2k commented Jul 31, 2025

@fronzbot Tests and CI are green now with the exception of the coverage due to an issue with CI:

Commit creating failed: {"message":"Token required because branch is protected"}

See https://github.com/fronzbot/blinkpy/actions/runs/16658736107/job/47150437518?pr=1078

@mback2k
Copy link
Contributor Author

mback2k commented Oct 18, 2025

@fronzbot I hope you are well, do you see any chance to move forward with this? I guess a lot of people would enjoy this, especially once I integrate this into the Home Assistant integration.

Copy link
Owner

@fronzbot fronzbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh man, totally forgot about this PR, I'm really sorry.

Only a small comment to move a function to prevent duplicate code 👍

@pablopezg
Copy link

Waiting for this change! Hopefully we will be able to have a lot of new possibilities in HA!

@mback2k
Copy link
Contributor Author

mback2k commented Oct 20, 2025

I am busy at the moment, but will update the PR as soon as possible.

@devernay
Copy link

I can confirm this works (or rather worked before the login API changes). It was not super stable and the lag was maybe 10 seconds or so (I tried different stream / ffmpeg configurations but could no fix it), but at least there was something, so I would say it's a good base for improvement. I think I only tested it with Minis.

@mback2k can you also rebase to current release? Is it supposed to work with doorbell/indoor/outdoor as well? Was it tested with these? If not do you need some help testing?

@mback2k mback2k force-pushed the livestreaming branch 2 times, most recently from 4fa4bfe to 4a1ef43 Compare October 27, 2025 20:26
@mback2k
Copy link
Contributor Author

mback2k commented Oct 27, 2025

I can confirm this works (or rather worked before the login API changes). It was not super stable and the lag was maybe 10 seconds or so (I tried different stream / ffmpeg configurations but could no fix it), but at least there was something, so I would say it's a good base for improvement. I think I only tested it with Minis.

Thanks for testing. In my tests I have the same ~6 second delay in stream initialization as with the Blink app itself, but once the stream is running it is quite smooth and stable.

@mback2k can you also rebase to current release? Is it supposed to work with doorbell/indoor/outdoor as well? Was it tested with these? If not do you need some help testing?

I have re-based / merged the current dev changes and indeed it works again. I have successfully tested Outdoor 3, Doorbell and Mini.

Coverage testing still fails the CI due to the lack of some token, would you mind taking a look at that @fronzbot?

@mback2k mback2k requested a review from fronzbot October 27, 2025 20:29
@fronzbot
Copy link
Owner

@mback2k yeah the coverage stuff broke awhile back and I haven't gotten around to fixing it, so it can just be ignored.

One point I want to clarify: you mentioned asyncio.timeout needing Python >3.11, but I didn't see a reference to that anywhere. Is this an improvement you think should be made and is not included in this PR? If so, I have no issue removing support for 3.9 and 3.10 if you want to make that change in a separate PR.

@mback2k
Copy link
Contributor Author

mback2k commented Oct 28, 2025

Thanks, I originally had the timeout in the code, but removed it since Blink servers will close the connection anyway if there is an issue with streaming. So, client side timeout enforcement is not necessarily needed as far as my testing showed.

@mback2k
Copy link
Contributor Author

mback2k commented Oct 28, 2025

Of course I can follow up with a separate PR for the timeout if needed.

@fronzbot fronzbot merged commit 1e868e2 into fronzbot:dev Oct 28, 2025
28 of 30 checks passed
@pablopezg
Copy link

One quick question, well, two indeed (sorry if they are stupid questions...):

  • Is the change already delivered? (I think it is)
  • How can it be used from Home Assistant?

@fronzbot
Copy link
Owner

The change is in the development version, but not in any version available on pip at the moment. Once I make a release, there will need to be extra work done to include it into home-assistant so it might be some time before that happens.

@pablopezg
Copy link

Ok, thank you for the clarification!

@mback2k
Copy link
Contributor Author

mback2k commented Nov 11, 2025

I already have a working updated HA integration locally and will work on a PR once this feature is released.

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

Successfully merging this pull request may close these issues.

get_liveview() returns a immis protocol link

4 participants