create file similar to text file creation
By this, I assume, that you are following as example of setting up producer and consumer, sending text/json messages over kafka.
In your case, you need serialise your video file/piece/chunk to bytes, send raw bytes to kafka, read those in consumer and deserialise your video file/piece/chunk back.
To send raw bytes through kafka, you need to use ByteArraySerializer
in producer and ByteArrayDeserializer
in consumer.
See:
https://kafka.apache.org/20/javadoc/index.html?org/apache/kafka/common/serialization/ByteArrayDeserializer.html
https://kafka.apache.org/20/javadoc/org/apache/kafka/common/serialization/ByteArraySerializer.html
So, in your configuration you need to specify properties( assuming that you don't use keys, only values):
producer:
"key.serializer":"org.apache.kafka.common.serialization.StringSerializer"
"value.serializer":"org.apache.kafka.common.serialization.ByteArraySerializer"
consumer:
"key.deserializer":"org.apache.kafka.common.serialization.StringDeserializer"
"value.deserializer":"org.apache.kafka.common.serialization.ByteArrayDeserializer"
If you just want to sent an mp4 file, read it as bytes like this (in java):
File to byte[] in Java
byte[] array = Files.readAllBytes(new File("/path/to/file").toPath());
On the other side, in consumer, you receive that byte array and save them to file.