Advertisement
Guest User

Untitled

a guest
Apr 28th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. AVRational rational = { 1, 25 };
  2. output_codec_ctx->time_base = rational;
  3. output_codec_ctx->time_base.num = 1;
  4. output_codec_ctx->time_base.den = 25;
  5. output_codec_ctx->ticks_per_frame = 2;
  6. output_codec_ctx->gop_size = 10;
  7. output_codec_ctx->max_b_frames = 1;
  8. output_codec_ctx->debug = 1;
  9.  
  10. output_codec_ctx->pix_fmt = AV_PIX_FMT_YUV420P;
  11. output_codec_ctx->codec_id = AV_CODEC_ID_H264;
  12.  
  13. av_opt_set( output_codec_ctx->priv_data, "preset", "slow", 0 );
  14.  
  15. while (av_read_frame( input_format_ctx, packet ) >= 0 && running ) {
  16. if (packet->stream_index == videoIndex) {
  17.  
  18. avcodec_decode_video2( input_codec_ctx, pFrame, &got_picture, packet );
  19.  
  20. if (got_picture) {
  21.  
  22. sws_scale( swsCtx_, pFrame->data, pFrame->linesize, 0, output_codec_ctx->height, outFrame->data, outFrame->linesize );
  23. outFrame->pts = frame_count++;
  24.  
  25. outPacket->stream_index = stream->index;
  26. outPacket->pts = AV_NOPTS_VALUE;
  27. outPacket->dts = AV_NOPTS_VALUE;
  28.  
  29.  
  30. avcodec_encode_video2( output_codec_ctx, outPacket, outFrame, &got_output );
  31. if (got_output) {
  32.  
  33. av_interleaved_write_frame( output_format_ctx, outPacket );
  34. av_free_packet( outPacket );
  35. }
  36. }
  37. }
  38. av_free_packet( packet );
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement