gtiff2mp4 logical error

Post Reply
sonnyk
Posts: 3
Joined: Fri Dec 02, 2022 5:16 pm

gtiff2mp4 logical error

Post by sonnyk »

When running gtiff2mp4 on ll-bbox cropped gtiffs the mp4 produced is completely black and does not show any of the input gtiffs.
Ex. of command line:
Username:~/gtiff_file_directory$ $GEO2GRID_HOME/bin/gtiff2mp4.sh test.mp4 `ls`
Creating temporary directory for sorting frames...
Creating video file from:
{list of gtiff files}
Total number of input files: 81
Preparing images for video conversion...
Generating animation...
ffmpeg version 5.0.1 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 10.3.0 (conda-forge gcc 10.3.0-16)
configuration: --prefix=/home/conda/feedstock_root/build_artifacts/ffmpeg_1650807798678/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac --cc=/home/conda/feedstock_root/build_artifacts/ffmpeg_1650807798678/_build_env/bin/x86_64-conda-linux-gnu-cc --disable-doc --disable-openssl --enable-demuxer=dash --enable-gnutls --enable-gpl --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-vaapi --enable-libx264 --enable-libx265 --enable-libaom --enable-libsvtav1 --enable-libxml2 --enable-libvpx --enable-pic --enable-pthreads --enable-shared --disable-static --enable-version3 --enable-zlib --enable-libmp3lame --pkg-config=/home/conda/feedstock_root/build_artifacts/ffmpeg_1650807798678/_build_env/bin/pkg-config
libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
libpostproc 56. 3.100 / 56. 3.100
Input #0, image2, from 'gtiff2mp4_tmp/%03d.GOES-16_ABI_RadM1_true_color_20230206_211955_GOES-East.tif':
Duration: 00:00:03.38, start: 0.000000, bitrate: N/A
Stream #0:0: Video: tiff, rgba, 174x146, 24 fps, 24 tbr, 24 tbn
Stream mapping:
Stream #0:0 -> #0:0 (tiff (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x557815176040] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 0x557815176040] profile High, level 1.1, 4:2:0, 8-bit
[libx264 @ 0x557815176040] 264 - core 161 r3030M 8bd6d28 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=5 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=25.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'test.mp4':
Metadata:
encoder : Lavf59.16.100
Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p(tv, progressive), 174x146, q=2-31, 24 fps, 12288 tbn
Metadata:
encoder : Lavc59.18.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame= 81 fps=0.0 q=-1.0 Lsize= 4kB time=00:00:03.25 bitrate= 9.4kbits/s speed=24.7x
video:2kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 92.755829%
[libx264 @ 0x557815176040] frame I:1 Avg QP:11.00 size: 52
[libx264 @ 0x557815176040] frame P:20 Avg QP:11.30 size: 21
[libx264 @ 0x557815176040] frame B:60 Avg QP:14.67 size: 14
[libx264 @ 0x557815176040] consecutive B-frames: 1.2% 0.0% 0.0% 98.8%
[libx264 @ 0x557815176040] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 @ 0x557815176040] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 0.0% 0.0% 0.0% 0.0% 0.0% skip:100.0%
[libx264 @ 0x557815176040] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.0% 0.0% 0.0% direct: 0.0% skip:100.0%
[libx264 @ 0x557815176040] 8x8 transform intra:0.0%
[libx264 @ 0x557815176040] coded y,uvDC,uvAC intra: 0.0% 0.0% 0.0% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x557815176040] i16 v,h,dc,p: 90% 0% 10% 0%
[libx264 @ 0x557815176040] i8c dc,h,v,p: 100% 0% 0% 0%
[libx264 @ 0x557815176040] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x557815176040] kb/s:3.04
Done
Removing temporary directory "gtiff2mp4_tmp"

Attached below is one of the gtiffs used.
sample of one of the gtiffs used
sample of one of the gtiffs used
GOES-16_ABI_RadM1_true_color_20230206_221655_GOES-East.tif (69.21 KiB) Viewed 19533 times
davidh
Posts: 116
Joined: Tue Jun 04, 2013 11:19 am

Re: gtiff2mp4 logical error

Post by davidh »

I'm so sorry about this. This really seems to be something we missed between me adding a couple bugs to the script and other outside changes making it worse. Bottom line is it seems ffmpeg no longer supports geotiffs that are internally tiled. I've put together a few fixes that the Geo2Grid team can prepare for a future bug-fix release of Geo2Grid. Would you be willing to try them out?

If you're familiar with diff/patch files, I've put together the below changes that should fix or workaround all the issues you've run into. You can make the adjustments to the script yourself based on this:

Code: Select all

--- a/bin/gtiff2mp4.sh
+++ b/bin/gtiff2mp4.sh
@@ -94,7 +94,7 @@ echo "Creating video file from: "
 printf '%s\n' ${INPUT_FILES[@]}
 echo "Total number of input files: ${#INPUT_FILES[@]}"

-FILE_EXT=${INPUT_FILES[0]##.}
+FILE_EXT=${INPUT_FILES[0]##*.}

 x=1
 echo "Preparing images for video conversion..."
@@ -102,10 +102,11 @@ for i in "${INPUT_FILES[@]}"; do
     counter=$(printf %03d $x)
     img_width_height=`gdal_size $i`
     img_width=`echo $img_width_height | cut -f1 -d' '`
-    img_height=`echo $img_height | cut -f3 -d' '`
+    img_height=`echo $img_width_height | cut -f3 -d' '`
     new_width=`get_new_image_width $img_width $img_height`
     if [[ $new_width -eq $img_width ]]; then
-        ln -s "../$i" "${TMP_FRAME_DIR}/${counter}.${FILE_EXT}"
+        # if a geotiff, make sure it isn't tiled (ffmpeg can't handle tiled tiffs)
+        gdal_translate "${i}" "${TMP_FRAME_DIR}/${counter}.${FILE_EXT}"
     else
         echo "Scaling image to work with ffmpeg (New width=${new_width})"
         gdal_translate -outsize $new_width 0 $i "${TMP_FRAME_DIR}/${counter}.${FILE_EXT}"
Please let me know how it goes. It'll really help me figure out what our options are for releasing a fix for this.
Post Reply