Skip to content
TheChatArchiveThe Chat Archive
Mistralmixtral-8x7b-instruct-v0.1· Mistral AIHugging Face Arena Human Preference 55K

please rewrite this bash script in perl, keeping the same functionality (reading…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Upstagesolar-10.7b-instruct-v1.0’s answer.
  1. User

    please rewrite this bash script in perl, keeping the same functionality (reading arguments passed to the script), and also calling the same executables like the original (ffmpeg, rm, av1an)

    #!/bin/bash set -euo pipefail

    DIR="(dirname−−"(dirname -- "(readlink -f -- "0")")"source"0")")" source "DIR/../video.sh" Initialize variables with default values

    quality="" preset="" resize="" noise="" input_file="" Loop through the command-line arguments

    while [[ # -gt 0 ]]; do case 1 in -q | --quality) quality="2"shift2;;−p∣−−preset)preset="2" shift 2 ;; -p | --preset) preset="2" shift 2 ;; -r | --resize) resize="2"shift2;;−n∣−−noise)noise="2" shift 2 ;; -n | --noise) noise="2" shift 2 ;; *) input_file="$1" shift ;; esac done

    if [[ ! -f "inputfile"]];thenecho"FILENOTFOUND:input_file" ]]; then echo "FILE NOT FOUND: input_file" fi Check for required arguments

    if [[ -z quality]]∣∣[[−zquality ]] || [[ -z preset ]] || [[ -z inputfile]];thenecho"Usage:input_file ]]; then echo "Usage: 0 -q|--quality -p|--preset [-n|--noise ] [-r|--resize ] " exit 1 fi

    file_path=(readlink−f"(readlink -f "input_file") file_name=(get−filename"(get-filename "file_path")

    chunk_method="ffms2"

    output_name="filename.reencode.av1an.aom.rf{file_name}.reencode.av1an.aom.rf{quality}.ppreset"metadatacomment="reencodedwithav1an(aom),10−bit,cpu−used={preset}" metadata_comment="reencoded with av1an(aom), 10-bit, cpu-used={preset}, cq=quality,chunk−method={quality}, chunk-method=chunk_method"

    if [ -n "noise"];thenoutputname+=".noisenoise" ]; then output_name+=".noise{noise}" else noise=10 fi

    if [ -n "resize"];thenoutputname+=".resize" ]; then output_name+=".{resize}p" fi Supposedtly to work without L-SMASH: av1an -i "input" -y --resume --verbose --split-method av-scenechange -m hybrid -c mkvmerge -e rav1e --force -v " --tiles 8 -s 4 --quantizer 80 --no-scene-detection" --photon-noise 7 --chroma-noise --pix-format yuv420p10le -w 8 -o "output.mkv" --disable-kf --enable-fwd-kf=0 We're disabling keyframes cause Av1an already did scene detection, so we wont have to.. And it speeds things up. --kf-max-dist=9999 Maximum keyframe interval, we're setting it at the highest possible value since av1an's scene detection keyframe interval is already 240 by default --enable-chroma-deltaq=1 --enable-qm=1 --quant-b-adapt=1 Parameters that give you free efficiency boost, ignore it. --ffmpeg "-vf 'scale=-1:720'"
    --concat mkvmerge --chunk-method ffms2
    --workers 4 --set-thread-affinity=2 \ #does not seem to work on OSX, remember to also set --threads of the --video params to the same value as thread affinity --photon-noise=10 \ # for grain synthesis --chunk-method lsmash --sc-method fast --sc-downscale-height 320 \

    ulimit -n 2048

    threads=2

    av1an --verbose -i "filepath"−−encoderaom−−workers4−−resume−−extra−split300−−ignore−frame−mismatch−−audio−params"−an"−−ffmpeg"−anfile_path" --encoder aom --workers 4 --resume --extra-split 300 --ignore-frame-mismatch --audio-params " -an " --ffmpeg " -an ([[ -n "resize" ]] && echo " -vf 'scale=-1:{resize}'")" --split-method av-scenechange --chunk-method chunkmethod−−concatmkvmerge−−set−thread−affinity="chunk_method --concat mkvmerge --set-thread-affinity="threads" --photon-noise="noise"−−video−params"−−bit−depth=10−−threads=noise" --video-params " --bit-depth=10 --threads=threads --end-usage=q --cq-level=quality−−cpu−used=quality --cpu-used=preset --tile-columns=0 --tile-rows=0 --tune-content=psy --tune=ssim --lag-in-frames=64 --enable-keyframe-filtering=1 --disable-kf --kf-max-dist=9999 --enable-qm=1 --deltaq-mode=0 --aq-mode=0 --quant-b-adapt=1 --enable-fwd-kf=0 --arnr-strength=4 --sb-size=dynamic --enable-dnl-denoising=0 " -o "${output_name}.audioless.mkv" put the audio back and convert to mp4

    ffmpeg -loglevel warning -hide_banner -i "outputname.audioless.mkv"−i"{output_name}.audioless.mkv" -i "file_path" -c copy -map 0:v -map 1:a -metadata comment="metadatacomment""metadata_comment" "{output_name}.mp4"

    rm -rf "${output_name}.audioless.mkv"

    echo -e "\n\n" exa -al --color=always --no-permissions --no-user --time-style=long-iso "inputfile""input_file" "{output_name}.mp4"

    echo "" echo "video-compare "inputfile""input_file" "{output_name}.mp4""

    echo -e "\n✅ FINISHED"

  2. Mistral Assistant

    #!/usr/bin/perl use strict; use warnings; use File::Basename;

    my DIR=dirname(abs_file(__FILE__));require"DIR = dirname(abs\_file(\_\_FILE\_\_)); require "DIR/../video.pl"; Initialize variables with default values

    my quality;myquality; my preset; my resize;myresize; my noise; my $input_file;

    Loop through the command-line arguments

    while (@ARGV) { my arg=shift@ARGV;if(arg = shift @ARGV; if (arg eq '-q' || arg eq '--quality') { quality = shift @ARGV; } elsif (argeq′−p′∣∣arg eq '-p' || arg eq '--preset') { preset = shift @ARGV; } elsif (arg eq '-r' || arg eq '--resize') { resize = shift @ARGV; } elsif (argeq′−n′∣∣arg eq '-n' || arg eq '--noise') { noise = shift @ARGV; } else { input_file = $arg; } }

    if (!-f input\_file) { print STDERR "FILE NOT FOUND: input_file\n"; }

    Check for required arguments

    if (!defined(quality)∣∣!defined(quality) || !defined(preset) || !defined(input\_file)) { print STDERR "Usage: 0 -q|--quality -p|--preset [-n|--noise ] [-r|--resize ] <input_file>\n"; exit 1; }

    my (file_path,file\_path, file_name) = fileparse($input_file, qr/.[^.]*/);

    my $chunk_method = "ffms2";

    my output_name="output\_name = "file_name.reencode.av1an.aom.rfquality.pquality.ppreset"; my metadata_comment="reencodedwithav1an(aom),10−bit,cpu−used=metadata\_comment = "reencoded with av1an(aom), 10-bit, cpu-used=preset, cq=quality,chunk−method=quality, chunk-method=chunk_method";

    if (defined(noise)) { output_name .= ".noisenoise"; } else { noise = 10; }

    if (defined(resize)) { output_name .= ".${resize}p"; }

    my $threads = 2;

    my av1an_cmd=qq(av1an−−verbose−i"av1an\_cmd = qq(av1an --verbose -i "file_path" --encoder aom --workers 4 --resume --extra-split 300 --ignore-frame-mismatch --audio-params " -an " --ffmpeg " -an ); av1an_cmd.="−vf′scale=−1:av1an\_cmd .= " -vf 'scale=-1:{resize}'" if (defined(resize));resize)); av1an_cmd .= qq( --split-method av-scenechange --chunk-method chunk_method−−concatmkvmerge−−set−thread−affinity="chunk\_method --concat mkvmerge --set-thread-affinity="threads" --photon-noise="noise"−−video−params"−−bit−depth=10−−threads=noise" --video-params " --bit-depth=10 --threads=threads --end-usage=q --cq-level=quality−−cpu−used=quality --cpu-used=preset --tile-columns=0 --tile-rows=0 --tune-content=psy --tune=ssim --lag-in-frames=64 --enable-keyframe-filtering=1 --disable-kf --kf-max-dist=9999 --enable-qm=1 --deltaq-mode=0 --aq-mode=0 --quant-b-adapt=1 --enable-fwd-kf=0 --arnr-strength=4 --sb-size=dynamic --enable-dnl-denoising=0 " -o "$output_name.audioless.mkv");

    system($av1an_cmd);

    my ffmpeg_cmd=qq(ffmpeg−loglevelwarning−hidebanner−i"ffmpeg\_cmd = qq(ffmpeg -loglevel warning -hide_banner -i "output_name.audioless.mkv" -i "file_path"−ccopy−map0:v−map1:a−metadatacomment="file\_path" -c copy -map 0:v -map 1:a -metadata comment="metadata_comment" "output_name.mp4");system(output\_name.mp4"); system(ffmpeg_cmd);

    system("rm", "-rf", "$output_name.audioless.mkv");

    print "\n\n"; system("exa", "-al", "--color=always", "--no-permissions", "--no-user", "--time-style

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.