Get duration of a video using ffmpeg or avconv

First you should have the ffmpeg dev packages installed. Follow this post to install the required ffmpeg dev packages.

Step 1: Open a video file using the function avformat_open_input.

Step 2: Get stream information using the function call avformat_find_stream_info.

Step 3: Duration of the video can be obtained from member duration of AVFormatContext.

Make sure you add linker flags -lavformat -lavcodec while you compile it.

tejainece

Ravi Teja is a technology entrepreneur with interest in Embedded Systems, Software engineering, Operating Systems, Web development, Cloud computing, Machine learning, etc.

More Posts - Website

Follow Me:
LinkedInGoogle Plus