shaka-project / shaka-streamer

A simple config-file based approach to preparing streaming media, based on FFmpeg and Shaka Packager.
https://shaka-project.github.io/shaka-streamer/
Apache License 2.0
198 stars 62 forks source link

Unable to parse the frame rate string #127

Closed hmishinev closed 1 year ago

hmishinev commented 1 year ago

System info

Operating System: macOS Monterey Shaka Packager Version: v2.6.1

Issue and steps to reproduce the problem

Packager Command:

  1. Use any MOV video captured with iPhone
  2. Try to process that video

What is the expected result?

The video is processed successfuly

What happens instead?

The following error is thrown:

+ ffprobe /Users/hmishinev/Projects/Reedsy/reedsy-videos/tmp/raw/video_bundle_58104c69-bbe2-45b7-be92-364d248ba84e/video -select_streams v:0 -show_entries stream=index -of compact=p=0:nk=1
+ ffprobe /Users/hmishinev/Projects/Reedsy/reedsy-videos/tmp/raw/video_bundle_58104c69-bbe2-45b7-be92-364d248ba84e/video -select_streams v:0 -show_entries stream=field_order -of compact=p=0:nk=1
+ ffprobe /Users/hmishinev/Projects/Reedsy/reedsy-videos/tmp/raw/video_bundle_58104c69-bbe2-45b7-be92-364d248ba84e/video -select_streams v:0 -show_entries stream=avg_frame_rate -of compact=p=0:nk=1
Traceback (most recent call last):
  File "/opt/homebrew/bin/shaka-streamer", line 125, in <module>
    sys.exit(main())
  File "/opt/homebrew/bin/shaka-streamer", line 104, in main
    with controller.start(args.output, input_config_dict, pipeline_config_dict,
  File "/opt/homebrew/lib/python3.10/site-packages/streamer/controller_node.py", line 179, in start
    self._input_config = InputConfig(input_config_dict)
  File "/opt/homebrew/lib/python3.10/site-packages/streamer/input_configuration.py", line 405, in __init__
    super().__init__(dictionary)
  File "/opt/homebrew/lib/python3.10/site-packages/streamer/configuration.py", line 325, in __init__
    value = self._check_and_convert_type(field, key, value)
  File "/opt/homebrew/lib/python3.10/site-packages/streamer/configuration.py", line 381, in _check_and_convert_type
    return [self._check_and_convert_type(subfield, key, v) for v in value]
  File "/opt/homebrew/lib/python3.10/site-packages/streamer/configuration.py", line 381, in <listcomp>
    return [self._check_and_convert_type(subfield, key, v) for v in value]
  File "/opt/homebrew/lib/python3.10/site-packages/streamer/configuration.py", line 368, in _check_and_convert_type
    sub_object = field.type(value)
  File "/opt/homebrew/lib/python3.10/site-packages/streamer/input_configuration.py", line 244, in __init__
    self.frame_rate = autodetect.get_frame_rate(self)
  File "/opt/homebrew/lib/python3.10/site-packages/streamer/autodetect.py", line 125, in get_frame_rate
    frame_rate = float(fraction[0]) / float(fraction[1])
ValueError: could not convert string to float: '1091|'

https://github.com/shaka-project/shaka-streamer/blob/main/streamer/autodetect.py#L124

A test video file is available here: https://drive.google.com/file/d/1RS90AgRXLus1o_8JeD_pKFlAUKkQJCp6/view?usp=sharing

joeyparrish commented 1 year ago

I believe this belongs in the shaka-streamer repo. I'll move the issue. Thanks!

joeyparrish commented 1 year ago

@hmishinev, could you please show us the output of this command?

ffprobe \
  /Users/hmishinev/Projects/Reedsy/reedsy-videos/tmp/raw/video_bundle_58104c69-bbe2-45b7-be92-364d248ba84e/video \
  -select_streams v:0 -show_entries stream=avg_frame_rate -of compact=p=0:nk=1
hmishinev commented 1 year ago

@joeyparrish, this is the result:

➜  reedsy git:(profile-videos) ✗ ffprobe \
  /Users/hmishinev/Projects/Reedsy/reedsy-videos/tmp/raw/video_bundle_58104c69-bbe2-45b7-be92-364d248ba84e/video \
  -select_streams v:0 -show_entries stream=avg_frame_rate -of compact=p=0:nk=1
ffprobe version 5.1 Copyright (c) 2007-2022 the FFmpeg developers
  built with Apple clang version 13.1.6 (clang-1316.0.21.2.5)
  configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/5.1 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-neon
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/hmishinev/Projects/Reedsy/reedsy-videos/tmp/raw/video_bundle_58104c69-bbe2-45b7-be92-364d248ba84e/video':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    creation_time   : 2022-10-28T06:57:53.000000Z
    com.apple.quicktime.location.accuracy.horizontal: 5.000000
    com.apple.quicktime.location.ISO6709: +42.4917+027.4655+019.820/
    com.apple.quicktime.make: Apple
    com.apple.quicktime.model: iPhone 12 Pro Max
    com.apple.quicktime.software: 16.0.3
    com.apple.quicktime.creationdate: 2022-10-28T09:57:53+0300
  Duration: 00:00:10.91, start: 0.000000, bitrate: 10873 kb/s
  Stream #0:0[0x1](und): Video: hevc (Main 10) (hvc1 / 0x31637668), yuv420p10le(tv, bt2020nc/bt2020/arib-std-b67), 1920x1080, 10663 kb/s, 29.97 fps, 29.97 tbr, 600 tbn (default)
    Metadata:
      creation_time   : 2022-10-28T06:57:53.000000Z
      handler_name    : Core Media Video
      vendor_id       : [0][0][0][0]
      encoder         : HEVC
    Side data:
      DOVI configuration record: version: 1.0, profile: 8, level: 4, rpu flag: 1, el flag: 0, bl flag: 1, compatibility id: 4
      displaymatrix: rotation of -90.00 degrees
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 164 kb/s (default)
    Metadata:
      creation_time   : 2022-10-28T06:57:53.000000Z
      handler_name    : Core Media Audio
      vendor_id       : [0][0][0][0]
  Stream #0:2[0x3](und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
    Metadata:
      creation_time   : 2022-10-28T06:57:53.000000Z
      handler_name    : Core Media Metadata
  Stream #0:3[0x4](und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
    Metadata:
      creation_time   : 2022-10-28T06:57:53.000000Z
      handler_name    : Core Media Metadata
  Stream #0:4[0x5](und): Data: none (mebx / 0x7862656D), 34 kb/s (default)
    Metadata:
      creation_time   : 2022-10-28T06:57:53.000000Z
      handler_name    : Core Media Metadata
Unsupported codec with id 0 for input stream 2
Unsupported codec with id 0 for input stream 3
Unsupported codec with id 0 for input stream 4
32700/1091|
joeyparrish commented 1 year ago

Okay, thanks. That's very helpful. Looks like it should be as easy as discarding the | character to fix it.

mariocynicys commented 1 year ago

The issue still persists for other probes as well https://github.com/shaka-project/shaka-streamer/pull/128#discussion_r1013417939