1def read_frame_as_jpg(in_filename, frame_num):
2 out, err = (
3 ffmpeg
4 .input(in_filename)
5 .filter_('select', 'gte(n,{})'.format(frame_num))
6 .output('pipe:', vframes=1, format='image2', vcodec='mjpeg')
7 .run(capture_stdout=True)
8 )
9 return out