ocean-data-factory-sweden / kso

Notebooks to upload/download marine footage, connect to a citizen science project, train machine learning models and publish marine biological observations.
GNU General Public License v3.0
4 stars 12 forks source link

ffmpegError in Upload subjects to Zooniverse #423

Closed Bergylta closed 3 weeks ago

Bergylta commented 3 weeks ago

🐛 Bug

If adding modification when creating example clips to check size and such, a ffmpeg error shows up

To Reproduce (REQUIRED)

Input:

pp.generate_zoo_clips(
    is_example=True,
    use_gpu=gpu_available.result,
)

INFO:root:Returning the fpath /cache/album/cache/kso-user/bucket/output/tjorn_2023/gp_tjorn/transect_rigs_27_09.mp4 Length of clips (seconds):10 Movie range to generate clips from (seconds):102 – 158 INFO:root:Number of clips to generate: 5 Number of modifications:1 Select modification: Blur_sensitive_info

Output:

INFO:root:Extracting clips
  0%|          | 0/5 [00:00<?, ?it/s]ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
  configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/cache/album/cache/kso-user/bucket/output/tjorn_2023/gp_tjorn/transect_rigs_27_09.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf60.16.100
  Duration: 00:02:38.81, start: 0.000000, bitrate: 1103 kb/s
  Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 955 kb/s, 119 fps, 119 tbr, 15232 tbn, 238 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
      encoder         : Lavc60.31.102 libx264
  Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
Filtergraph '.drawbox(0, 0, "iw", "ih*(15/100)", color="black",thickness="fill").drawbox(0, "ih*(95/100)","iw", "ih*(15/100)", color="black", thickness="fill")' was defined for video output stream 0:0 but codec copy was selected.
Filtering and streamcopy cannot be used together.
ERROR:root:ffmpeg error occurred.
ERROR:root:stderr: ffmpeg error (see stderr output for detail)
  0%|          | 0/5 [00:00<?, ?it/s]
11:20:45
---------------------------------------------------------------------------
Error                                     Traceback (most recent call last)
/cache/album/cache/kso-user/kso/kso_utils/project.py in on_button_clicked(b)
    664 
    665             def on_button_clicked(b):
--> 666                 self.generated_clips = zoo_utils.create_clips(
    667                     available_movies_df=self.available_movies_df,
    668                     selected_movies=str(self.selected_movies[0]),

/cache/album/cache/kso-user/kso/kso_utils/zooniverse_utils.py in create_clips(available_movies_df, selected_movies, movies_paths, clip_selection, project, modification_details, gpu_available, is_example, pool_size)
   1616     # Read each movie and extract the clips from the original videos
   1617     for index, row in tqdm(clips_start_df.iterrows(), total=clips_start_df.shape[0]):
-> 1618         extract_clips(
   1619             movie_path=movies_paths,
   1620             clip_length=clip_length,

/cache/album/cache/kso-user/kso/kso_utils/zooniverse_utils.py in extract_clips(movie_path, clip_length, upl_second_i, output_clip_path, modification_details, gpu_available, remove_audio)
   1457         if e.stderr is not None:
   1458             logging.error(f"stderr: {e.stderr.decode('utf8')}")
-> 1459         raise e
   1460 
   1461     # Ensure the clip was extracted

/cache/album/cache/kso-user/kso/kso_utils/zooniverse_utils.py in extract_clips(movie_path, clip_length, upl_second_i, output_clip_path, modification_details, gpu_available, remove_audio)
   1446     # Run the ffmpeg clip extraction code
   1447     try:
-> 1448         ffmpeg.input(input_path, **input_options).output(
   1449             output_path, **output_options
   1450         ).run(overwrite_output=True)

[~/.local/lib/python3.10/site-packages/ffmpeg/_run.py](https://album.cloudina.org/user/kso-user/lab/tree/kso/notebooks/classify/~/.local/lib/python3.10/site-packages/ffmpeg/_run.py) in run(stream_spec, cmd, capture_stdout, capture_stderr, input, quiet, overwrite_output)
    323     retcode = process.poll()
    324     if retcode:
--> 325         raise Error('ffmpeg', out, err)
    326     return out, err
    327 

Error: ffmpeg error (see stderr output for detail)

Expected behavior

Additional context

Shows up in the log window when adding a modification to example clips, if no modifications added, a "KeyError: site_id" shows up instead in the log window

jannesgg commented 3 weeks ago

@Bergylta This issue is part of an existing problem where we cannot use a GPU in the production environment with FFMpeg (incompatible device). I am closing this for now, select NO GPU for now until this is resolved.