Converting avi files to animated gifs

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Converting avi files to animated gifs

Dotan Cohen
I need to output a summary of a video as an animated gif. Ideally, I
would have eight equally-spaced frames from the video, and play them
back one at a time, each for 0.25 seconds. So I'd have a 2 second
animated gif.

I have been using mplayer for the conversion as that's what I have
been able to find relevant info on in google. This is what I have so
far:

#!/bin/bash
mplayer "$@" -vo gif89a:output="$@".gif:fps=1 -vf scale=640:480
-endpos 8 -really-quiet

This gives me eight frames from the first eight seconds of video. Not
what I want, but it seems to be all that mplayer is capable of. Can
ffmpeg grab those frames from $timeOfVideo/7 time periods? Note that
I'm dividing the time of the video by 7, not 8, so that I will have
the first and last frames of the video in the gif.

My second problem is shortening the duration that each frame is shown.
Currently, each frame is shown for 1 second. Can ffmpeg reduce that to
0.25 seconds each, so that the eight frames will be shown in two
seconds?

If there is a tool more suited to the job than ffmpeg, then please let
me know what tool it is. I am very new to Linux in general and to bash
in particular. Thanks in advance.

Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Converting avi files to animated gifs

Michel Bardiaux-2
Dotan Cohen wrote:

> I need to output a summary of a video as an animated gif. Ideally, I
> would have eight equally-spaced frames from the video, and play them
> back one at a time, each for 0.25 seconds. So I'd have a 2 second
> animated gif.
>
> I have been using mplayer for the conversion as that's what I have
> been able to find relevant info on in google. This is what I have so
> far:
>
> #!/bin/bash
> mplayer "$@" -vo gif89a:output="$@".gif:fps=1 -vf scale=640:480
> -endpos 8 -really-quiet
>
> This gives me eight frames from the first eight seconds of video. Not
> what I want, but it seems to be all that mplayer is capable of.

You specify fps=1, and that is exactly what you get.

> Can
> ffmpeg grab those frames from $timeOfVideo/7 time periods? Note that
> I'm dividing the time of the video by 7, not 8, so that I will have
> the first and last frames of the video in the gif.
>
> My second problem is shortening the duration that each frame is shown.
> Currently, each frame is shown for 1 second. Can ffmpeg reduce that to
> 0.25 seconds each, so that the eight frames will be shown in two
> seconds?
>
> If there is a tool more suited to the job than ffmpeg, then please let
> me know what tool it is. I am very new to Linux in general and to bash
> in particular. Thanks in advance.

I have tried:

ffmpeg -i utc_1434.mpg -f gif -vcodec gif -an -r 4 -pix_fmt rgb24 jef.gif
FFmpeg version SVN-r12579, Copyright (c) 2000-2008 Fabrice Bellard, et al.
   configuration: --enable-libmp3lame --enable-gpl --enable-x11grab
--enable-libgsm
   libavutil version: 49.6.0
   libavcodec version: 51.53.0
   libavformat version: 52.12.0
   libavdevice version: 52.0.0
   built on Mar 28 2008 14:23:53, gcc: 4.1.2 20061115 (prerelease)
(Debian 4.1.1-21)
Input #0, mpeg, from 'utc_1434.mpg':
   Duration: 00:00:59.9, start: 92564.370489, bitrate: 635 kb/s
     Stream #0.0[0x1e0]: Video: mpeg1video, yuv420p, 352x288 [PAR 1:1
DAR 11:9], 104857 kb/s, 25.00 tb(r)
     Stream #0.1[0x1c0]: Audio: mp2, 48000 Hz, mono, 32 kb/s
File 'jef.gif' already exists. Overwrite ? [y/N] y
Output #0, gif, to 'jef.gif':
     Stream #0.0: Video: gif, pal8, 352x288 [PAR 1:1 DAR 11:9], q=2-31,
200 kb/s,  4.00 tb(c)
Stream mapping:
   Stream #0.0 -> #0.0
[gif @ 0x8429f30]ERROR: gif only handles the rgb24 pixel format. Use
-pix_fmt rgb24.
Could not write header for output file #0 (incorrect codec parameters ?)

It should have worked, what did I do wrong?

--
Michel Bardiaux
http://www.mediaxim.com/
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Converting avi files to animated gifs

Ví­ctor Paesa
Hi,

Michel Bardiaux said:

> Dotan Cohen wrote:
>> I need to output a summary of a video as an animated gif. Ideally, I
>> would have eight equally-spaced frames from the video, and play them
>> back one at a time, each for 0.25 seconds. So I'd have a 2 second
>> animated gif.
>>
>> I have been using mplayer for the conversion as that's what I have
>> been able to find relevant info on in google. This is what I have so
>> far:
>>
>> #!/bin/bash
>> mplayer "$@" -vo gif89a:output="$@".gif:fps=1 -vf scale=640:480
>> -endpos 8 -really-quiet
>>
>> This gives me eight frames from the first eight seconds of video. Not
>> what I want, but it seems to be all that mplayer is capable of.
>
> You specify fps=1, and that is exactly what you get.
>
>> Can
>> ffmpeg grab those frames from $timeOfVideo/7 time periods? Note that
>> I'm dividing the time of the video by 7, not 8, so that I will have
>> the first and last frames of the video in the gif.
>>
>> My second problem is shortening the duration that each frame is shown.
>> Currently, each frame is shown for 1 second. Can ffmpeg reduce that to
>> 0.25 seconds each, so that the eight frames will be shown in two
>> seconds?
>>
>> If there is a tool more suited to the job than ffmpeg, then please let
>> me know what tool it is. I am very new to Linux in general and to bash
>> in particular. Thanks in advance.
>
> I have tried:
>
> ffmpeg -i utc_1434.mpg -f gif -vcodec gif -an -r 4 -pix_fmt rgb24
> jef.gif FFmpeg version SVN-r12579, Copyright (c) 2000-2008 Fabrice
> Bellard, et al.
>    configuration: --enable-libmp3lame --enable-gpl --enable-x11grab
> --enable-libgsm
>    libavutil version: 49.6.0
>    libavcodec version: 51.53.0
>    libavformat version: 52.12.0
>    libavdevice version: 52.0.0
>    built on Mar 28 2008 14:23:53, gcc: 4.1.2 20061115 (prerelease)
> (Debian 4.1.1-21)
> Input #0, mpeg, from 'utc_1434.mpg':
>    Duration: 00:00:59.9, start: 92564.370489, bitrate: 635 kb/s
>      Stream #0.0[0x1e0]: Video: mpeg1video, yuv420p, 352x288 [PAR 1:1
> DAR 11:9], 104857 kb/s, 25.00 tb(r)
>      Stream #0.1[0x1c0]: Audio: mp2, 48000 Hz, mono, 32 kb/s
> File 'jef.gif' already exists. Overwrite ? [y/N] y
> Output #0, gif, to 'jef.gif':
>      Stream #0.0: Video: gif, pal8, 352x288 [PAR 1:1 DAR 11:9], q=2-31,
> 200 kb/s,  4.00 tb(c)
> Stream mapping:
>    Stream #0.0 -> #0.0
> [gif @ 0x8429f30]ERROR: gif only handles the rgb24 pixel format. Use
> -pix_fmt rgb24.
> Could not write header for output file #0 (incorrect codec parameters ?)
>
> It should have worked, what did I do wrong?

Nothing wrong, I'd say it is a bug. Using swscaler gives a hint:

ffmpeg -i input.avi -f gif -vcodec gif -an -r 4 -pix_fmt rgb24 jef.gif
FFmpeg version SVN-r12572, Copyright (c) 2000-2008 Fabrice Bellard, et al.
  configuration: --enable-shared --disable-static --enable-gpl
--enable-swscale --enable-avfilter --enable-avfilter-lavf
--enable-pthreads --enable-liba52 --enable-avisynth --enable-libfaac
--enable-libfaad --enable-libgsm --enable-libmp3lame --enable-libnut
--enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid
--extra-cflags=-march=prescott -DX_DISPLAY_MISSING -I/usr/local/include
-L/usr/local/lib --build-suffix=-SVN --cpu=prescott --enable-avfilter
--enable-avfilter-lavf
  libavutil version: 49.6.0
  libavcodec version: 51.53.0
  libavformat version: 52.12.0
  libavdevice version: 52.0.0
  libavfilter version: 0.0.0
  built on Mar 26 2008 12:17:43, gcc: 4.2.3
Input #0, avi, from 'input.avi':
  Duration: 00:00:20.2, start: 0.000000, bitrate: 30349 kb/s
    Stream #0.0: Video: dvvideo, yuv420p, 720x576, 25.00 tb(r)
    Stream #0.1: Audio: pcm_s16le, 48000 Hz, stereo, 1536 kb/s
swScaler: Palette is not supported as output pixel format
Cannot get resampling context

Setting "-pix_fmt pal8" doesn't work, either.

Regards,
Víctor


_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Converting avi files to animated gifs

Michel Bardiaux-2
Víctor Paesa wrote:

> Hi,
>
> Michel Bardiaux said:
>> Dotan Cohen wrote:
>>> I need to output a summary of a video as an animated gif. Ideally, I
>>> would have eight equally-spaced frames from the video, and play them
>>> back one at a time, each for 0.25 seconds. So I'd have a 2 second
>>> animated gif.
>>>
>>> I have been using mplayer for the conversion as that's what I have
>>> been able to find relevant info on in google. This is what I have so
>>> far:
>>>
>>> #!/bin/bash
>>> mplayer "$@" -vo gif89a:output="$@".gif:fps=1 -vf scale=640:480
>>> -endpos 8 -really-quiet
>>>
>>> This gives me eight frames from the first eight seconds of video. Not
>>> what I want, but it seems to be all that mplayer is capable of.
>> You specify fps=1, and that is exactly what you get.
>>
>>> Can
>>> ffmpeg grab those frames from $timeOfVideo/7 time periods? Note that
>>> I'm dividing the time of the video by 7, not 8, so that I will have
>>> the first and last frames of the video in the gif.
>>>
>>> My second problem is shortening the duration that each frame is shown.
>>> Currently, each frame is shown for 1 second. Can ffmpeg reduce that to
>>> 0.25 seconds each, so that the eight frames will be shown in two
>>> seconds?
>>>
>>> If there is a tool more suited to the job than ffmpeg, then please let
>>> me know what tool it is. I am very new to Linux in general and to bash
>>> in particular. Thanks in advance.
>> I have tried:
>>
>> ffmpeg -i utc_1434.mpg -f gif -vcodec gif -an -r 4 -pix_fmt rgb24
>> jef.gif FFmpeg version SVN-r12579, Copyright (c) 2000-2008 Fabrice
>> Bellard, et al.
>>    configuration: --enable-libmp3lame --enable-gpl --enable-x11grab
>> --enable-libgsm
>>    libavutil version: 49.6.0
>>    libavcodec version: 51.53.0
>>    libavformat version: 52.12.0
>>    libavdevice version: 52.0.0
>>    built on Mar 28 2008 14:23:53, gcc: 4.1.2 20061115 (prerelease)
>> (Debian 4.1.1-21)
>> Input #0, mpeg, from 'utc_1434.mpg':
>>    Duration: 00:00:59.9, start: 92564.370489, bitrate: 635 kb/s
>>      Stream #0.0[0x1e0]: Video: mpeg1video, yuv420p, 352x288 [PAR 1:1
>> DAR 11:9], 104857 kb/s, 25.00 tb(r)
>>      Stream #0.1[0x1c0]: Audio: mp2, 48000 Hz, mono, 32 kb/s
>> File 'jef.gif' already exists. Overwrite ? [y/N] y
>> Output #0, gif, to 'jef.gif':
>>      Stream #0.0: Video: gif, pal8, 352x288 [PAR 1:1 DAR 11:9], q=2-31,
>> 200 kb/s,  4.00 tb(c)
>> Stream mapping:
>>    Stream #0.0 -> #0.0
>> [gif @ 0x8429f30]ERROR: gif only handles the rgb24 pixel format. Use
>> -pix_fmt rgb24.
>> Could not write header for output file #0 (incorrect codec parameters ?)
>>
>> It should have worked, what did I do wrong?
>
> Nothing wrong, I'd say it is a bug. Using swscaler gives a hint:
>
> ffmpeg -i input.avi -f gif -vcodec gif -an -r 4 -pix_fmt rgb24 jef.gif
> FFmpeg version SVN-r12572, Copyright (c) 2000-2008 Fabrice Bellard, et al.
>   configuration: --enable-shared --disable-static --enable-gpl
> --enable-swscale --enable-avfilter --enable-avfilter-lavf
> --enable-pthreads --enable-liba52 --enable-avisynth --enable-libfaac
> --enable-libfaad --enable-libgsm --enable-libmp3lame --enable-libnut
> --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid
> --extra-cflags=-march=prescott -DX_DISPLAY_MISSING -I/usr/local/include
> -L/usr/local/lib --build-suffix=-SVN --cpu=prescott --enable-avfilter
> --enable-avfilter-lavf
>   libavutil version: 49.6.0
>   libavcodec version: 51.53.0
>   libavformat version: 52.12.0
>   libavdevice version: 52.0.0
>   libavfilter version: 0.0.0
>   built on Mar 26 2008 12:17:43, gcc: 4.2.3
> Input #0, avi, from 'input.avi':
>   Duration: 00:00:20.2, start: 0.000000, bitrate: 30349 kb/s
>     Stream #0.0: Video: dvvideo, yuv420p, 720x576, 25.00 tb(r)
>     Stream #0.1: Audio: pcm_s16le, 48000 Hz, stereo, 1536 kb/s
> swScaler: Palette is not supported as output pixel format
> Cannot get resampling context
>
> Setting "-pix_fmt pal8" doesn't work, either.

Indeed, the gif.c *codec* forces PAL8, seems swscale cant do it yet, or
else the message is misleading. The LGPL scaler can, but hits another
wall: gif_write_header want RGB24! And just changing that guard wont
work, because RGB24 appears in several places in that muxer. I cant make
sense of it all (at least, not quickly), and there is not an official
maintainer for the encoder nor the muxer, so this looks like something
for the author, that is Francois Revol. I have sent him a heads-up.

Greetings,
--
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:[hidden email]

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Converting avi files to animated gifs

Baptiste Coudurier
Michel Bardiaux wrote:

> Víctor Paesa wrote:
> [...]
>
>>
>> ffmpeg -i input.avi -f gif -vcodec gif -an -r 4 -pix_fmt rgb24 jef.gif
>> FFmpeg version SVN-r12572, Copyright (c) 2000-2008 Fabrice Bellard, et al.
>>   configuration: --enable-shared --disable-static --enable-gpl
>> --enable-swscale --enable-avfilter --enable-avfilter-lavf
>> --enable-pthreads --enable-liba52 --enable-avisynth --enable-libfaac
>> --enable-libfaad --enable-libgsm --enable-libmp3lame --enable-libnut
>> --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid
>> --extra-cflags=-march=prescott -DX_DISPLAY_MISSING -I/usr/local/include
>> -L/usr/local/lib --build-suffix=-SVN --cpu=prescott --enable-avfilter
>> --enable-avfilter-lavf
>>   libavutil version: 49.6.0
>>   libavcodec version: 51.53.0
>>   libavformat version: 52.12.0
>>   libavdevice version: 52.0.0
>>   libavfilter version: 0.0.0
>>   built on Mar 26 2008 12:17:43, gcc: 4.2.3
>> Input #0, avi, from 'input.avi':
>>   Duration: 00:00:20.2, start: 0.000000, bitrate: 30349 kb/s
>>     Stream #0.0: Video: dvvideo, yuv420p, 720x576, 25.00 tb(r)
>>     Stream #0.1: Audio: pcm_s16le, 48000 Hz, stereo, 1536 kb/s
>> swScaler: Palette is not supported as output pixel format
>> Cannot get resampling context
>>
>> Setting "-pix_fmt pal8" doesn't work, either.
>
> Indeed, the gif.c *codec* forces PAL8, seems swscale cant do it yet, or
> else the message is misleading. The LGPL scaler can, but hits another
> wall: gif_write_header want RGB24! And just changing that guard wont
> work, because RGB24 appears in several places in that muxer. I cant make
> sense of it all (at least, not quickly), and there is not an official
> maintainer for the encoder nor the muxer, so this looks like something
> for the author, that is Francois Revol. I have sent him a heads-up.
>

Just remove "-vcodec gif".

--
Baptiste COUDURIER                              GnuPG Key Id: 0x5C1ABAAA
SMARTJOG SAS                                     http://www.smartjog.com
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
Phone: +33 1 49966312

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Converting avi files to animated gifs

Michel Bardiaux-2
Baptiste Coudurier wrote:
> Michel Bardiaux wrote:
[snip]

>> Indeed, the gif.c *codec* forces PAL8, seems swscale cant do it yet, or
>> else the message is misleading. The LGPL scaler can, but hits another
>> wall: gif_write_header want RGB24! And just changing that guard wont
>> work, because RGB24 appears in several places in that muxer. I cant make
>> sense of it all (at least, not quickly), and there is not an official
>> maintainer for the encoder nor the muxer, so this looks like something
>> for the author, that is Francois Revol. I have sent him a heads-up.
>>
>
> Just remove "-vcodec gif".
>
That's better:

ffmpeg_g -y -i utc_1434.mpg -f gif -an -r 4 jef.gif
FFmpeg version SVN-r12579, Copyright (c) 2000-2008 Fabrice Bellard, et al.
   configuration: --enable-libmp3lame --enable-gpl --enable-x11grab
--enable-libgsm
   libavutil version: 49.6.0
   libavcodec version: 51.53.0
   libavformat version: 52.12.0
   libavdevice version: 52.0.0
   built on Mar 28 2008 14:23:53, gcc: 4.1.2 20061115 (prerelease)
(Debian 4.1.1-21)
Input #0, mpeg, from 'utc_1434.mpg':
   Duration: 00:00:59.9, start: 92564.370489, bitrate: 635 kb/s
     Stream #0.0[0x1e0]: Video: mpeg1video, yuv420p, 352x288 [PAR 1:1
DAR 11:9], 104857 kb/s, 25.00 tb(r)
     Stream #0.1[0x1c0]: Audio: mp2, 48000 Hz, mono, 32 kb/s
Output #0, gif, to 'jef.gif':
     Stream #0.0: Video: rawvideo, yuv420p, 352x288 [PAR 1:1 DAR 11:9],
q=2-31, 200 kb/s,  4.00 tb(c)
Stream mapping:
   Stream #0.0 -> #0.0
Press [q] to stop encoding
frame=  242 fps=150 q=0.0 Lsize=   27468kB time=60.5
bitrate=3719.3kbits/s
video:35937kB audio:0kB global headers:0kB muxing overhead -23.566899%

2 but's though:

1. If animated gif requires rawvideo, why the foo doesnt it say so?
(This is a general problem in lavf, it is very weak on knowledge of
which codec is acceptable or recommended for what muxer).

2. The output file is wrong. In VLC I see it as greytone, 3 by 2 copies
of the same image, plus indistinct garbage. Try it, you'll hate it...

--
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:[hidden email]

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Converting avi files to animated gifs

Baptiste Coudurier
Michel Bardiaux wrote:

> Baptiste Coudurier wrote:
>> Michel Bardiaux wrote:
> [snip]
>>> Indeed, the gif.c *codec* forces PAL8, seems swscale cant do it yet, or
>>> else the message is misleading. The LGPL scaler can, but hits another
>>> wall: gif_write_header want RGB24! And just changing that guard wont
>>> work, because RGB24 appears in several places in that muxer. I cant make
>>> sense of it all (at least, not quickly), and there is not an official
>>> maintainer for the encoder nor the muxer, so this looks like something
>>> for the author, that is Francois Revol. I have sent him a heads-up.
>>>
>> Just remove "-vcodec gif".
>>
> That's better:
>
> ffmpeg_g -y -i utc_1434.mpg -f gif -an -r 4 jef.gif
> FFmpeg version SVN-r12579, Copyright (c) 2000-2008 Fabrice Bellard, et al.
>    configuration: --enable-libmp3lame --enable-gpl --enable-x11grab
> --enable-libgsm
>    libavutil version: 49.6.0
>    libavcodec version: 51.53.0
>    libavformat version: 52.12.0
>    libavdevice version: 52.0.0
>    built on Mar 28 2008 14:23:53, gcc: 4.1.2 20061115 (prerelease)
> (Debian 4.1.1-21)
> Input #0, mpeg, from 'utc_1434.mpg':
>    Duration: 00:00:59.9, start: 92564.370489, bitrate: 635 kb/s
>      Stream #0.0[0x1e0]: Video: mpeg1video, yuv420p, 352x288 [PAR 1:1
> DAR 11:9], 104857 kb/s, 25.00 tb(r)
>      Stream #0.1[0x1c0]: Audio: mp2, 48000 Hz, mono, 32 kb/s
> Output #0, gif, to 'jef.gif':
>      Stream #0.0: Video: rawvideo, yuv420p, 352x288 [PAR 1:1 DAR 11:9],

                                    ^^^^^^^^^
Humm I don't know how you managed to get through the check, did you
tweak something ?

 > 2 but's though:
>
> 1. If animated gif requires rawvideo, why the foo doesnt it say so?

Well, as usual, patch welcome, you are developper, no ?

> (This is a general problem in lavf, it is very weak on knowledge of
> which codec is acceptable or recommended for what muxer).

Lavf is premissive in many regards, this was the way things were used to
be, and IMHO this is one of its advantages, since it let 'aware' people
using it in many ways.

I personally wouldn't like lavf being aggressive.

See the agsm problem lately, this is again IMHO a bit useless wasted time.

> 2. The output file is wrong. In VLC I see it as greytone, 3 by 2 copies
> of the same image, plus indistinct garbage. Try it, you'll hate it...

Works great here.

ffmpeg -i <file> -pix_fmt rgb24 test.gif.
Output #0, gif, to 'test.gif':
    Stream #0.0: Video: rawvideo, rgb24, 720x608 [PAR 1:1 DAR 45:38],
q=2-31, 200 kb/s, 25.00 tb(c)

And file works great in all players I have at hands.

--
Baptiste COUDURIER                              GnuPG Key Id: 0x5C1ABAAA
SMARTJOG SAS                                     http://www.smartjog.com
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
Phone: +33 1 49966312
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Converting avi files to animated gifs

Michel Bardiaux-2
Baptiste Coudurier wrote:
> Michel Bardiaux wrote:
[snip]

>> Output #0, gif, to 'jef.gif':
>>      Stream #0.0: Video: rawvideo, yuv420p, 352x288 [PAR 1:1 DAR 11:9],
>
>                                     ^^^^^^^^^
> Humm I don't know how you managed to get through the check, did you
> tweak something ?

Yes, and I should have removed that. The correct way is:

ffmpeg_g -y -i utc_1434.mpg -pix_fmt rgb24 -f gif -an -r 4 jef.gif
FFmpeg version SVN-r12579, Copyright (c) 2000-2008 Fabrice Bellard, et al.
   configuration: --enable-libmp3lame --enable-gpl --enable-x11grab
--enable-libgsm
   libavutil version: 49.6.0
   libavcodec version: 51.53.0
   libavformat version: 52.12.0
   libavdevice version: 52.0.0
   built on Mar 28 2008 14:23:53, gcc: 4.1.2 20061115 (prerelease)
(Debian 4.1.1-21)
Input #0, mpeg, from 'utc_1434.mpg':
   Duration: 00:00:59.9, start: 92564.370489, bitrate: 635 kb/s
     Stream #0.0[0x1e0]: Video: mpeg1video, yuv420p, 352x288 [PAR 1:1
DAR 11:9], 104857 kb/s, 25.00 tb(r)
     Stream #0.1[0x1c0]: Audio: mp2, 48000 Hz, mono, 32 kb/s
Output #0, gif, to 'jef.gif':
     Stream #0.0: Video: rawvideo, rgb24, 352x288 [PAR 1:1 DAR 11:9],
q=2-31, 200 kb/s,  4.00 tb(c)
Stream mapping:
   Stream #0.0 -> #0.0
Press [q] to stop encoding
frame=  242 fps=124 q=0.0 Lsize=   27468kB time=60.5
bitrate=3719.3kbits/s
video:71874kB audio:0kB global headers:0kB muxing overhead -61.783449%

>
>  > 2 but's though:
>> 1. If animated gif requires rawvideo, why the foo doesnt it say so?
>
> Well, as usual, patch welcome, you are developper, no ?

OK, will try to add the guard at the same place rgb24 is checked.

>
>> (This is a general problem in lavf, it is very weak on knowledge of
>> which codec is acceptable or recommended for what muxer).
>
> Lavf is premissive in many regards, this was the way things were used to
> be, and IMHO this is one of its advantages, since it let 'aware' people
> using it in many ways.
>
> I personally wouldn't like lavf being aggressive.

And everyone could have what he wishes, that's why there is -strict
strictness  how strictly to follow the standards, no? You like to run
permissive, I prefer aggressive, ffmpeg should be able to do both.

>
> See the agsm problem lately, this is again IMHO a bit useless wasted time.

And I explained there that my desire to produce some message is
basically a defense against users attempting to change the bitrate then
pestering the list because it doesnt work.

>
>> 2. The output file is wrong. In VLC I see it as greytone, 3 by 2 copies
>> of the same image, plus indistinct garbage. Try it, you'll hate it...
>
> Works great here.
>
> ffmpeg -i <file> -pix_fmt rgb24 test.gif.
> Output #0, gif, to 'test.gif':
>     Stream #0.0: Video: rawvideo, rgb24, 720x608 [PAR 1:1 DAR 45:38],
> q=2-31, 200 kb/s, 25.00 tb(c)
>
> And file works great in all players I have at hands.
>
Yes, OK here now too. This is an issue of documentation/scrutability now.

--
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:[hidden email]

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Converting avi files to animated gifs

Baptiste Coudurier
Michel Bardiaux wrote:

> Baptiste Coudurier wrote:
> [...]
>
>>> (This is a general problem in lavf, it is very weak on knowledge of
>>> which codec is acceptable or recommended for what muxer).
>> Lavf is premissive in many regards, this was the way things were used to
>> be, and IMHO this is one of its advantages, since it let 'aware' people
>> using it in many ways.
>>
>> I personally wouldn't like lavf being aggressive.
>
> And everyone could have what he wishes, that's why there is -strict
> strictness  how strictly to follow the standards, no? You like to run
> permissive, I prefer aggressive, ffmpeg should be able to do both.

Again feel free to submit patch which add strictness when -strict is
actually used, but this would not change the default.

>> See the agsm problem lately, this is again IMHO a bit useless wasted time.
>
> And I explained there that my desire to produce some message is
> basically a defense against users attempting to change the bitrate then
> pestering the list because it doesnt work.

Yes, and now I'd like your check being done when stricness is explicitly
asked :>

[...]

--
Baptiste COUDURIER                              GnuPG Key Id: 0x5C1ABAAA
SMARTJOG SAS                                     http://www.smartjog.com
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
Phone: +33 1 49966312
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Converting avi files to animated gifs

Michel Bardiaux-2
Baptiste Coudurier wrote:

> Michel Bardiaux wrote:
>> Baptiste Coudurier wrote:
>> [...]
>>
>>>> (This is a general problem in lavf, it is very weak on knowledge of
>>>> which codec is acceptable or recommended for what muxer).
>>> Lavf is premissive in many regards, this was the way things were used to
>>> be, and IMHO this is one of its advantages, since it let 'aware' people
>>> using it in many ways.
>>>
>>> I personally wouldn't like lavf being aggressive.
>> And everyone could have what he wishes, that's why there is -strict
>> strictness  how strictly to follow the standards, no? You like to run
>> permissive, I prefer aggressive, ffmpeg should be able to do both.
>
> Again feel free to submit patch which add strictness when -strict is
> actually used, but this would not change the default.

General case: I agree. But here: the muxer wont work at all with the
wrong codec and/or pix_fmt, so the check must always be done.

>
>>> See the agsm problem lately, this is again IMHO a bit useless wasted time.
>> And I explained there that my desire to produce some message is
>> basically a defense against users attempting to change the bitrate then
>> pestering the list because it doesnt work.
>
> Yes, and now I'd like your check being done when stricness is explicitly
> asked :>
>
See reply in that thread.

--
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:[hidden email]

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Converting avi files to animated gifs [PATCH]

Michel Bardiaux-2
Michel Bardiaux wrote:

> Baptiste Coudurier wrote:
>> Michel Bardiaux wrote:
>>> Baptiste Coudurier wrote:
>>> [...]
>>>
>>>>> (This is a general problem in lavf, it is very weak on knowledge of
>>>>> which codec is acceptable or recommended for what muxer).
>>>> Lavf is premissive in many regards, this was the way things were used to
>>>> be, and IMHO this is one of its advantages, since it let 'aware' people
>>>> using it in many ways.
>>>>
>>>> I personally wouldn't like lavf being aggressive.
>>> And everyone could have what he wishes, that's why there is -strict
>>> strictness  how strictly to follow the standards, no? You like to run
>>> permissive, I prefer aggressive, ffmpeg should be able to do both.
>> Again feel free to submit patch which add strictness when -strict is
>> actually used, but this would not change the default.
>
> General case: I agree. But here: the muxer wont work at all with the
> wrong codec and/or pix_fmt, so the check must always be done.
And here is the patch. OK?

>
>>>> See the agsm problem lately, this is again IMHO a bit useless wasted time.
>>> And I explained there that my desire to produce some message is
>>> basically a defense against users attempting to change the bitrate then
>>> pestering the list because it doesnt work.
>> Yes, and now I'd like your check being done when stricness is explicitly
>> asked :>
>>
> See reply in that thread.
>

--
Michel Bardiaux
http://www.mediaxim.com/

Index: libavformat/gif.c
===================================================================
--- libavformat/gif.c (revision 12665)
+++ libavformat/gif.c (working copy)
@@ -341,8 +341,12 @@
 //        rate = video_enc->time_base.den;
     }
 
+    if (video_enc->codec->id != CODEC_ID_RAWVIDEO) {
+        av_log(s, AV_LOG_ERROR, "ERROR: animated-gif muxer requires the rawvideo codec. Use -vcodec rawvideo.\n");
+        return AVERROR(EIO);
+    }
     if (video_enc->pix_fmt != PIX_FMT_RGB24) {
-        av_log(s, AV_LOG_ERROR, "ERROR: gif only handles the rgb24 pixel format. Use -pix_fmt rgb24.\n");
+        av_log(s, AV_LOG_ERROR, "ERROR: animated-gif muxer only handles the rgb24 pixel format. Use -pix_fmt rgb24.\n");
         return AVERROR(EIO);
     }
 

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user