GithubHelp home page GithubHelp logo

muxinc / mux-python Goto Github PK

View Code? Open in Web Editor NEW
47.0 42.0 13.0 1.05 MB

Official Mux API wrapper for python projects, supporting both Mux Data and Mux Video.

License: MIT License

Python 94.29% Shell 0.10% Makefile 0.04% Mustache 5.58% Ruby 0.01%
mux video video-streaming video-processing video-analytics python

mux-python's Issues

DeprecationWarning: HTTPResponse.getheaders() is deprecated and will be removed in urllib3 v2.1.0

When using mux-python I get this warning:

DeprecationWarning: HTTPResponse.getheaders() is deprecated and will be removed in urllib3 v2.1.0. Instead access HTTPResponse.headers directly.

The problem is here at this line:

return self.urllib3_response.getheaders()

It should be changed to:

return self.urllib3_response.headers

If I prepare a pull request, are you willing to accept it? Thanks

Impossible to import Exceptions

A number of exceptions are thrown by muxpython but none of them can by caught by clients because:

  1. They are not exported.
  2. the function rest() in __init__.py is making it impossible to import them directly from rest.py

The simplest solution would be to export them all in __init__.py.

I'm happy to make a pull request if you'd like?

Example of how to upload a video

Hi,

I am struggling to use this library to upload videos to Mux. I have read through the documentation, ReadMe and examples in this repo. I have also been through the process of uploading to Mux using the web UI.

I can see the DirectUploadsApi and example makes what seems to be a "pre-request to upload", which returns a Google Storage URL to upload to and the info I need about where the upload will go/be called etc. But I seem to be missing the methods or documentation that then use or describe what I need to do with that URL to actually do the upload.

Any help or guidance would be much appreciated! I think the TODO in https://github.com/muxinc/mux-python/blob/master/examples/video/exercise-uploads.py is probably what I need?

"# TODO: At some point I'd like to actually perform an upload here and check the state changes etc. but I don't have time right now."

Thanks

Documentation for creating audio-only assets

Is there any documentation on creating audio-only assets? I see the announcement from years ago that it became available as a feature, but I'm struggling to find relevant documentation.

Create .mp4 stream instead of m3u8

Hello, I am trying to create the mp4 format stream for playback. However setting the parameter :
new_asset_settings = mux_python.CreateAssetRequest(playback_policy=[mux_python.PlaybackPolicy.PUBLIC], mp4_support = "standard")

This gives the response :
'new_asset_settings': {'input': None, 'master_access': None, 'mp4_support': 'standard', 'normalize_audio': False, 'passthrough': None, 'per_title_encode': None, 'playback_policy': None, 'test': None},

How can I use .mp4 format with the playback ID to make it work?

Realtime engagement counts not working properly for views

Hello!
I’m trying to obtain data for the real-time engagement counts. but looks like it’s not working correctly.
I use code from the example, like a

# video_id = ''  # Enter your video id here
    signing_key_id = '2pFHlr6WB9npEwHvONm8CRTZOxjpJHXyPCpjEGDIwZI'  # Enter your signing key id here
    private_key_base64 = 'HERE IS THE PRIVATE KEY AS IT WAS RECEIVED FROM DASHBOARD'  # Enter your base64 encoded private key here

    private_key = base64.b64decode(private_key_base64)
    time_issued = int(time.time()) + 3600
    payload = {
        'vid': video_id,
        'exp': time_issued,  # 1 hour
        'kid': signing_key_id
    }
    encoded = jwt.encode(payload, private_key, algorithm="RS256")
    return jsonify({
        'result': {
            'token': encoded,
            'expire': time_issued
        }
    })

So, if i use it like this - i will receive python error binascii.Error: Incorrect padding . It can be fixed with simple adding == at the end of private key string, and after that code is working fine - i receive encoded token.
But when I try to hit the url https://stats.mux.com/counts?token=TOKEN_TEXT_HERE i receive error :

{
    "error": {
        "type": "forbidden",
        "messages": [
            "Signing key not found."
        ]
    }
}

Anything we can do here?

Change "hls_segment_type" from .ts to .fmp4

Hello, Currently my live stream is broadcasting the chunks in ".ts" format. I would like to change the "HLS_segement_type" to .fmp4. Is there a parameter I can tune to convert the .ts chunk into .fmp4?

Upload local file(not from URL) and get playbackID as response

Hello.

Case 1: Use the MUX direct upload SDK for react

I created a component for frontend which works but the problem there is that the response from event doesn't contain the playbackID for the uploaded video. I find the video on my MUX assets, but I want to get the playbackID directly from response and that is not there. Is something I miss here?

Case 2: Uploade video from python wrapper

I can upload an asset using mux-python package, but when I want to upload it, it's required the video URL... I want to upload a file in my platform, so it would be a local file (not an URL). Can you help me here?

My goal is to upload a video (with the upload interface from MUX-UPLOADER or by creating my own interface in frontend) and get as a response the assetID and playbackID which I will store in my DB to be able to create a video content platform.

Thanks

Uploading asset in Python is not working

Hi

This is my code to upload my video to Mux via Python:

assets_api = mux_python.AssetsApi(mux_python.ApiClient(configuration))

# Create an Asset
input_settings = [mux_python.InputSettings(url=modelVideoFirebaseURL)]
create_asset_request = mux_python.CreateAssetRequest(input=input_settings, playback_policy=[mux_python.PlaybackPolicy.PUBLIC])
create_asset_response = assets_api.create_asset(create_asset_request=create_asset_request)

However, when I upload it I cannot view it in Assets (it says video is not public and is not viewable).

Also, when I view my video client side it says "Unsupported error" and that it is not playable on my browser.. But if I play a directly uploaded video on my client side it works.. The API does not work. Please help

Could we add license information to PyPI metadata?

Hello!

Currently pip show mux-python returns blank License info:

Name: mux-python
Version: 3.10.0
Summary: Mux API
Home-page: https://github.com/muxinc/mux-python
Author: Mux DevEx
Author-email: [email protected]
License:
Location: ...
Requires: python-dateutil, six, urllib3
Required-by:

Some company's custom package index might check for eligible values in License field before allowing the package to be added. Curious if we could add the license info here? Thanks!

Lower video resolution before download

Is there such an option? E.g. defining the width and height of the video before downloading it with mux_python.AssetsApi(mux_python.ApiClient(config)).get_asset()?

How to enable MP4 on already created asset

Dear coolleagues. Thanks so much for the amazing work done.

I am trying to update an asset, just like presented here, but passing the asset id to be updated from the list I got from assets_api.list_assets(), instead of an assets_api.create_asset(create_asset_request) object.

Error message I got is:

mux_python.exceptions.NotFoundException: (404)
Reason: Not Found
HTTP response headers: HTTPHeaderDict({'Cache-Control': 'max-age=0, private, must-revalidate', 'Content-Length': '121', 'Content-Type': 'application/json; charset=utf-8', 'Date': 'Thu, 16 Sep 2021 12:57:44 GMT', 'Server': 'Mux API Server v1.131.2', 'X-Request-Id': 'FqVOyN_5MDLCiXUBWLmD'})
HTTP response body: {"error":{"type":"not_found","messages":["The requested resource either doesn't exist or you don't have access to it."]}}

The asset id exists and is the correct one. So, I am wondering if:

  • to do an update I need a special access?
  • to update an asset the same must be an recently created asset and not an old one?

thanks in advance

"max_continuous_duration" parameter

Please add an example for "max_continuous_duration". There is no example available on how to use the "duration" parameter for a live stream.
I am not able to find how to set the duration in API request.
I am getting the following error : "'Server': 'Mux API Server v1.158.3', 'X-Request-Id': 'FvnrJ5bJcVMDeN0Hi62B'})
HTTP response body: {"error":{"type":"invalid_parameters","messages":["Cannot use max continuous duration with test live streams"]}}"

Additional cases where UnauthorizedException may raise?

Are there undocumented situations which might cause Mux to return a 401 (and therefore cause the client to raise an UnauthorizedException)?

I can't really share the code, but I can share the context:

  • We are connecting to Mux via the Python client to create assets and create/delete tracks.
  • We are currently using the same database locally and when deployed to production.
  • We are currently using the same codebase locally and when deployed to production.
  • We are currently using the same access tokens locally and when deployed to production.

Attempts to create or delete assets functions well enough in local. Attempts to create or delete assets raises an UnauthorizedException across our development, staging, and production environments.

The kicker, though, is that this all worked as recently as a week ago, and there were no new deploys to our production system before the issues started arising.

I'm wondering if there is potential that Mux would blacklist a server? All of our environments are deployed via managed Docker containers in DigitalOcean, so that seems the most noteworthy similarity between the three environments having issue.

Direct Upload Signed URL PUT failing with CORS error

I generated a signed_url by passing appropriate cors_origin as per my domain yet the generated URL, I am unable to PUT the video file from browser.

Here is the error I am getting:
Access to fetch at 'https://storage.googleapis.com/video-storage-us-east1-....' from origin 'https://youreact.tv' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

And here is my backend code that generates the signed URL:

uploads_api = mux_python.DirectUploadsApi(mux_python.ApiClient(configuration))

create_asset_request = mux_python.CreateAssetRequest(playback_policy=[mux_python.PlaybackPolicy.PUBLIC],passthrough="123")

create_upload_request = mux_python.CreateUploadRequest(timeout=3600, new_asset_settings=create_asset_request, cors_origin="https://youreact.tv")

create_upload_response = uploads_api.create_direct_upload(create_upload_request)

and here is the client side code that tries to PUT the video file:

const upload = async (file) => {

        const upload = UpChunk.createUpload({
            endpoint: '{{ signed_url }}',                
            file: file            
        });

        console.log("res:",upload) 
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.