Attempt to simply shutdown sequence to avoid race between vidoe and write threads. Can no longer join on write thread from write thread. Also use codecpar instead of deprecated codec member.