Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let movie open and play movie if gmt end show is used #7456

Merged
merged 10 commits into from May 16, 2023
Merged

Conversation

PaulWessel
Copy link
Member

If the mainscript ends with

gmt end show

we will use gmt docs to open and play the movie after it has been assembled. Closes #7455.

If the mainscript ends with

gmt end show

we will use gmt docs to open and play the movie after it has been assembled.
@PaulWessel PaulWessel added the enhancement Improving an existing feature label May 11, 2023
@PaulWessel PaulWessel added this to the 6.5.0 milestone May 11, 2023
@PaulWessel PaulWessel self-assigned this May 11, 2023
@Esteban82
Copy link
Member

It works but I got a lot of messagges related to vlc on the terminal including bold and red letters (see screen capture below) that might looks scary for some users. Is it possible to avoid that?

movie [NOTICE]: Running: ffmpeg -loglevel warning -f image2 -framerate 12 -y -i "/home/federico/Github/Esteban82/Pruebas_Privadas/Bug_Movie_Title/1/1_%03d.png" -vcodec libx264  -pix_fmt yuv420p 1.mp4
kf.service.services: KApplicationTrader: mimeType "x-scheme-handler/file" not found
kf.service.services: KApplicationTrader: mimeType "x-scheme-handler/file" not found
VLC media player 3.0.16 Vetinari (revision 3.0.13-8-g41878ff4f2)
federico@loki:~/Github/Esteban82/Pruebas_Privadas/Bug_Movie_Title$ [0000564a7e271820] main libvlc: Ejecutar vlc con la interfaz predeterminada. Use «cvlc» para usar vlc sin interfaz.
[00007f920c004900] gl gl: Initialized libplacebo v4.192.1 (API v192)
libva info: VA-API version 1.14.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/nouveau_drv_video.so
libva info: Found init function __vaDriverInit_1_14
libva info: va_openDriver() returns 0
[00007f920c004900] glconv_vaapi_x11 gl error: vaDeriveImage: operation failed
[00007f9214046790] main video output error: video output creation failed
[00007f9228c022f0] main decoder error: failed to create video output
[00007f920c02b4d0] gl gl: Initialized libplacebo v4.192.1 (API v192)
[00007f9228c022f0] avcodec decoder: Using G3DVL VDPAU Driver Shared Library version 1.0 for hardware decoding
[h264 @ 0x7f9228c42fc0] Failed setup for format vdpau: hwaccel initialisation returned error.
[00007f9228c022f0] avcodec decoder error: existing hardware acceleration cannot be reused
[00007f920c02b4d0] gl gl: Initialized libplacebo v4.192.1 (API v192)
libva info: VA-API version 1.14.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/nouveau_drv_video.so
libva info: Found init function __vaDriverInit_1_14
libva info: va_openDriver() returns 0
[00007f920c02b4d0] glconv_vaapi_x11 gl error: vaDeriveImage: operation failed
[00007f925c001b70] gl gl: Initialized libplacebo v4.192.1 (API v192)
libva info: VA-API version 1.14.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/nouveau_drv_video.so
libva info: Found init function __vaDriverInit_1_14
libva info: va_openDriver() returns 0
[00007f925c001b70] glconv_vaapi_x11 gl error: vaDeriveImage: operation failed
[00007f92140b6ff0] main video output error: video output creation failed
[00007f9228c022f0] main decoder error: failed to create video output
[00007f925c017580] gl gl: Initialized libplacebo v4.192.1 (API v192)
uint DBusMenuExporterDBus::GetLayout(int, int, const QStringList&, DBusMenuLayoutItem&): Condition failed: menu
uint DBusMenuExporterDBus::GetLayout(int, int, const QStringList&, DBusMenuLayoutItem&): Condition failed: menu

Screencapture:

image

@Esteban82
Copy link
Member

Also, if I asked for a a master frame (-Ml,png), GMT tries and fails to open it.

image

Full script

#!/usr/bin/env bash

cat << EOF > main.sh
gmt begin
	echo \${MOVIE_FRAME} | gmt text -R0/1/0/1 -JX10c -F+f200p+cCM -B0 -X0 -Y0
gmt end show
EOF
gmt movie main.sh -N1 -T100 -C480p -Fmp4 -Zs -D12 -Ml,png

@Esteban82
Copy link
Member

Is it possible to avoid that?

Yes, with this:

open 1.mp4 2> /dev/null

Paths was wrong, resulting in different kinds of behaviour on macos and Linux. Now we hvae separate calls to gmt docs with correct paths.
@PaulWessel
Copy link
Member Author

@Esteban82, see if this works now for opening both master frame and the movie. I have fixed the path and now explicitly call gmt docs on the master png. Before, I relied on just the gmt end show in the script taking care of it, but there is the issue of moving the plot up one directory.

Let me know about your warnings after this commit.

@Esteban82
Copy link
Member

@Esteban82, see if this works now for opening both master frame and the movie. I have fixed the path and now explicitly call gmt docs on the master png. Before, I relied on just the gmt end show in the script taking care of it, but there is the issue of moving the plot up one directory.

@PaulWessel it worked. Both files were open.

I wonder if it is a good idea to open both files. I think it might be a bit annoying. I wonder if it would be better to open only the mp4 only. And only open the master frame when a video is not requested.

@PaulWessel
Copy link
Member Author

Might also be annoying to some if we don't open both...
Maybe some modifier somewhere? E.g., -F.....[+v] for view movie. That way we could use a gmt end show presence to view master and **+**v to view movie, even if manuscript does to have show. Cleaner I think, and accommodates both schemes.

@PaulWessel
Copy link
Member Author

I think this is the better solution and I will implement it.

@PaulWessel
Copy link
Member Author

Try this @Esteban82 - works for me and the +v is a better solution for the video.

@PaulWessel
Copy link
Member Author

Got me thinking that having to add/remove show from a script is not a very clean way to do this. Thus +v is good. But we could also add +v as modifier to -M and then we have full control from the command line with no need to modify scripts. What you think?

-M[frame|f|m|l,][+v]

? I can even make it backwards compatible if show is in the script.

@PaulWessel
Copy link
Member Author

Sorry, not sure what I copied. -M is

[-M][frame],[format][+rdpu][+v]

@Esteban82
Copy link
Member

Yes, I think it is better to have a modifier in the gmt movie command (to open both files).

@PaulWessel
Copy link
Member Author

OK, +v in -M as well as backwards gmt end show check both works. Give it a try and then we can wrap this up.

@Esteban82
Copy link
Member

Esteban82 commented May 13, 2023

I am getting an error

NULL @ 0x55a54486da80] Unable to find a suitable output format for ',png'
,png: Invalid argument
movie [ERROR]: Running FFmpeg conversion to MP4 returned error 256 - exiting.
free(): invalid pointer
play.sh: línea 8: 35611 Abortado                (`core' generado) gmt movie main.sh -Ntitle -T10 -C480p -Zs -D12 -Ml,png -Fmp4

I think that you it was in the last commit (Add +v to -M)

Full script:

#!/usr/bin/env bash

cat << EOF > main.sh
gmt begin
	echo \${MOVIE_FRAME} | gmt text -R0/1/0/1 -JX10c -F+f200p+cCM -B0 -X0 -Y0
gmt end
EOF
gmt movie main.sh -Ntitle -T10 -C480p -Zs -D12 -Ml,png -Fmp4

@PaulWessel
Copy link
Member Author

Strange, I do

gmt movie main.sh -N1 -T100 -C480p -Fmp4+v -Zs -D12 -Ml,png+v

and it works fine for me. Please double-check. Those are error messages from ffmpeg and not movie. I only get the notice:

movie [NOTICE]: Running: ffmpeg -loglevel warning -f image2 -framerate 12 -y -i "/Users/pwessel/1/1_%03d.png" -vcodec libx264 -pix_fmt yuv420p 1.mp4

and there are no ,png strings anywhere.

@Esteban82
Copy link
Member

gmt movie main.sh -N1 -T100 -C480p -Fmp4+v -Zs -D12 -Ml,png+v

This works for me.

@Esteban82
Copy link
Member

I run this script. The movie command works.

The second doesn't. It tries to run the below command. I think that the ,png is wrong. I try without it and I got the movie.

ffmpeg -loglevel warning -f image2 -framerate 10 -y -i "/home/federico/Github/Esteban82/Pruebas_Privadas/Branch_movie-play/movie-play1/movie-play1_%01d.png" -vcodec libx264 ,png -pix_fmt yuv420p movie-play1.mp4

Full script

#!/usr/bin/env bash

cat << EOF > main.sh
gmt begin
	echo \${MOVIE_FRAME} | gmt text -R0/1/0/1 -JX10c -F+f200p+cCM -B0 -X0 -Y0
gmt end
EOF
gmt movie main.sh -Nmovie-play1 -T5 -C480p -Z  -D10 -Ml,png -Fmp4 
gmt movie main.sh -Nmovie-play2 -T5 -C480p -Zs -D10 -Fmp4 -Ml,png  

Terminal output

bash movie-play.sh 
movie [NOTICE]: Running: ffmpeg -loglevel warning -f image2 -framerate 10 -y -i "/home/federico/Github/Esteban82/Pruebas_Privadas/Branch_movie-play/movie-play1/movie-play1_%01d.png" -vcodec libx264 ,png -pix_fmt yuv420p movie-play1.mp4
[NULL @ 0x559d3f07f000] Unable to find a suitable output format for ',png'
,png: Invalid argument
movie [ERROR]: Running FFmpeg conversion to MP4 returned error 256 - exiting.
free(): invalid pointer
movie-play.sh: línea 8: 56700 Abortado                (`core' generado) gmt movie main.sh -Nmovie-play1 -T5 -C480p -Z -D10 -Ml,png -Fmp4
movie [NOTICE]: Running: ffmpeg -loglevel warning -f image2 -framerate 10 -y -i "/home/federico/Github/Esteban82/Pruebas_Privadas/Branch_movie-play/movie-play2/movie-play2_%01d.png" -vcodec libx264  -pix_fmt yuv420p movie-play2.mp4

@PaulWessel
Copy link
Member Author

Ok think I get it; work on that after dinner

@PaulWessel
Copy link
Member Author

PaulWessel commented May 14, 2023

OK, I had made a mistake by switching some pointers and that came to bite me in parsing -F. Now should work - I was able to see the same error you had and now it is gone.

@Esteban82
Copy link
Member

Now it works.

But I am still getting a lot of scary messagges in the terminal.

@PaulWessel
Copy link
Member Author

OK, can you

  1. run it with -Vd and see what gmt docs actually runs (the "open" command it selects)
  2. paste in those messages here

@PaulWessel
Copy link
Member Author

I am suspecting it picks ffplay and it has a nasty extensive verbose setting, so then we will need to fix that.

@Esteban82
Copy link
Member

Ok Paul. I do it. I think that the important message is:

movie-play.sh: línea 18: dev/null: No existe el archivo o el directorio (File or directory does not exist)

Full message:

bash movie-play.sh 
gmt [DEBUG]: GMT_Create_Session: Terminal width = 184
gmt [DEBUG]: Obtained the ppid from parent: 76679
gmt [DEBUG]: Enter: gmtinit_new_GMT_ctrl
gmt [DEBUG]: GMT->session.SHAREDIR = /usr/local/share
gmt [DEBUG]: GMT->session.HOMEDIR = /home/federico
gmt [DEBUG]: GMT->session.USERDIR = /home/federico/.gmt [created]
gmt [DEBUG]: GMT->session.CACHEDIR = /home/federico/.gmt/cache [created]
gmt [DEBUG]: GMT: 0. Will try to find subdir=postscriptlight stem = PSL_custom_fonts suffix=.txt
gmt [DEBUG]: GMT: 1. gmt_getsharepath trying current dir
gmt [DEBUG]: GMT: 2. gmt_getsharepath trying USERDIR /home/federico/.gmt
gmt [DEBUG]: GMT: 3. gmt_getsharepath trying USERDIR subdir /home/federico/.gmt/postscriptlight
gmt [DEBUG]: GMT: 4. gmt_getsharepath trying SHAREDIR subdir /usr/local/share/postscriptlight
gmt [DEBUG]: GMT: 5. gmt_getsharepath trying SHAREDIR /usr/local/share
gmt [DEBUG]: GMT: 6. gmt_getsharepath failed
gmt [DEBUG]: Map distance calculation will be Cartesian
gmt [DEBUG]: Exit:  gmtinit_new_GMT_ctrl
gmt [DEBUG]: Enter: New_PSL_Ctrl
gmt [DEBUG]: Exit:  New_PSL_Ctrl
gmt [DEBUG]: Enter: gmt_manage_workflow
gmt [DEBUG]: Exit : gmt_manage_workflow
gmt [DEBUG]: Enter: PSL_beginsession
gmt [DEBUG]: Exit : PSL_beginsession
gmt [DEBUG]: Enter: PSL_setdefaults
gmt [DEBUG]: Exit : PSL_setdefaults
gmt [DEBUG]: Enter: gmtlib_io_init
gmt [DEBUG]: Exit : gmtlib_io_init
gmt [DEBUG]: Enter: gmt_hash_init
gmt [DEBUG]: Exit:  gmt_hash_init
gmt [DEBUG]: Enter: gmt_hash_init
gmt [DEBUG]: Exit:  gmt_hash_init
gmt [DEBUG]: Enter: gmt_reload_settings
gmt [DEBUG]: The PROJ_GEODESIC set to Vincenty
gmt [DEBUG]: Look for file /home/federico/gmt.conf
gmt [DEBUG]: Look for file /home/federico/.gmt/gmt.conf
gmt [DEBUG]: Look for file /home/federico/.gmt/server/gmt.conf
gmt [DEBUG]: Look for file /home/federico/.gmt/cache/gmt.conf
gmt [DEBUG]: Could not find file gmt.conf
gmt [DEBUG]: Exit:  gmt_reload_settings
gmt [DEBUG]: Enter: gmtlib_plot_C_format
gmt [DEBUG]: Exit:  gmtlib_plot_C_format
gmt [DEBUG]: Enter: gmtinit_get_history
gmt [DEBUG]: Initialize FFTW with 8 threads.
gmt [DEBUG]: GMT_Create_Session initialized GMT structure
gmt [DEBUG]: Loading core GMT shared library: libgmt.so
gmt [DEBUG]: Shared Library # 0 (core). Path = libgmt.so
gmt [DEBUG]: Loading GMT plugins from: /usr/local/lib/gmt/plugins
gmt [DEBUG]: Shared Library # 1 (supplements). Path = /usr/local/lib/gmt/plugins/supplements.so
gmt [DEBUG]: Revised options: main.sh -N1 -T5 -C480p -Fmp4+v -Zs -D12 -Ml,png -Vd
movie [DEBUG]: Found readable file main.sh
movie [DEBUG]: Replace file main.sh with path main.sh
movie [DEBUG]: Replace file main.sh with main.sh
movie [DEBUG]: gmt_check_executable: Pass to popen: [ffmpeg -version 2> /dev/null]
movie [DEBUG]: ffmpeg -version 2> /dev/null was successful
movie [INFORMATION]: FFmpeg 4.4.2-0ubuntu0.22.04.1 found.
movie [INFORMATION]: Paper dimensions: Width = 24c Height = 13.5c
movie [INFORMATION]: Pixel dimensions: 640 x 360
movie [INFORMATION]: Building opaque PNG images.
movie [DEBUG]: Look for file 5 in /home/federico/.gmt
movie [DEBUG]: Look for file 5 in /home/federico/.gmt/cache
movie [DEBUG]: Look for file 5 in /home/federico/.gmt/server
movie [INFORMATION]: Create parameter initiation script movie_init.sh
movie [DEBUG]: Look for file 5 in /home/federico/.gmt
movie [DEBUG]: Look for file 5 in /home/federico/.gmt/cache
movie [DEBUG]: Look for file 5 in /home/federico/.gmt/server
movie [INFORMATION]: Number of main animation frames: 5
movie [INFORMATION]: Parameter files for main animation: 5
movie [INFORMATION]: Create master frame script movie_master.sh
movie [INFORMATION]: Single master plot (frame 4) built: 1.png
movie [DEBUG]: Delete movie_master.sh
movie [INFORMATION]: Create main movie frame script movie_frame.sh
movie [INFORMATION]: Total frames to process: 5
movie [INFORMATION]: Build frames using 7 cores
movie [INFORMATION]: Execute movie frame scripts in parallel
movie [DEBUG]: Launch script for frame 0
movie [DEBUG]: Launch script for frame 1
movie [DEBUG]: Launch script for frame 2
movie [DEBUG]: Launch script for frame 3
movie [DEBUG]: Launch script for frame 4
movie [INFORMATION]: Frame 5 of 5 completed [ 20.0 %]
movie [INFORMATION]: Frame 1 of 5 completed [ 40.0 %]
movie [INFORMATION]: Frame 4 of 5 completed [ 60.0 %]
movie [INFORMATION]: Frame 3 of 5 completed [ 80.0 %]
movie [INFORMATION]: Frame 2 of 5 completed [100.0 %]
movie [NOTICE]: Running: ffmpeg -loglevel warning -f image2 -framerate 12 -y -i "/home/federico/Github/Esteban82/Pruebas_Privadas/Branch_movie-play/1/1_%01d.png" -vcodec libx264  -pix_fmt yuv420p 1.mp4
movie [INFORMATION]: MP4 movie built: 1.mp4
movie [DEBUG]: Revised options: 1.mp4
docs [DEBUG]: Opening file:///home/federico/Github/Esteban82/Pruebas_Privadas/Branch_movie-play/1.mp4 via xdg-open
kf.service.services: KApplicationTrader: mimeType "x-scheme-handler/file" not found
kf.service.services: KApplicationTrader: mimeType "x-scheme-handler/file" not found
VLC media player 3.0.16 Vetinari (revision 3.0.13-8-g41878ff4f2)
movie [DEBUG]: Delete main.sh
movie [DEBUG]: Delete movie_cleanup.sh
gmt [DEBUG]: Entering GMT_Destroy_Session
movie-play.sh: línea 18: dev/null: No existe el archivo o el directorio
federico@loki:~/Github/Esteban82/Pruebas_Privadas/Branch_movie-play$ [000055a602d1a820] main libvlc: Ejecutar vlc con la interfaz predeterminada. Use «cvlc» para usar vlc sin interfaz.
[00007fbf24004900] gl gl: Initialized libplacebo v4.192.1 (API v192)
libva info: VA-API version 1.14.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/nouveau_drv_video.so
libva info: Found init function __vaDriverInit_1_14

@PaulWessel
Copy link
Member Author

Hm, could you post your movie-play.sh again. It says line 18

movie-play.sh: línea 18: dev/null: No existe el archivo o el directorio

but there is no dev/null, only /dev/null, so something funny is happening but there is no GMT error?

@PaulWessel
Copy link
Member Author

docs [DEBUG]: Opening file:///home/federico/Github/Esteban82/Pruebas_Privadas/Branch_movie-play/1.mp4 via xdg-open
kf.service.services: KApplicationTrader: mimeType "x-scheme-handler/file" not found
kf.service.services: KApplicationTrader: mimeType "x-scheme-handler/file" not found
VLC media player 3.0.16 Vetinari (revision 3.0.13-8-g41878ff4f2)

This seems to indicate that xdc-open is not fully configured somewhere (there should be a hidden file with file type pointing to a suitable application). I found this link about KDE.

@Esteban82
Copy link
Member

Hm, could you post your movie-play.sh again. It says line 18

movie-play.sh: línea 18: dev/null: No existe el archivo o el directorio

but there is no dev/null, only /dev/null, so something funny is happening but there is no GMT error?

Sorry, I had an extra command on my script. Nothing related to GMT. Forget about this.

@PaulWessel
Copy link
Member Author

Does that mean you can approve this PR?

@Esteban82
Copy link
Member

Sorry, I couldn't test again.

@Esteban82 Esteban82 merged commit 6e7d3c8 into master May 16, 2023
6 checks passed
@Esteban82 Esteban82 deleted the movie-play branch May 16, 2023 01:49
@Esteban82
Copy link
Member

docs [DEBUG]: Opening file:///home/federico/Github/Esteban82/Pruebas_Privadas/Branch_movie-play/1.mp4 via xdg-open
kf.service.services: KApplicationTrader: mimeType "x-scheme-handler/file" not found
kf.service.services: KApplicationTrader: mimeType "x-scheme-handler/file" not found
VLC media player 3.0.16 Vetinari (revision 3.0.13-8-g41878ff4f2)

This seems to indicate that xdc-open is not fully configured somewhere (there should be a hidden file with file type pointing to a suitable application). I found this link about KDE.

Thanks. This fix the warning messages.

@maxrjones maxrjones added the add-changelog Add PR to the changelog label Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add-changelog Add PR to the changelog enhancement Improving an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Let movie main.sh handle show to open the movie
3 participants