全体をメモリにビデオファイルをアップロードするエラー

Valentyn:

私は、迅速なアクセスのためのRAMに全体のビデオファイルをアップロードしようとしています。私はそれが私が代わりにリモートドライバのRAM内の場所をポイントにしたいなど、任意のデコーディングすることなくそのままファイルになりたいです。ファイルは2 GBのみです。私は、128 GBのRAMを持っています。私は、フレーム解析によってフレームを行う必要があり、永遠に取り、サーバから準備を進め。

私は私がこのような何かをするだろうと思いました

with open('my_file.txt', 'r') as f:
    file_content = f.read() # Read whole file in the file_content string
print(file_content)

しかし、私はエラーことができます。それを行うための別の方法はありますか?IOライブラリを使用したような?

In [11]: u = open("/net/server/raw/2020.04.02/IMG_9261.MOV",'r')

In [12]: data = u.read()

---------------------------------------------------------------------------
UnicodeDecodeError                        Traceback (most recent call last)
<ipython-input-12-eecbc439fbf0> in <module>
----> 1 data = u.read()

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/codecs.py in decode(self, input, final)
    320         # decode input (taking the buffer into account)
    321         data = self.buffer + input
--> 322         (result, consumed) = self._buffer_decode(data, self.errors, final)
    323         # keep undecoded input until the next call
    324         self.buffer = data[consumed:]

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc9 in position 31: invalid continuation byte

この例の用途はrequests.getが、これは私がNFSでマウントすることができ、ローカルサーバーを持っているHTTPのためにのみ動作します

import requests
from pygame import mixer
import io

r = requests.get("http://example.com/somesmallmp3file.mp3")
inmemoryfile = io.BytesIO(r.content)

mixer.music.init()
mixer.music.load(inmemoryfile)
mixer.music.play()
フリードリヒ・S:

バイナリモードのための「b」を追加すると、それを動作させる必要があります。

u = open("/net/server/raw/2020.04.02/IMG_9261.MOV",'rb')

おすすめ

転載: http://10.200.1.11:23101/article/api/json?id=399551&siteId=1