Gstreamer video recording duration

Hi, all
The pipeline uses nvv4l2h264enc, flvmux, filesink to record videos. How do I know the recorded duration/ encoded duration while recording?

You may try to set this:

$ export GST_DEBUG=*v4l2videoenc*:5

And then each frame to encoder is printed out.
For showing information on preview, may try either timeoverlay or clockoverlay

How can I get the GST_DEBUG message in main loop, not stdout ?