to go the the beginning of the file and start over the above again.
This works fine with avi file. But for mkv file, it doesn't work. The first approach gives me mkv demuxing errors, the second approach doesn't give me demuxing error but av_read_frame returns error -5.
What is the correct way to repeatedly play a file? How to make it work on Matroska file?