ffmpeg:video:duration
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
ffmpeg:video:duration [2025/05/27 18:24] – peter | ffmpeg:video:duration [2025/05/27 18:34] (current) – [By Packet duration_time] peter | ||
---|---|---|---|
Line 22: | Line 22: | ||
<WRAP info> | <WRAP info> | ||
- | **NOTE: | + | **NOTE: |
+ | |||
+ | * This returns an estimate of the duration based on the bitrate and size of the file. | ||
</ | </ | ||
Line 47: | Line 50: | ||
</ | </ | ||
- | < | + | < |
- | **NOTE:** This returns the duration of the entire container, and not just the duration of the video. | + | **WARNING:** This returns the duration of the entire container, and not just the duration of the video. |
</ | </ | ||
Line 60: | Line 63: | ||
<code bash> | <code bash> | ||
- | video_pkt_durations=$(ffprobe -v error -select_streams v:$i -skip_frame nokey -show_entries packet=duration_time -of default=nokey=1: | + | video_pkt_durations=$(ffprobe -v error -select_streams v:0 -skip_frame nokey -show_entries packet=duration_time -of default=nokey=1: |
sum_video_pkt_duration=0 | sum_video_pkt_duration=0 | ||
Line 68: | Line 71: | ||
#echo " | #echo " | ||
for video_pkt_duration in $video_pkt_durations; | for video_pkt_duration in $video_pkt_durations; | ||
- | sum_video_pkt_duration=$( echo " | + | sum_video_pkt_duration=$(echo " |
(( count_video_pkt_duration++ )) | (( count_video_pkt_duration++ )) | ||
done; | done; | ||
- | video_duration=$( echo " | + | video_duration=$( echo " |
echo " | echo " | ||
echo "VIDEO FRAMES=${count_video_pkt_duration}" | echo "VIDEO FRAMES=${count_video_pkt_duration}" | ||
</ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Calculate duration using Size and Bitrate ===== | ||
+ | |||
+ | <code bash> | ||
+ | duration=$( echo " | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Calculate duration using Size and Bitrate ===== | ||
+ | |||
+ | <code bash> | ||
+ | duration = NUMBER_OF_FRAMES / FPS | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | </ | ||
---- | ---- | ||
ffmpeg/video/duration.1748370265.txt.gz · Last modified: 2025/05/27 18:24 by peter