4

I am trying to change a video's keyframe interval to be 1 following this link and using the command

ffmpeg -i myvideo.mp4 -vcodec libx264 -x264-params keyint=30:no-scenecut -acodec copy out.mp4

as indicated in the first answer. I wrote keyint=30 as my video's fps is 30, so 1*30=30. However, only the first frame's keyframe is 1, and all the rest remain 0 (as before the above command), as shown by the command ffprobe -select_streams v:0 -show_frames out.mp4 :

...
[FRAME]
media_type=video
stream_index=0
key_frame=1
pkt_pts=0
pkt_pts_time=0.000000
pkt_dts=0
pkt_dts_time=0.000000
best_effort_timestamp=0
best_effort_timestamp_time=0.000000
pkt_duration=512
pkt_duration_time=0.033333
pkt_pos=48
pkt_size=18693
width=560
height=320
pix_fmt=yuv420p
sample_aspect_ratio=N/A
pict_type=I
coded_picture_number=0
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
[/FRAME]
[FRAME]
media_type=video
stream_index=0
key_frame=0
pkt_pts=512
pkt_pts_time=0.033333
pkt_dts=512
pkt_dts_time=0.033333
best_effort_timestamp=512
best_effort_timestamp_time=0.033333
pkt_duration=512
pkt_duration_time=0.033333
pkt_pos=21764
pkt_size=199
width=560
height=320
pix_fmt=yuv420p
sample_aspect_ratio=N/A
pict_type=B
coded_picture_number=3
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
[/FRAME]
...

Any ideas?

Marievi
  • 4,951
  • 1
  • 16
  • 33
  • Your command is correct: it outputs an I-frame each second or 30 frames. If you want an I-frame only output then you need to set `keyint` to 1 not 30. – aergistal Sep 27 '17 at 10:56
  • @aergistal Thanks for your answer. I tried it, but again only the first frame has `keyframe = 1`... – Marievi Sep 27 '17 at 11:01

1 Answers1

5

Finally, I achieved what I wanted with the command :

ffmpeg -i myvideo.mp4 -qscale 0 -g 1 outputFile.mp4
Marievi
  • 4,951
  • 1
  • 16
  • 33