Saya telah menulis skrip pembungkus interaktif untuk desktop unix untuk alasan ini, dan setelah satu tahun penggunaan, saya senang membagikannya di sana!
Dibuat dengan byzanz
, gifsicle
, xdotool
, dan script ditulis dalam php
.
Contoh output:
[1020px, lebar gif tidak diubah ukuran 1020px, 70 detik, 50 warna, 65Kb ]
Ini memberikan gif terkompresi yang baik, dan merupakan karya yang bagus untuk pertanyaan ini.
Ini adalah basis yang cukup sederhana, siap untuk diretas oleh Anda.
Fungsi : Gif record pada posisi mouse atau layar penuh, mengubah ukuran, kompresi, kompresi warna, membalikkan / menggabungkan, unggahan ikal giphy.com.
Untuk memulai catatan gif 10 detik: gif 10
Untuk merekam beberapa kali dengan parameter yang sama: gif !
Untuk memulai catatan gif layar penuh 5 detik: gif 5 --fullscreen
Script runnning, dengan senang hati merekam dirinya sendiri:
[ 45 detik, lebar 645px, penuh warna, 976kb ]
Skrip 5kb penuh:
#!/usr/bin/php
<?php
#> php xdotool byzanz gifsicle curl
#@ https://webdev23.github.io/gif/gif
echo "Usage: ./gif [time in seconds|!] [--fullscreen|-f]\n";
echo "--------------------------------------------------\n";
echo "Gif recorder tool\n";
echo "gif ! to call back last settings\n";
echo "Please move your mouse at the top left corner point\n";
echo "of the wanted gif area. Then press enter.\n";
echo "\n";
#~ Nico KraZhtest | 05/2017 | https://github.com/webdev23/gif
#~ Create fluid GIF's fastly
#~ You can set the gif record time as argument: ./gif 10
#~ Default record time is 1 seconde, or set it now:
$recordTime = 1;
#~ ----------------
$t = @$argv[1];
$x1;$y1;$x2;$y2;$gw;$gh;$defc;$rw;
if (!isset($argv[1]) || @$argv[1] === "!") {
$t = $recordTime;
}
if (@$argv[1] === "!") {
$pos = file_get_contents("./.config/gif/pos");
$pos = explode("\n", $pos);
$x1 = $pos[0];
$y1 = $pos[1];
$x2 = $pos[2];
$y2 = $pos[3];
$gw = $pos[4];
$gh = $pos[5];
$t = $pos[6];
@$GLOBALS['defc'] = $pos[7];
@$GLOBALS['$rw'] = $pos[8];
#~ echo $x1." ".$y1." ".$x2." ".$y2." ".$gw." ".$gh." ".$t." ".$defc." ".@$rw;
}
else if (@$argv[2] === "fullscreen" || @$argv[2] === "--fullscreen" || @$argv[2] === "-f" || @$argv[2] === "f") {
echo "############\nStarting fullscreen record\n";
$fs = system("xdpyinfo | grep 'dimensions:'");
echo "\n";
$fs = explode(" ",$fs);
echo $fs[1];
$fs = explode(" ",$fs[1]);
echo $fs[0];
$fs = explode("x",$fs[0]);
echo $fs[0]."\n";
echo $fs[1];
$x1 = "0";
$y1 = "0";
$x2 = "fs";
$y2 = "fs";
$gw = $fs[0];
$gh = $fs[1];
$t = $argv[1];
system("mkdir -p ./.config/gif/");
system("cd ./.config/gif/ && \
echo '$x1\n$y1\n$x2\n$y2\n$gw\n$gh\n$t\n\n\n\n' > pos");
}
else {
$stdin = fopen('php://stdin', 'r');
$response = rtrim(fgets(STDIN));
$p1 = system("xdotool getmouselocation");
$pos1 = explode(" ",$p1);
$x1 = $pos1[0];
$x1 = explode(":",$x1);
$x1 = $x1[1];
echo "X1: ".$x1;
$y1 = $pos1[1];
$y1 = explode(":",$y1);
$y1 = $y1[1];
echo " Y1: ".$y1;
echo "\nNow move your mousse at the bottom right corner.\nThen enter\n";
$stdin = fopen('php://stdin', 'r');
$response = rtrim(fgets(STDIN));
$p2 = system("xdotool getmouselocation");
$pos2 = explode(" ",$p2);
$x2 = $pos2[0];
$x2 = explode(":",$x2);
$x2 = $x2[1];
echo "X2: ".$x2;
$y2 = $pos2[1];
$y2 = explode(":",$y2);
$y2 = $y2[1];
echo " Y2: ".$y2;
$gw = ($x2 - $x1);
echo "\nGif width: ".$gw;
$gh = ($y2 - $y1);
echo "\nGif height: ".$gh;
echo "\n".$x1." ".$y1." ".$x2." ".$y2." ".$gw." ".$gh." ".$t."\n";
system("mkdir -p ./.config/gif/");
system("cd ./.config/gif/ && \
echo '$x1\n$y1\n$x2\n$y2\n$gw\n$gh\n$t\n\n\n\n' > pos");
}
$unix = date_timestamp_get(date_create());
echo "\n".$unix." | Starting ".$t."s gif record\n";
@system("byzanz-record \
-v \
--duration=$t \
--x=$x1 \
--y=$y1 \
--width=$gw \
--height=$gh \
~/Pictures/gif$unix.gif");
$named = "gif".$unix;
echo "Saved as ~/Pictures/".$named.".gif\n";
echo "\nOptimize | How many colors to keep? (default 100, max 256) \n";
if (@$argv[1] === "!"){
$pos = file_get_contents("./.config/gif/pos");
$pos = explode("\n", $pos);
$defc = $pos[7];
}
if (!isset($defc)){
$defc = readline("Colors: ");
}
if (empty($defc)){
$defc = "100";
}
echo "\nKeeping ".$defc." colors\n";
system("gifsicle --verbose -i ~/Pictures/$named.gif -O5 --colors=$defc -o ~/Pictures/$named\_reduced.gif");
echo "\nOptimize | Resize width in pixels (default 360px) \n";
if (@$argv[1] === "!"){
$pos = file_get_contents("./.config/gif/pos");
$pos = explode("\n", $pos);
$rw = $pos[8];
}
if (!isset($rw)){
$rw = readline("Width : ");
}
if (empty($rw)){
$rw = "360";
}
echo "\nResized by ".$rw." pixels width\n";
@system("gifsicle --verbose -i ~/Pictures/$named\_reduced.gif --resize-width $rw -o ~/Pictures/".$named."_optimized.gif");
$opt = "~/Pictures/".$named."_optimized.gif";
usleep(5000000);
echo "\nSpecial | Reverse and merge?\n";
system("xdg-open ~/Pictures/".$named."_optimized.gif > /dev/null");
if (@$argv[1] === "!"){
$pos = file_get_contents("./.config/gif/pos");
$pos = explode("\n", $pos);
$rev = $pos[9];
}
if (!isset($rev)){
$stdin = fopen('php://stdin', 'r');
$rev = rtrim(fgets(STDIN));
$rev = "1";
}
if (!isset($rev)){
$rev = "0";
}
@system("cd ./.config/gif/ && sed -i '8s/.*/$defc/' pos");
@system("cd ./.config/gif/ && sed -i '9s/.*/$rw/' pos");
@system("cd ./.config/gif/ && sed -i '10s/.*/$rev/' pos");
if ($rev === "1"){
@system("gifsicle \
-i ~/Pictures/$named\_reduced.gif \
'#-2-1' \
-o ~/Pictures/".$named."_reversed.gif");
$inv = "~/Pictures/".$named."_reversed.gif";
usleep(400000);
@system("gifsicle \
-i ~/Pictures/$named\_reduced.gif \
--append $inv \
--resize-width $rw \
-o ~/Pictures/".$named."_merged.gif");
usleep(3000000);
system("xdg-open ~/Pictures/".$named."_merged.gif > /dev/null");
}
echo "\n####################";
echo "\nUpload to giphy.com?\n";
$stdin = fopen('php://stdin', 'r');
$response = rtrim(fgets(STDIN));
$m = "~/Pictures/".$named."_merged.gif";
$f = system("du -h $m");
$f = explode(" ",$f);
$f = $f[1];
$www = system('curl \
--progress-bar \
-v \
-F "file=@'.$f.'" \
-F "api_key=dc6zaTOxFJmzC" \
"http://upload.giphy.com/v1/gifs"');
$www = json_decode($www);
echo "\n\nhttps://i.giphy.com/".$www->data->id.".gif\n";
echo "\nThanks YOU!\n";
Kemampuan membalikkan / menggabungkan, untuk membuat barang artistik.
Asli (435kb)
Terbalik, digabung: (826kb)
Untuk menginstal, menggunakan phi :
php <(curl https://webdev23.github.io/phi/phi) install https://webdev23.github.io/gif/gif
Layar penuh:
[1920 * 1080px, gif 400px, 50 detik , 100 warna, 2Mb ]
Sumber, dengan beberapa penjelasan lebih lanjut dan potensi pembaruan:
https://github.com/webdev23/gif