Created
April 27, 2016 19:01
-
-
Save vade/a48d2445262a3e94a51bfc12424c55ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while(av_read_frame(inputFormatContext, &avPacket) >= 0) | |
{ | |
// Decode Video | |
if( videoStreamIndex == avPacket.stream_index) | |
{ | |
int result = decodeVideo(inputVideoDecoderContext, videoFrame, &videoFrameCount, avPacket); | |
if(result > 0) | |
{ | |
// retime our frame ? | |
if (videoFrame->pts != AV_NOPTS_VALUE) | |
videoFrame->pts = av_rescale_q(avPacket.pts, outputVideoStream->codec->time_base, outputVideoStream->time_base); | |
AVPacket encodedPacket;// (AVPacket*)malloc(sizeof(AVPacket)); | |
av_init_packet(&encodedPacket); | |
encodedPacket.data = NULL; | |
encodedPacket.size = 0; | |
result = encodeVideo(outputVideoStream->codec, &encodedPacket, videoFrame); | |
if(result > 0) | |
{ | |
int write_ret = av_interleaved_write_frame(outputFormatContext, &encodedPacket); | |
if (write_ret < 0) | |
{ | |
fprintf(stderr, "Error writing frame\n"); | |
} | |
} | |
} | |
} | |
// Decode Audio | |
else if(audioStreamIndex == avPacket.stream_index) | |
{ | |
decodeAudio(inputAudioDecoderContext, audioFrame, &audioFrameCount, avPacket); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment