I need to output an h.265 (or hevc, is the same) bit-stream onto an str file in python.
I have a bitstream file and i select some data from this file to save it to a new one. I use bitstring module to process the bitstream file.
Edit: My question is how to create a new bitstream file and insert data into.
Check out the part about Joining BitArrays (base class of BitStream) in this part of the bitstring documentation. How to join the substreams depends on how you have them in the first place.
For writing the bitstream to a file, use the method 'toFile' of the Bits class, which is a base class of BitStream.
f = open('fileToWriteTo', 'wb')
bitstreamObject.tofile(f)
If you want to write multiple substreams one after another, you can open the file in append mode the next times you write something.
f = open('fileToWriteTo', 'ab')
nextSubstream.tofile(f)