FFmpeg: Copy ‘location’ metadata to output file name

I have a FFmpeg batch script for downscaling all videos in a directory. The videos have been recorded in different forests, and I would like to write the geolocation as the output file name.

Currenly, my script is

FOR /F "tokens=*" %G IN ('dir /b *.MP4') DO "c:\Program Files\ffmpeg\bin\ffmpeg.exe" -i "%G"  -vf "scale=trunc(iw/10)*2:trunc(ih/10)*2" -vcodec libx265 -crf 20 "%~nG_komprimeret.mp4"

When I look at the file’s metadata, I can see the location

Output #0, mp4, to 'GH013764_komprimeret.mp4':
  Metadata:
    major_brand     : mp41
    minor_version   : 538120216
    compatible_brands: mp41
    firmware        : HD7.01.01.90.00
    location        : +56.1710+009.5756/
    location-eng    : +56.1710+009.5756/

My files output should be named something like GH013764_komprimeret_+56.1710+009.5756.mp4.

How is it possible to include the location metadata in the output file name?

Read more here: Source link