stdin is a stream, so it isn't seekable. If you want to know its length, you must read data until you get EOF. If you need to DO something with that data, you need to store it somehow since it will be lost as you read it.

One possibility is to copy the data to a temporary file as you read it in. Then you can open this file and seek in it.