Reputation: 169
Because ffprobe is sometimes reporting invalid values for video duration, one recommanded way to get accurate video duration we often find on the web for this specific problem is to decode the file with ffmpeg null muxer and parse the "time=..." line.
ffmpeg -i file.mp4 -f null -
The problem with this solution is that this is very, very slow. I noticed the stream mapping with this solution is :
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> wrapped_avframe (native))
Stream #0:1 -> #0:1 (aac (native) -> pcm_s16le (native))
...
frame= 331 fps=115 q=-0.0 Lsize=N/A time=00:00:05.52 bitrate=N/A speed=1.92x
So I updated the previous command by adding "-c copy"
ffmpeg -i file.mp4 -c copy -f null -
Now the decoding process (is it really decoding?) is 600x faster !
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
frame=40109 fps=39085 q=-1.0 Lsize=N/A time=00:11:09.14 bitrate=N/A speed= 652x
Why is this solution not as popular as the previous one ? Video duration is still reported and seems to be as accurate as before.
Am I doing something wrong with this solution?
Upvotes: 1
Views: 658
Reputation: 93329
It's generally fine to use -c copy
. Occasionally, there may be small inaccuracies, as the decoder would emit frames in the correct order and discard non-frame packets. But we're talking small differences.
Upvotes: 0