How to calculate the length of the video file that was encoded so far? I am using ffmpeg to convert a video file to H.264 format. If I call ffprobe while ffmpeg is still running the duration of the video is not known. Only when ffmpeg finishes the ffprobe will display the duration.

Similar, if I run mplayer to play the video while it is still being encoded the duration is either unknown or displays incorrectly.

Is there a way to know duration of the resulted video (h264 in .mkv container) while it is still being encoded by ffmpeg?

Edit: I will make the question a little bit more clear.

I am interested in knowing how long is the video which was encoded so far. Let's say the input file is 1 minute 45 seconds long. The resulting file should preserve the length. But I would like to know how much did ffmpeg encode so far. If we can determine the length of the video after conversion is done, shouldn't there be a way to determine the length of the video that was already processed and ready to be played?
Short answer is No.

Longer answer is, it depends.

If you're encoding a file, then generally the output is the duration of the input, unless there's speed change or trim filters or -ss, -to, -t options applied. For a live input, FFmpeg will stop the encode when it encounters EOF on the input, so unless you know that, you won't know the output duration. For multiple inputs of differing duration, it will depend on what the command is e.g. is there a -shortest in there, is there an amix, which defaults to the longest of the inputs, or amerge which terminates upon the shortest input.

By default, the ffmpeg console readout will display the progress of the encoding in realtime i.e. the duration encoded, so far.