how should I control the flow when writing an animated webp to the file.

72 views
Skip to first unread message

Owen Choi

unread,
Sep 17, 2021, 2:46:38 AM9/17/21
to WebP Discussion
Hi everyone~
First of all, I would like to thank those who help us use such a good image encoder.

I'm curious about the flow control of the muxing of the animation webp.
As you all know, in order to get the muxed data, we have to call the WebPAnimEncoderAssemble() function to get the data and save it in a file.

I checked that it works normally when I do what is shown in the documentation.

However, there is a problem here. In the environment I tested, it takes a lot of time to process WebPAnimEncoderAssemble() as below, obtains data, and write to the file as below.
Other threads have to wait a long time to work on the file.
For your information, I wanted to make a 20-minute animation for the test.

example1)
------------------------------------------------------------------------------------------------------------------------------------------
WebPAnimEncoderOptions enc_options;
WebPAnimEncoderOptionsInit(&enc_options);
// Tune 'enc_options' as needed.
WebPAnimEncoder* enc = WebPAnimEncoderNew(width, height, &enc_options);
while(<there are more frames>) {
  WebPConfig config;
  WebPConfigInit(&config);
  // Tune 'config' as needed.
  WebPAnimEncoderAdd(enc, frame, timestamp_ms, &config);
}
WebPAnimEncoderAdd(enc, NULL, timestamp_ms, NULL);
WebPAnimEncoderAssemble(enc, webp_data);
WebPAnimEncoderDelete(enc);
write(fd, webp_data.bytes, webp_data.size);
-------------------------------------------------------------------------------------------------------------------------------------------

Can I bring the muxed data one by one and save it to the file? It should be an Animated webp file.
Is there anyone who knows how I want to do it?

James Zern

unread,
Sep 17, 2021, 6:41:51 PM9/17/21
to WebP Discussion
Hi Owen,

On Thu, Sep 16, 2021 at 11:46 PM Owen Choi <tac...@gmail.com> wrote:
Hi everyone~
First of all, I would like to thank those who help us use such a good image encoder.

I'm curious about the flow control of the muxing of the animation webp.
As you all know, in order to get the muxed data, we have to call the WebPAnimEncoderAssemble() function to get the data and save it in a file.

I checked that it works normally when I do what is shown in the documentation.

However, there is a problem here. In the environment I tested, it takes a lot of time to process WebPAnimEncoderAssemble() as below, obtains data, and write to the file as below.
Other threads have to wait a long time to work on the file.
For your information, I wanted to make a 20-minute animation for the test.

20 minutes is quite long for an animated image if your frame rate isn't extremely low. How many frames are you trying to process? Would this be better handled as a video?
 

example1)
------------------------------------------------------------------------------------------------------------------------------------------
WebPAnimEncoderOptions enc_options;
WebPAnimEncoderOptionsInit(&enc_options);
// Tune 'enc_options' as needed.
WebPAnimEncoder* enc = WebPAnimEncoderNew(width, height, &enc_options);
while(<there are more frames>) {
  WebPConfig config;
  WebPConfigInit(&config);
  // Tune 'config' as needed.
  WebPAnimEncoderAdd(enc, frame, timestamp_ms, &config);
}
WebPAnimEncoderAdd(enc, NULL, timestamp_ms, NULL);
WebPAnimEncoderAssemble(enc, webp_data);
WebPAnimEncoderDelete(enc);
write(fd, webp_data.bytes, webp_data.size);
-------------------------------------------------------------------------------------------------------------------------------------------

Can I bring the muxed data one by one and save it to the file? It should be an Animated webp file.
Is there anyone who knows how I want to do it?

Writing out individual frames is possible, but will require some custom code and you would need to be able to seek to the beginning to update the file header on completion. WebPAnimEncoder is built on top of libwebp and libwebpmux, so you could use the frame encoding there as a reference and skip the libwebpmux integration to handle this case.
 

--
You received this message because you are subscribed to the Google Groups "WebP Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webp-discuss...@webmproject.org.
To view this discussion on the web visit https://groups.google.com/a/webmproject.org/d/msgid/webp-discuss/d4b479d5-a90c-4781-b970-a2ac1e4919f0n%40webmproject.org.

Owen Choi

unread,
Sep 23, 2021, 11:21:42 AM9/23/21
to WebP Discussion, James Zern
Hi James

Thank you for your detailed answer.
I'm gonna check your solution. :)

2021년 9월 18일 토요일 오전 7시 41분 51초 UTC+9에 James Zern님이 작성:
Reply all
Reply to author
Forward
0 new messages