Skip to content

Instantly share code, notes, and snippets.

@lindenle
Created March 10, 2014 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lindenle/72fab989fc053a89c6c0 to your computer and use it in GitHub Desktop.
Save lindenle/72fab989fc053a89c6c0 to your computer and use it in GitHub Desktop.
//set teh timestamp to 0 before we start
pReadFrame->pts = 0;
while (av_read_frame(pReadFormatCtx, &readPkt) >= 0) {
AVPacket origPkt = readPkt;
do {
lastPTSValue = pReadFrame->pts;
//the decode packet blows away the last values
ret = decode_packet(&gotFrame, 0);
fprintf(stdout,"pts/dts read: %lld\n",pReadFrame->pts);
pReadFrame->pts = lastPTSValue;
if (ret < 0)
break;
fprintf(stdout,"pts/dts read: %lld\n",pReadFrame->pts);
//what type of frame was this
if ( pWriteVideo_st && readPkt.stream_index == readVideoStreamIdx ) {
write_video_frame(pWriteFormatCtx, pWriteVideo_st);
pReadFrame->pts += av_rescale_q(1, pWriteVideo_st->codec->time_base, pWriteVideo_st->time_base);
} else if (pWriteAudio_st && readPkt.stream_index == readAudioStreamIdx) {
write_audio_frame(pWriteFormatCtx,pWriteAudio_st);
} else {
fprintf(stderr,"Something bad happened in decode");
return -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment