Re-encode with ffmpeg using libx265 - rawvideo
For files already encoded to AVI, you'll have to extract the video to a raw HEVC stream first:

ffmpeg -i in.avi -c copy -map 0:v -f hevc in.265


and then

ffmpeg -framerate 30 -i in.265 -i in.avi -c copy -map 0:v -map 1:a -video_track_timescale 1k fixed.mp4


Replace the framerate value with the true rate of the video.



Encode new files to MP4 or MKV.

ffmpeg -i "$origFile" -map 0 -c copy -c:v libx265 -preset slow -crf 28 "newFile.mp4"