examples/muxing: simplify video PTS setting

Rely on frame_count. Also more consistent with audio path.
This commit is contained in:
Stefano Sabatini 2014-01-10 11:07:42 +01:00
parent 2ce4543286
commit d497141b85
1 changed files with 1 additions and 3 deletions

View File

@ -435,6 +435,7 @@ static void write_video_frame(AVFormatContext *oc, AVStream *st)
av_init_packet(&pkt); av_init_packet(&pkt);
/* encode the image */ /* encode the image */
frame->pts = frame_count;
ret = avcodec_encode_video2(c, &pkt, frame, &got_packet); ret = avcodec_encode_video2(c, &pkt, frame, &got_packet);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "Error encoding video frame: %s\n", av_err2str(ret)); fprintf(stderr, "Error encoding video frame: %s\n", av_err2str(ret));
@ -549,8 +550,6 @@ int main(int argc, char **argv)
return 1; return 1;
} }
if (frame)
frame->pts = 0;
for (;;) { for (;;) {
/* Compute current audio and video time. */ /* Compute current audio and video time. */
audio_time = audio_st ? audio_st->pts.val * av_q2d(audio_st->time_base) : 0.0; audio_time = audio_st ? audio_st->pts.val * av_q2d(audio_st->time_base) : 0.0;
@ -565,7 +564,6 @@ int main(int argc, char **argv)
write_audio_frame(oc, audio_st); write_audio_frame(oc, audio_st);
} else { } else {
write_video_frame(oc, video_st); write_video_frame(oc, video_st);
frame->pts++;
} }
} }