mpenkov / ffmpeg-tutorial

A set of tutorials that demonstrates how to write a video player based on FFmpeg
http://www.ffmpeg.org/documentation.html
1.22k stars 395 forks source link

Tuto7 : Async after seeking backwards #27

Open kherounts opened 9 years ago

kherounts commented 9 years ago

Hi The image and the audio are not synchronized anymore, once seeked backwards. The image seems to be in the correct position unlike the audio. However, the video becomes synchronized subsequently being seeked forwards once. Do you have any idea how to resolve this problem?

kherounts commented 9 years ago

Finally I found the solution. In the seek part of decode_thread() I changed :

if(is->audioStream >= 0) {
packet_queue_flush(&is->audioq);
packet_queue_put(&is->audioq, &flush_pkt);
}
if(is->videoStream >= 0) {
packet_queue_flush(&is->videoq);
packet_queue_put(&is->videoq, &flush_pkt);
}

to :

if(is->videoStream >= 0) {
packet_queue_flush(&is->videoq);
packet_queue_put(&is->videoq, &flush_pkt);
}
else if(is->audioStream >= 0) {
packet_queue_flush(&is->audioq);
packet_queue_put(&is->audioq, &flush_pkt);
}
mpenkov commented 9 years ago

Can you push your changes?