IO.write/2 expects character data / strings. You have arbitrary binary data and that does not map properly to that assumption. You want IO.binwrite/2.
That said, if you are doing significant multimedia work, you may wish to check out Membrane Framework in case it is useful / applicable to your needs.






















