Added a call to avformat_close_input in order to close the stream when done.