Closed stefanbj closed 1 year ago
Also seems the check (in previous version) to prevent accidental re-uploads image sample is broken, or has been removed.
Not exactly the correct solution, but the approach seems to kind of work:
diff --git a/mapillary_tools/ffmpeg.py b/mapillary_tools/ffmpeg.py
index 7290e39..758a5be 100644
--- a/mapillary_tools/ffmpeg.py
+++ b/mapillary_tools/ffmpeg.py
@@ -8,6 +8,7 @@ import re
import subprocess
import sys
import typing as T
+import tempfile^M
from pathlib import Path
if sys.version_info >= (3, 8):
@@ -227,6 +229,16 @@ class FFMPEG:
ouput_template = f"{sample_prefix}_{NA_STREAM_IDX}_%06d{FRAME_EXT}"
stream_specifier = "v"
+ # prepare video filter grapgh script -- this can become too large for the cmdline
+ vfiltergraph= f"select={eqs}"
+ LOG.info(f"filtergraph: {vfiltergraph}")
+ #vfg = tempfile.NamedTemporaryFile(prefix="ffmpeg_vf",
+ # suffix=".tmp")
+ vfg = open(r"C:\Users\stefanb\AppData\Local\Temp\ffmpeg_vfoy1yg7ih.tmp", "w")
+ LOG.info(f"filtergraph file is: {str(vfg.name)}")
+ #vfg.write(b"{str(vfiltergraph)}")
+ vfg.write(f"{str(vfiltergraph)}")
+
cmd: T.List[str] = [
# global options should be specified first
*["-hide_banner", "-nostdin"],
@@ -236,7 +248,8 @@ class FFMPEG:
*stream_selector,
# filter videos
*[
- *["-vf", f"select={eqs}"],
+ #*["-vf", f"select={eqs}"],
+ *["-filter_script", vfg.name],
# Each frame is passed with its timestamp from the demuxer to the muxer
# vsync is deprecated but -fps_mode is not avaliable on some versions ;(
*["-vsync", "0"],
@@ -254,7 +267,9 @@ class FFMPEG:
ouput_template,
]
+ LOG.info(f"extract_specified_frames: {' '.join(cmd)}")
self._run_ffmpeg(cmd)
+ vfg .close()^M
class Probe:
The resulting printout is:
PS C:\Users\stefanb\OUTDIR\mt\mapillary_tools> python3.exe -m mapillary_tools.commands video_process --overwrite_all_EXIF_tags --interpolate_directions --geotag_source camm D:\Bilder\2023-02-26\R0011493.MP4 D:\Bilder\2023-02-26\R0011493
2023-02-26 23:13:24,717 - INFO - Extracting video information: ffprobe -print_format json -hide_banner -show_format -show_streams D:\Bilder\2023-02-26\R0011493.MP4
[mov,mp4,m4a,3gp,3g2,mj2 @ 000002070a717c40] UDTA parsing failed retrying raw
Last message repeated 1 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 000002070a717c40] DTS discontinuity in stream 2: packet 226 with DTS 555979021, packet 227 with DTS 560942136
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'D:\Bilder\2023-02-26\R0011493.MP4':
....
Unsupported codec with id 0 for input stream 2
2023-02-26 23:13:25,023 - INFO - Extracting video metdata
2023-02-26 23:13:54,396 - INFO - Found total 1496 GPS points
2023-02-26 23:13:54,397 - INFO - Extracting video samples
2023-02-26 23:13:54,472 - INFO - Extracting video samples
2023-02-26 23:13:54,616 - INFO - Found total 15011 video samples
2023-02-26 23:13:54,617 - INFO - Interpolating video samples in the time range from 0.555979021 to 1500.720445844
2023-02-26 23:13:54,978 - INFO - Found total 15002 interpolated video samples
2023-02-26 23:13:55,039 - INFO - Selected 6481 video samples by the minimal sample distance 3.0
2023-02-26 23:13:55,047 - INFO - filtergraph: select=eq(n\,6)+eq(n\,43)+eq(n\,55)+eq(n\,70)+eq(n\,88)+eq(n\,97)+eq(n\,104)+eq(n\,110)+eq(n\,116)+eq(n\,122)+eq(n\,126)+eq(n\,130)+eq(n\,134)+eq(n\,137)+eq(n\,140)+eq(n\,143)+eq(n\,146)+eq(n\,149)+eq(n\,152)+eq(n\,155)+eq(n\,158)+eq(n\,161)+eq(n\,164)+eq(n\,167)+eq(n\,170)+eq(n\,173)+eq(n\,176)+eq(n\,179)+eq(n\,182)+eq(n\,185.....
2023-02-26 23:13:55,058 - INFO - filtergraph file is: C:\Users\stefanb\AppData\Local\Temp\ffmpeg_vfoy1yg7ih.tmp
2023-02-26 23:13:55,059 - INFO - extract_specified_frames: -hide_banner -nostdin -i D:\Bilder\2023-02-26\R0011493.MP4 -map 0:1 -filter_script C:\Users\stefanb\AppData\Local\Temp\ffmpeg_vfoy1yg7ih.tmp -vsync 0 -frames:1 6481 -frame_pts 1 -qscale:1 2 D:\Bilder\2023-02-26\R0011493\.mly_ffmpeg_R0011493.MP4_3976_1677449635\R0011493_1_%06d.jpg
2023-02-26 23:13:55,064 - INFO - Extracting frames: ffmpeg -hide_banner -nostdin -i D:\Bilder\2023-02-26\R0011493.MP4 -map 0:1 -filter_script C:\Users\stefanb\AppData\Local\Temp\ffmpeg_vfoy1yg7ih.tmp -vsync 0 -frames:1 6481 -frame_pts 1 -qscale:1 2 D:\Bilder\2023-02-26\R0011493\.mly_ffmpeg_R0011493.MP4_3976_1677449635\R0011493_1_%06d.jpg
-vsync is deprecated. Use -fps_mode
Passing a number to -vsync is deprecated, use a string argument as described in the manual.
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001e5cbfae780] UDTA parsing failed retrying raw
Last message repeated 1 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001e5cbfae780] DTS discontinuity in stream 2: packet 226 with DTS 555979021, packet 227 with DTS 560942136
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'D:\Bilder\2023-02-26\R0011493.MP4':
...
frame= 6481 fps=8.2 q=24.8 Lsize=N/A time=00:25:00.60 bitrate=N/A speed= 1.9x
video:2861306kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
2023-02-26 23:27:26,133 - WARNING - The specified frame index 13409 was not extracted from stream index 1
2023-02-26 23:27:26,133 - WARNING - The specified frame index 13413 was not extracted from stream index 1
2023-02-26 23:27:26,151 - WARNING - The specified frame index 13449 was not extracted from stream index 1
2
....
2023-02-26 23:27:26,271 - WARNING - The specified frame index 14993 was not extracted from stream index 1
2023-02-26 23:27:26,271 - WARNING - The specified frame index 14996 was not extracted from stream index 1
2023-02-26 23:27:26,271 - WARNING - The specified frame index 14999 was not extracted from stream index 1
2023-02-26 23:27:26,271 - WARNING - The specified frame index 15002 was not extracted from stream index 1
2023-02-26 23:27:26,271 - WARNING - The specified frame index 15005 was not extracted from stream index 1
2023-02-26 23:27:26,290 - WARNING - Force the option "filetypes" to be "image" to avoid processing and uploading both the video samples and the videos themselves
2023-02-26 23:27:26,290 - WARNING - Since sample geotags have been written in EXIFs when you sampled videos by distance (3.0 meter(s)), so we force the option "geotag_source" to be "exif" to avoid unnecessary geotagging from the videos again
Extracting geotags from images: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████| 6481/6481 [00:27<00:00, 234.31images/s]
Overwriting EXIF: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 5839/5839 [00:12<00:00, 450.74images/s]
Verifying image EXIF writing: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████| 5839/5839 [00:40<00:00, 143.61images/s]
2023-02-26 23:29:24,091 - INFO - Check the description file for details: D:\Bilder\2023-02-26\R0011493\mapillary_image_description.json
2023-02-26 23:29:24,101 - INFO - 6481 image(s) read in total
2023-02-26 23:29:24,102 - INFO - 5839 image(s) are ready to be uploaded
2023-02-26 23:29:24,102 - ERROR - 642 image(s) failed due to MapillaryGeoTaggingError
2023-02-26 23:29:24,103 - ERROR - MapillaryProcessError: Failed to process 642 files. To skip these errors, specify --skip_process_errors
PS C:\Users\stefanb\OUTDIR\mt\mapillary_tools>```
Thanks for reporting the issue! Could you try out the latest main branch and see if it fixes? Reopen if it does not.
Just did a new upload using main/HEAD (8be59838ecb75a7aaa1a9c199ee13a47689d9b78), and can confirm that the issue is now resolved for me. (Sorry fr the late reply.)
Basic information
0.10.0
Windows
Steps to reproduce behavior
python3.exe -m mapillary_tools.commands video_process_and_upload --user_name bruno360 --overwrite_all_EXIF_tags --interpolate_directions --geotag_source camm R0011493.MP4 R0011493
Expected behavior
6481 video samples uploaded ...
Actual behavior
No images upploaded.
ERROR - MapillaryFFmpegNotFoundError: The ffmpeg command "ffmpeg" not found
Corresponding data
...
Additional information