Because i need play my videos on iPad, I wrote a nginx module which convert flv
fragment to mpeg-ts fragment.
But there is a problem, as the video plays the video and audio more and more
out of sync.
After 30min, it is out of sync very significant.
I have been working for that several days on this issue.
I need help.
Below is part of my code:
if(packet.stream_index==video_index){
if (packet.pts != (u_int)AV_NOPTS_VALUE)
{
packet.pts =
av_rescale_q(packet.pts,AV_TIME_BASE_NEW_Q,video_stream->time_base);
}
if (packet.dts != (u_int)AV_NOPTS_VALUE)
{
packet.dts =
av_rescale_q(packet.dts,AV_TIME_BASE_NEW_Q,video_stream->time_base);
}
if(video_bitstream_filters!=NULL)
{
ret =
write_frame(oc,&packet,video_stream->codec,video_bitstream_filters);
if (ret < 0)
{
fprintf(stderr, "Error:write_frame[video] error: %d\n",
ret);
}
}else{
ret = av_interleaved_write_frame(oc, &packet);
if (ret < 0)
{
fprintf(stderr, "Error:av_interleaved_write_frame[video]
error: %d\n", ret);
}
}
}else if(packet.stream_index==audio_index){
if (packet.pts != (u_int)AV_NOPTS_VALUE)
{
packet.pts =
av_rescale_q(packet.pts,audio_stream->codec->time_base,audio_stream->time_base);
}
if (packet.dts != (u_int)AV_NOPTS_VALUE)
packet.dts =
av_rescale_q(packet.dts,audio_stream->codec->time_base,audio_stream->time_base);
if (packet.duration > 0)
packet.duration =
av_rescale_q(packet.duration,audio_stream->codec->time_base,audio_stream->time_base);
ret = av_interleaved_write_frame(oc, &packet);
if (ret < 0)
{
fprintf(stderr, "Error:av_interleaved_write_frame[audio] error:
%d\n", ret);
}
}
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user