Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AVRational rational = { 1, 25 };
- output_codec_ctx->time_base = rational;
- output_codec_ctx->time_base.num = 1;
- output_codec_ctx->time_base.den = 25;
- output_codec_ctx->ticks_per_frame = 2;
- output_codec_ctx->gop_size = 10;
- output_codec_ctx->max_b_frames = 1;
- output_codec_ctx->debug = 1;
- output_codec_ctx->pix_fmt = AV_PIX_FMT_YUV420P;
- output_codec_ctx->codec_id = AV_CODEC_ID_H264;
- av_opt_set( output_codec_ctx->priv_data, "preset", "slow", 0 );
- while (av_read_frame( input_format_ctx, packet ) >= 0 && running ) {
- if (packet->stream_index == videoIndex) {
- avcodec_decode_video2( input_codec_ctx, pFrame, &got_picture, packet );
- if (got_picture) {
- sws_scale( swsCtx_, pFrame->data, pFrame->linesize, 0, output_codec_ctx->height, outFrame->data, outFrame->linesize );
- outFrame->pts = frame_count++;
- outPacket->stream_index = stream->index;
- outPacket->pts = AV_NOPTS_VALUE;
- outPacket->dts = AV_NOPTS_VALUE;
- avcodec_encode_video2( output_codec_ctx, outPacket, outFrame, &got_output );
- if (got_output) {
- av_interleaved_write_frame( output_format_ctx, outPacket );
- av_free_packet( outPacket );
- }
- }
- }
- av_free_packet( packet );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement