keep track of video_next_dts. Use it when packet dts is AV_NOPTS_VALUE. Also handle EAGAIN in send_packet_get_frame etc
parent
d03de98317
commit
f938fd83ac
|
@ -277,8 +277,8 @@ VideoStore::VideoStore(
|
||||||
#endif
|
#endif
|
||||||
video_first_pts = 0;
|
video_first_pts = 0;
|
||||||
video_first_dts = 0;
|
video_first_dts = 0;
|
||||||
video_last_pts = 0;
|
video_next_pts = 0;
|
||||||
video_last_dts = 0;
|
video_next_dts = 0;
|
||||||
|
|
||||||
audio_first_pts = 0;
|
audio_first_pts = 0;
|
||||||
audio_first_dts = 0;
|
audio_first_dts = 0;
|
||||||
|
@ -898,6 +898,8 @@ int VideoStore::writeVideoFramePacket(AVPacket *ipkt) {
|
||||||
video_first_dts = ipkt->dts;
|
video_first_dts = ipkt->dts;
|
||||||
}
|
}
|
||||||
opkt.dts = ipkt->dts - video_first_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 ) {
|
if ( ipkt->pts != AV_NOPTS_VALUE ) {
|
||||||
opkt.pts = ipkt->pts - video_first_dts;
|
opkt.pts = ipkt->pts - video_first_dts;
|
||||||
|
@ -906,6 +908,7 @@ int VideoStore::writeVideoFramePacket(AVPacket *ipkt) {
|
||||||
|
|
||||||
dumpPacket(video_out_stream, &opkt, "after pts adjustment");
|
dumpPacket(video_out_stream, &opkt, "after pts adjustment");
|
||||||
write_packet(&opkt, video_out_stream);
|
write_packet(&opkt, video_out_stream);
|
||||||
|
video_next_dts = opkt.dts + opkt.duration;
|
||||||
zm_av_packet_unref(&opkt);
|
zm_av_packet_unref(&opkt);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -934,8 +937,8 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) {
|
||||||
if ( audio_out_codec ) {
|
if ( audio_out_codec ) {
|
||||||
// I wonder if we can get multiple frames per packet? Probably
|
// I wonder if we can get multiple frames per packet? Probably
|
||||||
ret = zm_send_packet_receive_frame(audio_in_ctx, in_frame, *ipkt);
|
ret = zm_send_packet_receive_frame(audio_in_ctx, in_frame, *ipkt);
|
||||||
if ( ret <= 0 ) {
|
if ( ret < 0 ) {
|
||||||
Debug(3, "Not ready to receive frame");
|
Debug(3, "failed to receive frame code: %d", ret);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
zm_dump_frame(in_frame, "In frame from decode");
|
zm_dump_frame(in_frame, "In frame from decode");
|
||||||
|
|
Loading…
Reference in New Issue