Hot answers tagged

68

OK then I started ffcast, did vim, quit ffcast, then converted .avi→.gif. I ran the recording commands in another terminal. Polished script for your $PATH at the end of this answer. What happened? Capturing FFcast helps the user interactively select a screen region and hands over the geometry to an external command, such as FFmpeg, for screen ...


50

found a solution: identify, part of the imagemagick package, does exactly what I need $ identify color.jpg > color.jpg JPEG 1980x650 1980x650+0+0 8-bit DirectClass 231KB 0.000u 0:00.000


45

Rather than parsing the output of identify by eye, or by text utilities, you can use its -format option to output the width and height in whatever format suits you best. For example: $ identify -format '%w %h' img.png 100 200 $ identify -format '%wx%h' img.png 100x200 A list of image properties that you can output can be found on this page, but for the ...


22

This can easily be done using ImageMagick identify -format '%n %i\n' -- *.gif 12 animated.gif 1 non_animated.gif identify -format %n prints the number of frames in the gif; for animated gifs, this number is bigger than 1. (ImageMagick is probably readily available in your distro's repositories for an easy install)


16

you can just use the command "file" to get the informations you need: ~# file cha_2.png cha_2.png: PNG image data, 656 x 464, 8-bit/color RGB, non-interlaced


11

For me, the answer was to use ffcast with ffmpeg like so: ffcast -w % ffmpeg -f x11grab -show_region 1 -framerate 20 -video_size %s -i %D+%c -codec:v huffyuv -vf crop="iw-mod(iw\\,2):ih-mod(ih\\,2)" out.avi I then used ffmpeg to do the conversion from avi to gif - it's very fast and it keeps the framerate intact: ffmpeg -i out.avi -pix_fmt rgb24 out.gif ...


9

Using exiftool: exiftool -q -if '$framecount > 1' -p '$directory/$filename' -r -ext:gif . Would report the paths of the GIF files that have more than one frame (in the current directory, recursively).


6

There is probably a better way to do it, but here is what I would do First, split your animation in frames convert animation.gif +adjoin temp_%02d.gif Then, select one over n frames with a small for-loop in which you loop over all the frames, you check if it is divisible by 2 and if so you copy it in a new temporary file. j=0; for i in $(ls temp_*gif); ...


5

Use identify to see the sizes : $ identify color.jpg > color.jpg JPEG 1980x650 1980x650+0+0 8-bit DirectClass 231KB 0.000u 0:00.000 Extract value via cut | sed, from field 3: identify ./color.jpg | cut -f 3 -d " " | sed s/x.*// #width identify ./color.jpg | cut -f 3 -d " " | sed s/.*x// #height Asign to variable: W=`identify ./color.jpg | cut -f 3 -...


5

Another way with im using the fx operator: find . -type f -name \*.gif -exec sh -c \ 'identify -format "%[fx:n>1]\n" "$0" | grep -q 1' {} \; -print This searches the current directory and its subdirectories for .gif images running that shell command for each .gif found. If number of frames n>1 then fx prints 1, otherwise it prints 0. This is piped to ...


5

You can you use nearly any web-browser, as they should play gifs just fine.


4

If you'd like to avoid dependencies, you might also consider sxiv. It can play animated gifs using the -a flag, and only depends on imlib2.


4

To create an animated GIF using command line, I would use the excellent command line tools from the package Imagemagick: convert -delay 10 *.gif animation.gif


3

You can use the following command for f in ./*.flv; do ffmpeg -i "$f" -vf scale=320:-1 "${f%.*}.gif" done This iterates over all files ending with .flv in the current directory, processing them and changing the extension to .gif. Note that the file names must not contain spaces for this to work. Alternatively, on a GNU system, you can use find . -...


3

Your script works just fine, but you need to zero pad your individual frame names; otherwise it creates the gif with frames in a jumbled order. I fixed that and tried it on a few giphy webp animations (including your example) and the output is what you'd expect. Below is just your script with two changes. First, an altered for loop to zero pad those frame ...


2

There is an alternate version of MBR's answer, as a bash function: gif_framecount_reducer () { # args: $gif_path $frames_reduction_factor local orig_gif="${1?'Missing GIF filename parameter'}" local reduction_factor=${2?'Missing reduction factor parameter'} # Extracting the delays between each frames local orig_delay=$(gifsicle -I "$orig_gif"...


2

Both display and file are quite slow, and have the potential to bring even quite capable systems to their knees dealing with many multiple files. A small test: $ du -h *.png --total | tail -n 1 9.2M total $ ls -l *.png | wc -l 107 $ /usr/bin/time file *.png --> 0.37user 0.26system 0:06.93elapsed 9%CPU (0avgtext+0avgdata ...


2

Gifs cannot be manipulated in that way by appending. It's disappointing, I know. I'd written a detailed explanation of the file format here, but Wikipedia explains it better. This is why appending with cat doesn't work. There aren't many "simple" formats, but I'd take a bet that .bmp is one of the simplest, containing a semi-raw pixel array and metadata.


2

for my setup(ubuntu 16.04), ffcast doesn't work well as it's not updated on github for quite a while. so I put up a script using slop(https://github.com/naelstrof/slop) and ffmpeg. an example: #!/bin/bash read -r X Y W H G ID < <(slop -f "%x %y %w %h %g %i") TMP_AVI=$(mktemp /tmp/outXXXXXXXXXX.avi) ffmpeg -s "$W"x"$H" -y -f x11grab -i :0.0+$X,$Y ...


2

This repository help you to create your gif from selection region and also optimize it for you https://github.com/devlifeX/record-screen-gif


2

the standard Tool for manipulating GIF images is gifsicle ... here is the syntax to combine several animated gif files gifsicle g1.gif g2.gif g3.gif > combo.gif then to view it just issue open combo.gif


2

You are probably using a lot of ram and causing swapping. A simple test using /usr/bin/time -v in front of the command when run on say 5 files, and again on 10 files will show that the Maximum resident set size is approximately double for twice as many files. So rather than doing them all at once, convert them one at a time, or say ten at a time, then ...


2

Yes. While asciinema doesn't provide this natively, there are tools out there that can facilitate that for you. You can create your local recording like so: asciinema rec my_recording.json And then feed that into a tool like asciicast2gif: ./asciicast2gif my_recording.json my_recording.gif


2

You can make a looping GIF by setting a bit in the header of the file (been doing that since 1989), but there is no such facility that I know of in the .mp4 files. For them looping is controlled via an additional, player dependent, file. The absence of that also is the reason why you don't have any looping .mp4 on YouTube.


2

I would have used ffmpeg for this task. Have a look at this thread which should give you good results. I tried with the mp4 of the gif from giphy and obtained this gif below as a result, which looks pretty good in my opinion! mkdir frames ffmpeg -i giphy.mp4 -vf scale=320:-1:flags=lanczos,fps=10 frames/ffout%03d.png convert -loop 0 frames/ffout*.png output....


1

# install gifsicle sudo apt install gifsicle #combine GIF files gifsicle *.GIF > combo.gif or gifsicle *.GIF > combo.gif --colors 256


1

First, convert the GIF into a [high-quality] video ffmpeg -i anim.gif -crf 12 -pix_fmt yuv420p anim-single.mp4 Then, make a new video with multiple loops of the single ffmpeg -i anim-single.mp4 -filter_complex "loop=120:9999" anim-final.mp4 Tested today in ffmpeg version 4.1.3


1

I would just convert the gif to a MP4 FIRST and then loop it about 100 times. The basic idea is the same but from the obvious approach it does not seem to work that well to feed multiple gif animations in the transcoder. Instead of doing that just convert one and then repeat the results as many times as needed.


Only top voted, non community-wiki answers of a minimum length are eligible