I found the solution: I have to rescale the pts and dts after encing the packet and before writing it. -- View this message in context: http://libav-users.943685.n4.nabble.com/Writing-mkv-files-with-libav-API-tp4657443p4657444.html Sent from the libav-users mailing list archive at Nabble.com.