{"action":"created","issue":{"url":"https://api.github.com/repos/mikeboers/PyAV/issues/448","repository_url":"https://api.github.com/repos/mikeboers/PyAV","labels_url":"https://api.github.com/repos/mikeboers/PyAV/issues/448/labels{/name}","comments_url":"https://api.github.com/repos/mikeboers/PyAV/issues/448/comments","events_url":"https://api.github.com/repos/mikeboers/PyAV/issues/448/events","html_url":"https://github.com/mikeboers/PyAV/issues/448","id":374307254,"node_id":"MDU6SXNzdWUzNzQzMDcyNTQ=","number":448,"title":"Data (not file or network protocol) interface to libav","user":{"login":"davidavdav","id":5497303,"node_id":"MDQ6VXNlcjU0OTczMDM=","avatar_url":"https://avatars0.githubusercontent.com/u/5497303?v=4","gravatar_id":"","url":"https://api.github.com/users/davidavdav","html_url":"https://github.com/davidavdav","followers_url":"https://api.github.com/users/davidavdav/followers","following_url":"https://api.github.com/users/davidavdav/following{/other_user}","gists_url":"https://api.github.com/users/davidavdav/gists{/gist_id}","starred_url":"https://api.github.com/users/davidavdav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidavdav/subscriptions","organizations_url":"https://api.github.com/users/davidavdav/orgs","repos_url":"https://api.github.com/users/davidavdav/repos","events_url":"https://api.github.com/users/davidavdav/events{/privacy}","received_events_url":"https://api.github.com/users/davidavdav/received_events","type":"User","site_admin":false},"labels":[{"id":899396031,"node_id":"MDU6TGFiZWw4OTkzOTYwMzE=","url":"https://api.github.com/repos/mikeboers/PyAV/labels/user%20help","name":"user help","color":"bfdadc","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":26,"created_at":"2018-10-26T09:46:43Z","updated_at":"2018-11-07T09:30:48Z","closed_at":null,"author_association":"NONE","body":"Hi, \r\n\r\nWe've been struggling (#445) with using libav to decode packets of compressed audio that come into our server via a dedicated websocket connection. \r\n\r\nIt appears that the only way to send data to libav is though some file name (which may actually be a URL of some sort).  So our solution is currently to use a unix named pipe, `av.open(pipe)` a container, then read packets, frames, from the stream in the container.  This worked OK-ish, until we hit #445. \r\n\r\n```python\r\n## consume reads data from a named pipe, and returns the data through framesq.\r\n## It should be called from a separate process. \r\n## Decompressed data is returned in a Queue framesq.\r\ndef consume(pipename, framesq, doneq, sr):\r\n    try:\r\n        container = av.open(pipename, \"r\", options={'max_delay': '10000'})\r\n        audio = container.streams[0]\r\n\r\n        resampler = av.AudioResampler(\r\n            format = av.AudioFormat(\"s16p\").packed,\r\n            layout = int(1),\r\n            rate = sr,\r\n        )\r\n\r\n        for packet in container.demux(audio):\r\n            for frame in packet.decode():\r\n                frame.pts = None\r\n                for i, plane in enumerate(frame.planes):\r\n                    frame = resampler.resample(frame)\r\n                    bytes = frame.planes[0].to_bytes()\r\n                    framesq.put(bytes)\r\n\r\n    except Exception as e:\r\n        logger.debug(\"Error in AV consumption: %r\", e)\r\n\r\n    doneq.put(True) ## signal end of data  \r\n```\r\n\r\nIn the light of solution #325, I've been experimenting with UDP and unix domain sockets to set up the transport of data, to circumvent the problem that ffmpeg options don't seem to make much of a difference.  However I can't get any of these to work (a boilerplate example would be appreciated:-). \r\n\r\nBut really, we would just want to send the actual compressed data (incl headers etc) to libav synchoneously, and receive the decompressed data out whenever libav has enough information to output another frame.  But we can't find an entry to pyav / libav / ffmpeg do do such a thing, hence the workaround above.  \r\n\r\nDoes anyone know if it would be possible to get a chunk-by-chunk implementation of the decoding?\r\n"},"comment":{"url":"https://api.github.com/repos/mikeboers/PyAV/issues/comments/436561013","html_url":"https://github.com/mikeboers/PyAV/issues/448#issuecomment-436561013","issue_url":"https://api.github.com/repos/mikeboers/PyAV/issues/448","id":436561013,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNjU2MTAxMw==","user":{"login":"jlaine","id":1567624,"node_id":"MDQ6VXNlcjE1Njc2MjQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1567624?v=4","gravatar_id":"","url":"https://api.github.com/users/jlaine","html_url":"https://github.com/jlaine","followers_url":"https://api.github.com/users/jlaine/followers","following_url":"https://api.github.com/users/jlaine/following{/other_user}","gists_url":"https://api.github.com/users/jlaine/gists{/gist_id}","starred_url":"https://api.github.com/users/jlaine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlaine/subscriptions","organizations_url":"https://api.github.com/users/jlaine/orgs","repos_url":"https://api.github.com/users/jlaine/repos","events_url":"https://api.github.com/users/jlaine/events{/privacy}","received_events_url":"https://api.github.com/users/jlaine/received_events","type":"User","site_admin":false},"created_at":"2018-11-07T09:30:48Z","updated_at":"2018-11-07T09:30:48Z","author_association":"COLLABORATOR","body":"PR #453 has been merged, so I'm closing this issue."}}
{"actor":{"display_login":"jlaine"}}