keep track of video_next_dts. Use it when packet dts is AV_NOPTS_VALUE. Also handle EAGAIN in send_packet_get_frame etc

pull/2714/head^2
Isaac Connor 2019-10-16 09:01:59 -04:00
parent d03de98317
commit f938fd83ac
1 changed files with 7 additions and 4 deletions

View File

@ -277,8 +277,8 @@ VideoStore::VideoStore(
#endif
video_first_pts = 0;
video_first_dts = 0;
video_last_pts = 0;
video_last_dts = 0;
video_next_pts = 0;
video_next_dts = 0;
audio_first_pts = 0;
audio_first_dts = 0;
@ -898,6 +898,8 @@ int VideoStore::writeVideoFramePacket(AVPacket *ipkt) {
video_first_dts = ipkt->dts;
}
opkt.dts = ipkt->dts - video_first_dts;
} else {
opkt.dts = av_rescale_q(video_next_dts, video_out_stream->time_base, video_in_stream->time_base);;
}
if ( ipkt->pts != AV_NOPTS_VALUE ) {
opkt.pts = ipkt->pts - video_first_dts;
@ -906,6 +908,7 @@ int VideoStore::writeVideoFramePacket(AVPacket *ipkt) {
dumpPacket(video_out_stream, &opkt, "after pts adjustment");
write_packet(&opkt, video_out_stream);
video_next_dts = opkt.dts + opkt.duration;
zm_av_packet_unref(&opkt);
return 0;
@ -934,8 +937,8 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) {
if ( audio_out_codec ) {
// I wonder if we can get multiple frames per packet? Probably
ret = zm_send_packet_receive_frame(audio_in_ctx, in_frame, *ipkt);
if ( ret <= 0 ) {
Debug(3, "Not ready to receive frame");
if ( ret < 0 ) {
Debug(3, "failed to receive frame code: %d", ret);
return 0;
}
zm_dump_frame(in_frame, "In frame from decode");