Comments (13)
There are 2 problems:
- GR should not call
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 specifyGKS_VIDEO_OPTS
beforeGR.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?
from gr.rb.
x264 that is used by ffmpeg requires "mod 4" in this case: https://code.videolan.org/videolan/x264/-/blob/master/encoder/encoder.c#L529
from gr.rb.
@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.
from gr.rb.
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
from gr.rb.
What is your distribution?
I confirmed that it works well on Ubuntu 20.04.
from gr.rb.
I'm on Ubuntu 20.04 as well. The same error still happens after installing the packages mentioned in #46 (comment).
from gr.rb.
What about libavdevice-dev?
It's not in the Dockerfile list, but in my case Ubuntu can output with it. (Until then, similar error)
from gr.rb.
Mh, that's also already installed: libavdevice-dev is already the newest version (7:4.2.4-1ubuntu0.1).
from gr.rb.
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?
from gr.rb.
@kou
Great investigation as always.
Can I ask you one question: what is mod 4?
from gr.rb.
Oh, sorry. It's abbreviation of "modulo 4":
- English: https://en.wikipedia.org/wiki/Modulo_operation
- Japanese: https://ja.wikipedia.org/wiki/%E5%89%B0%E4%BD%99%E6%BC%94%E7%AE%97
from gr.rb.
Thank you.
I didn't know that x264 can only support video sizes that are divisible by 4.
from gr.rb.
Reported to sciapp/gr.
from gr.rb.
Related Issues (20)
- GR meta HOT 1
- pkg-config HOT 1
- gtk example libfreetype error HOT 2
- Recording the call to the Native GR function in a log file HOT 1
- Segmental fault occurs when using fiddle 1.0.3 on Windows HOT 1
- mingw gr package cannot be built (because qhull-git has been removed?) HOT 1
- nonuniformheatmap, nonuniformpolarheatmap HOT 1
- MacOS homebrew libgr v0.55.0 does not work with workstations other than gksqt HOT 2
- Match the version numbers of sciapp/gr and GR.rb HOT 4
- Ubuntu 21.04 Wayland HOT 1
- Support saving a plot directly to a file without opening up Qt? HOT 5
- On Windows + RubyInstaller, if the environment variable GKS_FONTPATH is not set, the text will not be displayed.
- Should GR.rb support iTerm2?
- Problems with `hold` method behavior
- add fiddladd fiddley.rb to fiddle HOT 3
- Release Fiddle::Pointer HOT 1
- Add cpubasedvolume to GR module
- Some odd problem: GR3_ERROR_INVALUD_VALUE HOT 1
- Get the binary blob instead of saving the plot to an image file. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gr.rb.