1

What is the best way to extract individual yuv frames from a yuv video? Can we use ffmpeg?

I'm able to extract individual jpg frames but am struggling to extract individual yuv frames. I know that I can write my own script in python to extract this as the frames in yuv videos are just stacked against each other in raw format but wondering if there's a command line command I can just use for this.

Pradheep Elango
  • 63
  • 2
  • 2
  • 4

1 Answers1

1

Using ffmpeg,

ffmpeg -f rawvideo -framerate 25 -s 1280x720 -pixel_format yuv420p -i in.yuv -c copy -f segment -segment_time 0.01 frames%d.yuv

Replace the framerate, size and pixel format with the correct values, of course.

Gyan
  • 34,439
  • 6
  • 56
  • 98
  • Thanks @mulvya! So the idea is to segment the video, and I should modify the segment_time such that only one frame is included in the segment? Will it be possible to precisely extract just one frame when fps is not integral (e.g: 24.58)? Should I first convert fps into 1 fps and then do this? Thanks! – Pradheep Elango Sep 09 '17 at 16:48
  • As long as segment_time is less than `1/fps`, each segment will be one frame. – Gyan Sep 09 '17 at 16:57
  • Oh yes of course. Thanks @mulvya! Do you know what I should change if I want to use mp4 (hevc/h265 encoding) as input. Is the only way to first convert to yuv video and then apply the above – Pradheep Elango Sep 09 '17 at 17:05
  • `ffmpeg -i in.mp4 -f segment -segment_time 0.01 frames%d.yuv` – Gyan Sep 09 '17 at 17:12