Movie unable to make certain frames

I am running gmt movie and it gets stuck at “100%” frame completion and does not go onto the next step of using ffmpeg to compile the frames. In reality, I can see (using htop) that there are 4 frames that it has not yet completed and refuses to complete. These frames are not the final 4 frames of the movie. For example, frame 2138 doesnt make a .jpeg (it is not in the folder that gets created). Any idea if I can make specific frames? I am able to take the images in the folder and compile separately using ffmpeg, but when it gets to frame 2138, it stops and cant go past, even though 2139,2140… exist.

This is what the terminal shows:

movie [INFORMATION]: Frame 08480 of 8491 completed [ 99.8 %]
movie [INFORMATION]: Frame 08481 of 8491 completed [ 99.8 %]
movie [INFORMATION]: Frame 08490 of 8491 completed [ 99.8 %]
movie [INFORMATION]: Frame 08478 of 8491 completed [ 99.8 %]
movie [INFORMATION]: Frame 08485 of 8491 completed [ 99.8 %]
movie [INFORMATION]: Frame 08487 of 8491 completed [ 99.8 %]
movie [INFORMATION]: Frame 08482 of 8491 completed [ 99.9 %]
movie [INFORMATION]: Frame 08483 of 8491 completed [ 99.9 %]
movie [INFORMATION]: Frame 08484 of 8491 completed [ 99.9 %]
movie [INFORMATION]: Frame 08488 of 8491 completed [ 99.9 %]
movie [INFORMATION]: Frame 08491 of 8491 completed [ 99.9 %]
movie [INFORMATION]: Frame 08477 of 8491 completed [ 99.9 %]
movie [INFORMATION]: Frame 08486 of 8491 completed [ 99.9 %]
movie [INFORMATION]: Frame 08489 of 8491 completed [ 99.9 %]
movie [INFORMATION]: Frame 08479 of 8491 completed [100.0 %]

In addition, sometimes the frames dont display properly and show weird shading on the bathymetry grids, although id wager that this is an entirely different problem.

This is my gmt call command. Nothing in the main.sh or pre.sh should cause any problem, although when I set it to make fewer frames, the video works as intended.
gmt movie main.sh -Cuhd -N$name -Tflight_path.txt -Sbpre.sh -Pb -Zs -Vi -Fmp4 -x${corepower} -D30 -H5

I had a similar problem some times ago, never could get to the bottom of it but, if I were to take a wild guess, I’d go for conflict in file access during parallel work.

Hi @EvanPi.

You can generate a single specific frame from a movie run by using the master frame option -M. For example, to make only frame 2138 as a PNG you can add: -M2138,png to your gmt movie call (in this case you can remove -Fmp4).

Alternatively, if you want to inspect what’s going wrong with particular frames, you can remove the -Zs option so that GMT does NOT delete the temporary scripts that it generates for each frame. Then you can look at the individual frame scripts and see where it gets stuck or fails.

Finally, it would be very helpful if you could share your main.sh and pre.sh scripts.

I was able to get a version to work by removing some potential file conflicts and then compile the images via ffmpeg: ffmpeg -loglevel warning -f image2 -framerate 30 -y -i "GofarAnimation6_G3Glide_backup2/GofarAnimation6_G3Glide_%05d.png" -vcodec libx264 -pix_fmt yuv420p GofarAnimation6_G3Glide_30fps.mp4

Here is my pre.sh (I am well aware that there is a bunch of bash jargon and variables here and that you do not have the data etc. to run these files):

gmt begin
  gmt set FONT_ANNOT_PRIMARY 8,Helvetica,black FONT_ANNOT_SECONDARY 8,Helvetica,black FONT_LABEL 8,Helvetica,black FONT_TITLE 10,Helvetica,black
  gmt set COLOR_BACKGROUND black COLOR_FOREGROUND white COLOR_NAN white GMT_CUSTOM_LIBS /usr/local/lib/mbsystem.so
  gmt set FORMAT_GEO_MAP ddd.xx MAP_FRAME_WIDTH 3p MAP_ANNOT_OFFSET_PRIMARY 5p

  gmt makecpt -Clapaz -T-4000/-2500/1 -Z -D -H > main.cpt

  # Set up flight path: -G is the spacing of each frame in meters.
  # Start: -106.25 -4.5125
  # End: -105.50 -4.6675
  gmt project -C-106.25/-4.5125 -E-105.50/-4.6675 -G10e -Q > flight_path.txt
gmt end

And my main.sh:

gmt begin
  gmt set FONT_ANNOT_PRIMARY 8,Helvetica,black FONT_ANNOT_SECONDARY 8,Helvetica,black FONT_LABEL 8,Helvetica,black FONT_TITLE 10,Helvetica,black
  gmt set COLOR_BACKGROUND black COLOR_FOREGROUND white COLOR_NAN white GMT_CUSTOM_LIBS /usr/local/lib/mbsystem.so
  gmt set FORMAT_GEO_MAP ddd.xx MAP_FRAME_WIDTH 3p MAP_ANNOT_OFFSET_PRIMARY 5p
  
  G1Sentry1m=../../../Data/DiveGrids/JoinedGrids/datalist625_619_620_1m_I10.grd
  CPT_FILE=main.cpt

  region=$(echo "${MOVIE_COL0} ${MOVIE_COL1}" | gmt info -I+R0.025/0.01 -Vq)
	width=$(gmt math -Q ${MOVIE_WIDTH} 1.5c SUB =)

  gmt basemap -B+n -JM${width} $region -Xc -Y0.5i

#This section was my old code that didnt plot a few grids
  #ls ../../../Data/DiveGrids/G3_Grids/*.grd > divelist.txt
  #while read line; do
  #  gmt grdimage $line -JM${width} $region -I+d -C$CPT_FILE -Q -Vq
  #done < divelist.txt

#This section is my newer version that directly plots grids
  gmt grdimage ../../../Data/DiveGrids/G3_Grids/sentry614_1m_processed_1.grd -JM${width} $region -I+d -C$CPT_FILE -Q -Vq
  gmt grdimage ../../../Data/DiveGrids/G3_Grids/sentry615_1m.grd -JM${width} $region -I+d -C$CPT_FILE -Q -Vq
  gmt grdimage ../../../Data/DiveGrids/G3_Grids/sentry616_1m.grd -JM${width} $region -I+d -C$CPT_FILE -Q -Vq
  gmt grdimage ../../../Data/DiveGrids/G3_Grids/sentry617_1m.grd -JM${width} $region -I+d -C$CPT_FILE -Q -Vq
  gmt grdimage ../../../Data/DiveGrids/G3_Grids/sentry618_1m.grd -JM${width} $region -I+d -C$CPT_FILE -Q -Vq
  gmt grdimage ../../../Data/DiveGrids/G3_Grids/sentry621_1m.grd -JM${width} $region -I+d -C$CPT_FILE -Q -Vq
  gmt grdimage ../../../Data/DiveGrids/G3_Grids/sentry622_1m.grd -JM${width} $region -I+d -C$CPT_FILE -Q -Vq
  gmt grdimage ../../../Data/DiveGrids/G3_Grids/sentry623_1m.grd -JM${width} $region -I+d -C$CPT_FILE -Q -Vq
  gmt grdimage ../../../Data/DiveGrids/G3_Grids/sentry624_1m.grd -JM${width} $region -I+d -C$CPT_FILE -Q -Vq
  gmt grdimage ../../../Data/DiveGrids/G3_Grids/sentry627_1m.grd -JM${width} $region -I+d -C$CPT_FILE -Q -Vq


	gmt basemap -JM${width} $region -Bpxa.01 -Bpya.005 -Xc -BNSWE+t"G3 AUV Sentry Bathymetry" \
            -LjRT+o0.5+w1k+f+l"Scale (km)" --MAP_TICK_LENGTH=0p --MAP_ANNOT_OBLIQUE=lat_parallel --FONT_LABEL=8p

cat > legend.txt <<'LEGEND'
G 0.25i
B main.cpt 0.15i 0.1i+h+ml -Bxaf+l"Bathymetry Depth (m)" --MAP_FRAME_PEN=1.15p --FONT_ANNOT_PRIMARY=10p --FONT_LABEL=12p --FONT_ANNOT_SECONDARY=10p
LEGEND
gmt legend legend.txt -DjLB+o0.1i/0.1i+w2i -F+gwhite+p1p 
gmt end

It is still unable to produce some frames and some other frames show a wonky grid:
frame 3740 vs 3741, where 3740 has a grid on the left that is squished for a single frame.


Hi @EvanPi .

I tested your scripts without the grids and with less frames. In my case it worked fine.

I suspect that there is an issue with a specific grid. Is it not possible to merge your all grids in one?

Unfortunately the grid would be extremely large due to the narrow swath nature of grid area. It would then have an extreme amount of nan data.