Skip to content

Commit

Permalink
quality: nframes fix
Browse files Browse the repository at this point in the history
Fix: #16

Signed-off-by: Daniel Socek <[email protected]>
  • Loading branch information
dsocek authored and dvrogozh committed Aug 10, 2020
1 parent f2b1428 commit 7731e71
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 13 deletions.
1 change: 1 addition & 0 deletions doc/man/measure-quality.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ PROCESSING OPTIONS
------------------
--nframes|-n <uint>::
Process (encode, calculate metrics) this number of frames and stop.
If omitted or set to 0, all frames will be processed (default: 0).
--dry-run::
Do not execute any commands, but dump them to `stdout`.
Expand Down
5 changes: 4 additions & 1 deletion measure/quality/AVC/run_cbr_ffmpeg-qsv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ shift
bitrate=$(python3 -c 'print(int('$bitrate_Mbps' * 1000000))')
bufsize=$(python3 -c 'print(int('$bitrate' * 2))')

vframes="-frames:v $nframes"
[[ "$nframes" = "0" ]] && vframes=""

DEVICE=${DEVICE:-/dev/dri/renderD128}

cmd=(ffmpeg -hwaccel qsv -hwaccel_device $DEVICE -an \
$rawvideo -i $file -vframes $nframes \
$rawvideo -i $file $vframes \
-c:v h264_qsv -preset $preset -profile:v high -b:v $bitrate -maxrate $bitrate -minrate $bitrate \
-bufsize $bufsize \
$options \
Expand Down
5 changes: 4 additions & 1 deletion measure/quality/AVC/run_cbr_ffmpeg-ref.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ shift
bitrate=$(python3 -c 'print(int('$bitrate_Mbps' * 1000000))')
bufsize=$(python3 -c 'print(int('$bitrate' * 2))')

vframes="-frames:v $nframes"
[[ "$nframes" = "0" ]] && vframes=""

cmd=(ffmpeg -an \
$rawvideo -i $file -vframes $nframes \
$rawvideo -i $file $vframes \
-c:v libx264 $options -b:v $bitrate -maxrate $bitrate -minrate $bitrate -bufsize $bufsize -tune psnr \
-vsync 0 -y ${prefix}_${bitrate_Mbps}Mbps_CBR_REF.h264)

Expand Down
5 changes: 4 additions & 1 deletion measure/quality/AVC/run_cbr_sample-encode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ shift
bitrate=$(python3 -c 'print(int('$bitrate_Mbps' * 1000))')
bufsize=$(python3 -c 'print(int('$bitrate' / 4))')

vframes="-n $nframes"
[[ "$nframes" = "0" ]] && vframes=""

DEVICE=${DEVICE:-/dev/dri/renderD128}

cmd=(sample_encode -hw -device $DEVICE \
h264 -w $width -h $height -f $framerate -i $file \
-u $preset -b $bitrate -cbr -n $nframes \
-u $preset -b $bitrate -cbr $vframes \
$options \
-BufferSizeInKB $bufsize \
-o ${prefix}_${bitrate_Mbps}Mbps_CBR_SENC.h264)
Expand Down
5 changes: 4 additions & 1 deletion measure/quality/AVC/run_vbr_ffmpeg-qsv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ bitrate=$(python3 -c 'print(int('$bitrate_Mbps' * 1000000))')
maxrate=$(python3 -c 'print(int('$bitrate' * 2))')
bufsize=$(python3 -c 'print(int('$bitrate' * 4))')

vframes="-frames:v $nframes"
[[ "$nframes" = "0" ]] && vframes=""

DEVICE=${DEVICE:-/dev/dri/renderD128}

cmd=(ffmpeg -hwaccel qsv -hwaccel_device $DEVICE -an \
$rawvideo -i $file -vframes $nframes \
$rawvideo -i $file $vframes \
-c:v h264_qsv -preset $preset -profile:v high -b:v $bitrate -maxrate $maxrate \
-bufsize $bufsize \
$options \
Expand Down
5 changes: 4 additions & 1 deletion measure/quality/AVC/run_vbr_ffmpeg-ref.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ bitrate=$(python3 -c 'print(int('$bitrate_Mbps' * 1000000))')
maxrate=$(python3 -c 'print(int('$bitrate' * 2))')
bufsize=$(python3 -c 'print(int('$bitrate' * 4))')

vframes="-frames:v $nframes"
[[ "$nframes" = "0" ]] && vframes=""

cmd=(ffmpeg -an \
$rawvideo -i $file -vframes $nframes \
$rawvideo -i $file $vframes \
-c:v libx264 $options -b:v $bitrate -maxrate $maxrate -bufsize $bufsize -tune psnr \
-vsync 0 -y ${prefix}_${bitrate_Mbps}Mbps_VBR_REF.h264)

Expand Down
5 changes: 4 additions & 1 deletion measure/quality/AVC/run_vbr_sample-encode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ shift
bitrate=$(python3 -c 'print(int('$bitrate_Mbps' * 1000))')
bufsize=$(python3 -c 'print(int('$bitrate' / 2))')

vframes="-n $nframes"
[[ "$nframes" = "0" ]] && vframes=""

DEVICE=${DEVICE:-/dev/dri/renderD128}

cmd=(sample_encode -hw -device $DEVICE \
h264 -w $width -h $height -f $framerate -i $file \
-u $preset -b $bitrate -vbr -n $nframes \
-u $preset -b $bitrate -vbr $vframes \
$options \
-BufferSizeInKB $bufsize \
-o ${prefix}_${bitrate_Mbps}Mbps_VBR_SENC.h264)
Expand Down
5 changes: 4 additions & 1 deletion measure/quality/HEVC/run_cbr_ffmpeg-qsv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ shift
bitrate=$(python3 -c 'print(int('$bitrate_Mbps' * 1000000))')
bufsize=$(python3 -c 'print(int('$bitrate' * 2))')

vframes="-frames:v $nframes"
[[ "$nframes" = "0" ]] && vframes=""

DEVICE=${DEVICE:-/dev/dri/renderD128}

cmd=(ffmpeg -hwaccel qsv -hwaccel_device $DEVICE -an \
$rawvideo -i $file -vframes $nframes \
$rawvideo -i $file $vframes \
-c:v hevc_qsv -preset $preset -profile:v main -b:v $bitrate -maxrate $bitrate -minrate $bitrate \
-bufsize $bufsize \
$options \
Expand Down
5 changes: 4 additions & 1 deletion measure/quality/HEVC/run_cbr_ffmpeg-ref.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ shift
bitrate=$(python3 -c 'print(int('$bitrate_Mbps' * 1000000))')
bufsize=$(python3 -c 'print(int('$bitrate' * 2))')

vframes="-frames:v $nframes"
[[ "$nframes" = "0" ]] && vframes=""

cmd=(ffmpeg -an \
$rawvideo -i $file -vframes $nframes \
$rawvideo -i $file $vframes \
-c:v libx265 $options -b:v $bitrate -maxrate $bitrate -minrate $bitrate -bufsize $bufsize -tune psnr \
-vsync 0 -y ${prefix}_${bitrate_Mbps}Mbps_CBR_REF.h265)

Expand Down
5 changes: 4 additions & 1 deletion measure/quality/HEVC/run_cbr_sample-encode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ shift
bitrate=$(python3 -c 'print(int('$bitrate_Mbps' * 1000))')
bufsize=$(python3 -c 'print(int('$bitrate' / 4))')

vframes="-n $nframes"
[[ "$nframes" = "0" ]] && vframes=""

DEVICE=${DEVICE:-/dev/dri/renderD128}

cmd=(sample_encode -hw -device $DEVICE \
h265 -w $width -h $height -f $framerate -i $file \
-u $preset -b $bitrate -cbr -n $nframes \
-u $preset -b $bitrate -cbr $vframes \
$options \
-BufferSizeInKB $bufsize \
-o ${prefix}_${bitrate_Mbps}Mbps_CBR_SENC.h265)
Expand Down
5 changes: 4 additions & 1 deletion measure/quality/HEVC/run_vbr_ffmpeg-qsv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ bitrate=$(python3 -c 'print(int('$bitrate_Mbps' * 1000000))')
maxrate=$(python3 -c 'print(int('$bitrate' * 2))')
bufsize=$(python3 -c 'print(int('$bitrate' * 4))')

vframes="-frames:v $nframes"
[[ "$nframes" = "0" ]] && vframes=""

DEVICE=${DEVICE:-/dev/dri/renderD128}

cmd=(ffmpeg -hwaccel qsv -hwaccel_device $DEVICE -an \
$rawvideo -i $file -vframes $nframes \
$rawvideo -i $file $vframes \
-c:v hevc_qsv -preset $preset -profile:v main -b:v $bitrate -maxrate $maxrate \
-bufsize $bufsize \
$options \
Expand Down
5 changes: 4 additions & 1 deletion measure/quality/HEVC/run_vbr_ffmpeg-ref.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ bitrate=$(python3 -c 'print(int('$bitrate_Mbps' * 1000000))')
maxrate=$(python3 -c 'print(int('$bitrate' * 2))')
bufsize=$(python3 -c 'print(int('$bitrate' * 4))')

vframes="-frames:v $nframes"
[[ "$nframes" = "0" ]] && vframes=""

cmd=(ffmpeg -an \
$rawvideo -i $file -vframes $nframes \
$rawvideo -i $file $vframes \
-c:v libx265 $options -b:v $bitrate -maxrate $maxrate -bufsize $bufsize -tune psnr \
-vsync 0 -y ${prefix}_${bitrate_Mbps}Mbps_VBR_REF.h265)

Expand Down
5 changes: 4 additions & 1 deletion measure/quality/HEVC/run_vbr_sample-encode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ shift
bitrate=$(python3 -c 'print(int('$bitrate_Mbps' * 1000))')
bufsize=$(python3 -c 'print(int('$bitrate' / 2))')

vframes="-n $nframes"
[[ "$nframes" = "0" ]] && vframes=""

DEVICE=${DEVICE:-/dev/dri/renderD128}

cmd=(sample_encode -hw -device $DEVICE \
h265 -w $width -h $height -f $framerate -i $file \
-u $preset -b $bitrate -vbr -n $nframes \
-u $preset -b $bitrate -vbr $vframes \
$options \
-BufferSizeInKB $bufsize \
-o ${prefix}_${bitrate_Mbps}Mbps_VBR_SENC.h265)
Expand Down
2 changes: 1 addition & 1 deletion measure/quality/measure-quality
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,7 @@ options_ref=$(get_coding_commandline_options $codec $preset "ref" $use_vdenc)
options_qsv=$(get_coding_commandline_options $codec $preset "qsv" $use_vdenc)
options_senc=$(get_coding_commandline_options $codec $preset "senc" $use_vdenc)
vmaf_model_path=$(get_vmaf_model $resolution)
path=$(dirname $(readlink -f $0))

mkdir -p $outdir && cd $outdir
if [[ $? -ne 0 ]]; then
Expand All @@ -780,7 +781,6 @@ if [[ $? -ne 0 ]]; then
fi

if [ "$skip_encoding" = "no" ]; then
path=$(dirname $(readlink -f $0))
for b in ${bitrates[@]}; do
if [ "$is_yuv" = "no" ]; then
if [ "$skip_reference" = "no" ]; then
Expand Down

0 comments on commit 7731e71

Please sign in to comment.