start_encoding and add_stream cleanup
use avio_closep