juanmcasillas / gopro2gpx

Parse the gpmd stream for GOPRO moov track (MP4) and extract the GPS info into a GPX (and kml) file.
GNU General Public License v3.0
194 stars 49 forks source link

UnboundLocalError: local variable 'major' referenced before assignment #37

Closed forna closed 1 year ago

forna commented 1 year ago

I am getting this error with the latest ffmpeg:

D:\projects\JS\goPro-to-geoJson\drive\video>gopro2gpx -s -vvv GH010086.MP4 GH010086 Traceback (most recent call last): File "C:\Program Files\Python\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Program Files\Python\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Program Files\Python\Scripts\gopro2gpx.exe__main.py", line 7, in File "C:\Program Files\Python\lib\site-packages\gopro2gpx\gopro2gpx.py", line 191, in main main_core(args) File "C:\Program Files\Python\lib\site-packages\gopro2gpx\gopro2gpx.py", line 152, in main_core ffmpegtools = FFMpegTools(ffprobe=config.ffprobe_cmd, ffmpeg=config.ffmpeg_cmd) File "C:\Program Files\Python\lib\site-packages\gopro2gpx\ffmpegtools.py", line 34, in init__ self.version = self.getVersion() File "C:\Program Files\Python\lib\site-packages\gopro2gpx\ffmpegtools.py", line 49, in getVersion return Version(major, medium, minor) UnboundLocalError: local variable 'major' referenced before assignment

The ffmpeg version: D:\projects\JS\goPro-to-geoJson\drive\video>ffmpeg -version ffmpeg version 2022-12-15-git-9adf02247c-essentials_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers built with gcc 12.1.0 (Rev2, Built by MSYS2 project) configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband libavutil 57. 43.100 / 57. 43.100 libavcodec 59. 55.100 / 59. 55.100 libavformat 59. 34.102 / 59. 34.102 libavdevice 59. 8.101 / 59. 8.101 libavfilter 8. 52.100 / 8. 52.100 libswscale 6. 8.112 / 6. 8.112 libswresample 4. 9.100 / 4. 9.100 libpostproc 56. 7.100 / 56. 7.100

forna commented 1 year ago

It seems I've fixed it by changing ffmpegtools.py line 43 to:

version_info_reg = re.compile('ffmpeg version (\d+)-(\d+)-(\d+)', flags=re.I)

lukegluke commented 1 year ago

It helps me, thanks.

juanmcasillas commented 1 year ago

Hello.

I changed the version parsing code to support the old and new formats.

#
# manage old format, and new formats here. Examples
#
# ffmpeg version N-109674-gc0bc804e55-20230127 Copyright (c) 2000-2023 the FFmpeg developers
# Version(major=109674, medium='gc0bc804e55', minor=20230127)
# ffmpeg version 2023-01-25-git-2c3107c3e9-essentials_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
# Version(major=2023, medium=1, minor=25)
#

See this commit for more details.

juanmcasillas commented 1 year ago

Issue closed