Open fapdash opened 3 years ago
@fapdash Thank you for your report.
According to the official website, the following dependent libraries are required to build GR.
https://gr-framework.org/building.html
The libraries related to video output are optional
, not required
. Therefore, they may not be included in the pre-built binaries managed by the package manager. For example, the libgr distributed via homebrew specifies only the following dependencies, so video output is not possible.
depends_on "cmake" => :build
depends_on "cairo"
depends_on "glfw"
depends_on "libtiff"
depends_on "qhull"
depends_on "qt@5"
depends_on "zeromq"
I guess Linux can't output video for the same reason... But to be honest, I don't understand much about the lower layers. I think I need to look into this more closely.
Parhaps, you may be able to output video by simply installing the following dependent libraries.
Libraries that may be related to video output are:
sudo apt install -y libavcodec-dev \
libavdevice-dev \
libavformat-dev \
libavutil-dev
What is your distribution? I confirmed that it works well on Ubuntu 20.04.
I'm on Ubuntu 20.04 as well. The same error still happens after installing the packages mentioned in https://github.com/red-data-tools/GR.rb/issues/46#issuecomment-886014608.
What about libavdevice-dev? It's not in the Dockerfile list, but in my case Ubuntu can output with it. (Until then, similar error)
Mh, that's also already installed: libavdevice-dev is already the newest version (7:4.2.4-1ubuntu0.1).
I confirmed that the same error occurs when I set GKS_WSTYPE=100.
@kou Could you please set the environment variable GKS_WSTYPE=100
and check again?
There are 2 problems:
av_write_trailer()
on initialization failure:diff --git a/lib/gks/plugin/vc.c b/lib/gks/plugin/vc.c
index 6391d651..ccf76cf0 100644
--- a/lib/gks/plugin/vc.c
+++ b/lib/gks/plugin/vc.c
@@ -270,7 +270,10 @@ void vc_movie_finish(movie_t movie)
if (movie->fmt_ctx && movie->cdc_ctx)
{
- av_write_trailer(movie->fmt_ctx);
+ if (movie->fmt_ctx->pb)
+ {
+ av_write_trailer(movie->fmt_ctx);
+ }
avcodec_close(movie->cdc_ctx);
if (!(movie->out_fmt->flags & AVFMT_NOFILE))
For example, movie->fmt_ctx->pb
is NULL
when avcocdec_open2()
is failed: https://github.com/sciapp/gr/blob/master/lib/gks/plugin/vc.c#L185
It can be happen by specifying wrong video size (361
isn't mod 4): GKS_VIDEO_OPTS=361x240@25@2x
save_videos.rb
should specify GKS_VIDEO_OPTS
before GR.beginprint
:diff --git a/examples/save_videos.rb b/examples/save_videos.rb
index d17dbc1..68bf6a3 100644
--- a/examples/save_videos.rb
+++ b/examples/save_videos.rb
@@ -21,6 +21,9 @@ epoch.times do |i|
y << i**2 * Math.cos(i * Math::PI / 10.0) / 100.0
end
+# configure video size
+ENV['GKS_VIDEO_OPTS'] = '360x240@25@2x'
+
# start
GR.beginprint('savefig/video.mov')
@@ -32,9 +35,6 @@ end
# stop
GR.endprint
-# configure video size
-ENV['GKS_VIDEO_OPTS'] = '360x240@25@2x'
-
# You can use block
GR.beginprint('savefig/video.mp4') do
epoch.times do |j|
If it's not specified, width and height (ws_state_list::mem[0]
and ws_state_list::mem[1]
) may be updated by cairoplugin: https://github.com/sciapp/gr/blob/master/lib/gks/plugin/cairoplugin.c#L894-L895
It may set invalid width and/or height (not mod 4).
Could you report 1. to GR?
@kou Great investigation as always. Can I ask you one question: what is mod 4?
Oh, sorry. It's abbreviation of "modulo 4":
x264 that is used by ffmpeg requires "mod 4" in this case: https://code.videolan.org/videolan/x264/-/blob/master/encoder/encoder.c#L529
Thank you. I didn't know that x264 can only support video sizes that are divisible by 4.
Reported to sciapp/gr.
I understand that the README says that video might not be supported by the versions provided by package managers but a more helpful error message in those cases would be nice.
I followed the instructions to install
libgrm-dev
through apt:And then tried to run the
save_videos.rb
example: