Guest User

Untitled

a guest
Mar 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. for(int i = 0; i<120;i++)
  2. {
  3. AVPacket pkt;
  4. av_init_packet(&pkt);
  5. ret = av_read_frame(inputFormatCtx, &pkt);
  6.  
  7. pkt.pts = pkt.dts = i;
  8. pkt.pts = av_rescale_q(pkt.pts, inputStream->time_base, outputStream->time_base);
  9. pkt.dts = av_rescale_q(pkt.dts, inputStream->time_base, outputStream->time_base);
  10.  
  11. ret = av_interleaved_write_frame(outputFormatCtx, &pkt);
  12. av_packet_unref(&pkt);
  13. }
  14. ret = av_write_trailer(outputFormatCtx);
  15.  
  16. for(int i = 0; i<120;i++){
  17. AVPacket pkt;
  18. av_init_packet(&pkt);
  19. ret = av_read_frame(inputFormatCtx, &pkt);
  20. packets.push_back(pkt);
  21. }
  22.  
  23. vector<AVPacket>::reverse_iterator it;
  24. int j = 0;
  25. for(it = packets.rbegin(); it != packets.rend(); it++){
  26. AVPacket n = (*it);
  27. n.pts = n.dts = j;
  28. j++;
  29. n.pts = av_rescale_q(n.pts, inputStream->time_base, outputStream->time_base);
  30. n.dts = av_rescale_q(n.dts, inputStream->time_base, outputStream->time_base);
  31. ret = av_interleaved_write_frame(outputFormatCtx, &n);
  32. av_packet_unref(&n);
  33. }
  34.  
  35. ret = av_write_trailer(outputFormatCtx);
  36.  
  37. [FRAME]
  38. media_type=video
  39. stream_index=0
  40. key_frame=1
  41. pkt_pts=0
  42. pkt_pts_time=0.000000
  43. pkt_dts=0
  44. pkt_dts_time=0.000000
  45. best_effort_timestamp=0
  46. best_effort_timestamp_time=0.000000
  47. pkt_duration=512
  48. pkt_duration_time=0.033333
  49. pkt_pos=48
  50. pkt_size=12974
  51. width=1920
  52. height=1080
  53. pix_fmt=yuv420p
  54. sample_aspect_ratio=N/A
  55. pict_type=I
  56. coded_picture_number=0
  57. display_picture_number=0
  58. interlaced_frame=0
  59. top_field_first=0
  60. repeat_pict=0
  61. [/FRAME]
  62. [FRAME]
  63. media_type=video
  64. stream_index=0
  65. key_frame=0
  66. pkt_pts=512
  67. pkt_pts_time=0.033333
  68. pkt_dts=512
  69. pkt_dts_time=0.033333
  70. best_effort_timestamp=512
  71. best_effort_timestamp_time=0.033333
  72. pkt_duration=512
  73. pkt_duration_time=0.033333
  74. pkt_pos=13022
  75. pkt_size=473
  76. width=1920
  77. height=1080
  78. pix_fmt=yuv420p
  79. sample_aspect_ratio=N/A
  80. pict_type=P
  81. coded_picture_number=1
  82. display_picture_number=0
  83. interlaced_frame=0
  84. top_field_first=0
  85. repeat_pict=0
  86. [/FRAME]
  87. [FRAME]
  88. media_type=video
  89. stream_index=0
  90. key_frame=0
  91. pkt_pts=1024
  92. pkt_pts_time=0.066667
  93. pkt_dts=1024
  94. pkt_dts_time=0.066667
  95. best_effort_timestamp=1024
  96. best_effort_timestamp_time=0.066667
  97. pkt_duration=512
  98. pkt_duration_time=0.033333
  99. pkt_pos=13495
  100. pkt_size=511
  101. width=1920
  102. height=1080
  103. pix_fmt=yuv420p
  104. sample_aspect_ratio=N/A
  105. pict_type=P
  106. coded_picture_number=2
  107. display_picture_number=0
  108. interlaced_frame=0
  109. top_field_first=0
  110. repeat_pict=0
  111. [/FRAME]
  112.  
  113. [FRAME]
  114. media_type=video
  115. stream_index=0
  116. key_frame=1
  117. pkt_pts=14848
  118. pkt_pts_time=0.966667
  119. pkt_dts=14848
  120. pkt_dts_time=0.966667
  121. best_effort_timestamp=14848
  122. best_effort_timestamp_time=0.966667
  123. pkt_duration=512
  124. pkt_duration_time=0.033333
  125. pkt_pos=757791
  126. pkt_size=65625
  127. width=1920
  128. height=1080
  129. pix_fmt=yuv420p
  130. sample_aspect_ratio=N/A
  131. pict_type=I
  132. coded_picture_number=58
  133. display_picture_number=0
  134. interlaced_frame=0
  135. top_field_first=0
  136. repeat_pict=0
  137. [/FRAME]
  138. [FRAME]
  139. media_type=video
  140. stream_index=0
  141. key_frame=0
  142. pkt_pts=15360
  143. pkt_pts_time=1.000000
  144. pkt_dts=15360
  145. pkt_dts_time=1.000000
  146. best_effort_timestamp=15360
  147. best_effort_timestamp_time=1.000000
  148. pkt_duration=512
  149. pkt_duration_time=0.033333
  150. pkt_pos=823416
  151. pkt_size=29642
  152. width=1920
  153. height=1080
  154. pix_fmt=yuv420p
  155. sample_aspect_ratio=N/A
  156. pict_type=P
  157. coded_picture_number=60
  158. display_picture_number=0
  159. interlaced_frame=0
  160. top_field_first=0
  161. repeat_pict=0
  162. [/FRAME]
  163. [FRAME]
  164. media_type=video
  165. stream_index=0
  166. key_frame=1
  167. pkt_pts=30208
  168. pkt_pts_time=1.966667
  169. pkt_dts=30208
  170. pkt_dts_time=1.966667
  171. best_effort_timestamp=30208
  172. best_effort_timestamp_time=1.966667
  173. pkt_duration=512
  174. pkt_duration_time=0.033333
  175. pkt_pos=1546454
  176. pkt_size=66021
  177. width=1920
  178. height=1080
  179. pix_fmt=yuv420p
  180. sample_aspect_ratio=N/A
  181. pict_type=I
  182. coded_picture_number=117
  183. display_picture_number=0
  184. interlaced_frame=0
  185. top_field_first=0
  186. repeat_pict=0
  187. [/FRAME]
Add Comment
Please, Sign In to add comment