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

0.8.2 video_process command for GoPro camera does not work on Windows 10 #503

Closed
WASD42 opened this issue Apr 4, 2022 · 4 comments · Fixed by #510
Closed

0.8.2 video_process command for GoPro camera does not work on Windows 10 #503

WASD42 opened this issue Apr 4, 2022 · 4 comments · Fixed by #510
Labels

Comments

@WASD42
Copy link

WASD42 commented Apr 4, 2022

Basic information

  • Release version: 0.8.2
  • System: Windows 10
  • Capture Device: GoPro Hero 8 Black

Steps to reproduce behavior

  1. Capture a video with GoPro
  2. run mapillary_tools --verbose video_process $VIDEO_PATH $PICS_PATH --geotag_source "gopro_videos" --interpolate_directions --video_sample_interval 1

Expected behavior

The process finishes successfully.

Actual behavior

The process fails with the exception:

2022-04-04 09:14:17,762 - INFO    - Extracting frames: ffmpeg -i E:\Mapillary\from\GH010012.MP4 -y -nostats -loglevel 0 -hide_banner -codec copy -map 0:3 -f rawvideo C:\Users\PROFES~1\AppData\Local\Temp\tmpoanptej3
Traceback (most recent call last):
  File "C:\Python310\Scripts\mapillary_tools-script.py", line 33, in <module>
    sys.exit(load_entry_point('mapillary-tools==0.8.2', 'console_scripts', 'mapillary_tools')())
  File "C:\Python310\lib\site-packages\mapillary_tools\commands\__main__.py", line 127, in main
    args.func(argvars)
  File "C:\Python310\lib\site-packages\mapillary_tools\commands\video_process.py", line 15, in run
    ProcessCommand().run(args)
  File "C:\Python310\lib\site-packages\mapillary_tools\commands\process.py", line 238, in run
    descs = process_geotag_properties(
  File "C:\Python310\lib\site-packages\mapillary_tools\process_geotag_properties.py", line 158, in process_geotag_properties
    descs = geotag.to_description()
  File "C:\Python310\lib\site-packages\mapillary_tools\geotag\geotag_from_gopro.py", line 55, in to_description
    points = get_points_from_gpmf(video)
  File "C:\Python310\lib\site-packages\mapillary_tools\geotag\geotag_from_gopro.py", line 120, in get_points_from_gpmf
    gpmf_data = extract_and_parse_bin(path)
  File "C:\Python310\lib\site-packages\mapillary_tools\geotag\geotag_from_gopro.py", line 114, in extract_and_parse_bin
    ffmpeg.extract_stream(path, tmp.name, stream_id)
  File "C:\Python310\lib\site-packages\mapillary_tools\ffmpeg.py", line 93, in extract_stream
    run_ffmpeg(cmd)
  File "C:\Python310\lib\site-packages\mapillary_tools\ffmpeg.py", line 36, in run_ffmpeg
    subprocess.check_call(full_cmd)
  File "C:\Python310\lib\subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ffmpeg', '-i', 'E:\\Mapillary\\from\\GH010012.MP4', '-y', '-nostats', '-loglevel', '0', '-hide_banner', '-codec', 'copy', '-map', '0:3', '-f', 'rawvideo', 'C:\\Users\\PROFES~1\\AppData\\Local\\Temp\\tmpoanptej3']' returned non-zero exit status 1.

Corresponding data

The exception is caused by using tempfile.NamedTemporaryFile() function and trying to access it by a subprocess (which is impossible on Windows since the NT version) in mapillary_tools\geotag\geotag_from_gopro.py:

with tempfile.NamedTemporaryFile() as tmp:
   ...
   ffmpeg.extract_stream(path, tmp.name, stream_id)

I was able to fix the issue by replacing it with:

tmp = tempfile.NamedTemporaryFile(delete = False)
    try:
        LOG.debug("Extracting GoPro stream %s to %s", stream_id, tmp.name)

        tmp.close() # Let's close the file to let subprocess access it
        ffmpeg.extract_stream(path, tmp.name, stream_id)

        LOG.debug("Parsing GoPro GPMF %s", tmp.name)
        r = parse_bin(tmp.name)
    finally:
        os.remove(tmp.name)
        return r
@WASD42 WASD42 changed the title 0.8.2 video_process command does not work for Windows 10 0.8.2 video_process command for GoPro camera does not work on Windows 10 Apr 4, 2022
@ptpt ptpt added the bug label Apr 4, 2022
RudyTheDev added a commit to RudyTheDev/mapillary_tools that referenced this issue May 27, 2022
@RudyTheDev
Copy link

I am experiencing the same crash and the above fix by WASD42 appears to fix it. Win 10 Pro.

I was doing mapillary_tools-0.8.2-win.exe video_process "videos/" "images/" --geotag_source "gopro_videos" --interpolate_directions --video_sample_interval 1

The trace I got was:

  File "main.py", line 4, in <module>
  File "mapillary_tools\commands\__main__.py", line 127, in main
  File "mapillary_tools\commands\video_process.py", line 15, in run
  File "mapillary_tools\commands\process.py", line 238, in run
  File "mapillary_tools\process_geotag_properties.py", line 158, in process_geotag_properties
  File "mapillary_tools\geotag\geotag_from_gopro.py", line 55, in to_description
  File "mapillary_tools\geotag\geotag_from_gopro.py", line 120, in get_points_from_gpmf
  File "mapillary_tools\geotag\geotag_from_gopro.py", line 114, in extract_and_parse_bin
  File "mapillary_tools\ffmpeg.py", line 93, in extract_stream
  File "mapillary_tools\ffmpeg.py", line 36, in run_ffmpeg
  File "subprocess.py", line 364, in check_call
subprocess.CalledProcessError: Command '['ffmpeg', '-i', 'videos/GH150133.MP4', '-y', '-nostats', '-loglevel', '0', '-hide_banner', '-codec', 'copy', '-map', '0:3', '-f', 'rawvideo', 'C:\\Users\\HK\\AppData\\Local\\Temp\\tmpewip3gtv']' returned non-zero exit status 1.
[8312] Failed to execute script 'main' due to unhandled exception!

Which led me to this issue report.

@ptpt
Copy link
Member

ptpt commented Jun 1, 2022

Thanks. Will fix it in the next release.

@ptpt
Copy link
Member

ptpt commented Jun 29, 2022

Could you check if the latest works for you on Windows?

@RudyTheDev
Copy link

I does work for me on Windows now, yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants