ffmpeg:video:size
This is an old revision of the document!
Table of Contents
ffmpeg - Video - Size
Using Perl Regex
ffmpeg -i "input.mkv" -c copy -f null /dev/null 2>&1 | tail -n 2 | grep -Po "(?<=video\:)([0-9]+)"
NOTE: Gets the size directly from ffmpeg.
Get the video size from the stream
ffprobe -v error -select_streams v:$i -show_entries stream=size -of default=noprint_wrappers=1:nokey=1 "input.mkv" | uniq
WARNING: This often returns N/A for some container formats, such as MKV.
Get the video size from the container
ffprobe -v error -select_streams v:0 -show_entries format=size -of default=noprint_wrappers=1:nokey=1 "input.mkv" | uniq
WARNING: This gets the entire container size, not just the video stream…
Calculate size manually using packet size
This method reads each video packet, individually, and totals up each packet size.
- Sums up the size attribute of -show_entries command.
video_sizes=$(ffprobe -v error -select_streams v:0 -skip_frame nokey -show_entries packet=size -of default=nokey=1:noprint_wrappers=1 "input.mkv") sum_video_size=0 precision=6 count_video_pkt_size=0 echo "Calculating video size..." for video_size in $video_sizes; do (( sum_video_size+=video_size )) (( count_video_size++ )) done; size=$( echo "scale=6; ${sum_video_size}" | bc)
ffmpeg/video/size.1748371541.txt.gz · Last modified: 2025/05/27 18:45 by peter