Lychee icon indicating copy to clipboard operation
Lychee copied to clipboard

Video import fails when FFProbe can't read EXIF data. Stops sync

Open felin-arch opened this issue 5 years ago • 2 comments

Detailed description of the problem [REQUIRED]

Video import fails when FFProbe can't read EXIF data. Lychee categorizes the file as a video, which it is, but PHPExif can't read it's metadata and fails.

Steps to reproduce the issue

Steps to reproduce the behavior:

  1. get this file: https://we.tl/t-6vo1fTqt1r (link is good for a week)
  2. put it in a directory you will use to sync lychee
  3. Sync a directory containing the file from the CLI using php artisan lychee:sync /dir/with/video/file
  4. See error
In app/Metadata/Extractor.php:157 
$exif->getMimeType() member is called on boolean

The above file is a video file, but PHP says it is an 'application/octet-stream'. This causes FFProbe to fail parsing the exif data, returning "false". This also stops the full sync, instead of just ignoring this error.

I managed to track this down to https://github.com/LycheeOrg/php-exif/blob/8980669dc60b9ce234d895a77f046592958fea4c/lib/PHPExif/Adapter/FFprobe.php#L105

I think we should fall back on the native adapter in such cases. That's what I did locally by adding a false-check. I'll submit the PR shortly.

Output of the diagnostics [REQUIRED]

I am using your official Docker build from LycheeOrg/Lychee-Docker. Diagnostics ------- Info: Latest version of PHP is 7.4 Warning: You may experience problems when uploading a photo of large size. Take a look in the FAQ for details. Warning: Dropbox import not working. dropbox_key is empty.

System Information
--------------
Lychee Version (git):            No git data found.
DB Version:                      4.0.8

composer install:                --no-dev
APP_ENV:                         production
APP_DEBUG:                       false

System:                          Linux
PHP Version:                     7.3
Max uploaded file size:          20M
Max post size:                   100M
MySQL Version:                   10.5.8-MariaDB-1:10.5.8+maria~focal

Imagick:                         1
Imagick Active:                  1
Imagick Version:                 1690
GD Version:                      2.2.5



Config Information
--------------
version:                         040008
check_for_updates:               0
sorting_Photos_col:              title
sorting_Photos_order:            ASC
sorting_Albums_col:              title
sorting_Albums_order:            ASC
imagick:                         1
skip_duplicates:                 0
small_max_width:                 0
small_max_height:                360
medium_max_width:                1920
medium_max_height:               1080
lang:                            en
layout:                          1
image_overlay:                   0
image_overlay_type:              desc
default_license:                 none
compression_quality:             90
full_photo:                      1
delete_imported:                 0
Mod_Frame:                       1
Mod_Frame_refresh:               30
thumb_2x:                        1
small_2x:                        1
medium_2x:                       1
landing_page_enable:             0
landing_owner:                   John Smith
landing_title:                   John Smith
landing_subtitle:                Cats, Dogs & Humans Photography
landing_facebook:                https://www.facebook.com/JohnSmith
landing_flickr:                  https://www.flickr.com/JohnSmith
landing_twitter:                 https://www.twitter.com/JohnSmith
landing_instagram:               https://instagram.com/JohnSmith
landing_youtube:                 https://www.youtube.com/JohnSmith
landing_background:              dist/cat.jpg
site_title:                      Archive
site_copyright_enable:           0
site_copyright_begin:            2019
site_copyright_end:              2019
additional_footer_text:          
display_social_in_gallery:       0
public_search:                   0
SL_enable:                       0
SL_for_admin:                    0
public_recent:                   0
recent_age:                      1
public_starred:                  0
downloadable:                    0
photos_wraparound:               1
map_display:                     1
zip64:                           1
map_display_public:              0
map_provider:                    Wikimedia
force_32bit_ids:                 0
map_include_subalbums:           0
update_check_every_days:         3
has_exiftool:                    1
share_button_visible:            0
import_via_symlink:              1
has_ffmpeg:                      1
location_decoding:               0
location_decoding_timeout:       30
location_show:                   0
location_show_public:            0
rss_enable:                      0
rss_recent_days:                 7
rss_max_items:                   100
prefer_available_xmp_metadata:   0
editor_enabled:                  0
lossless_optimization:           0
swipe_tolerance_x:               150
swipe_tolerance_y:               250
local_takestamp_video_formats:   .avi|.mov
log_max_num_line:                1000
unlock_password_photos_with_url_param: 0

felin-arch avatar Dec 07 '20 22:12 felin-arch

Well I;m new to this application and I'm no expert in it by any means, but I downloaded the .MOV file and ran php artisan lychee:sync /dir/with/file and it imported the .MOV file without an error. I get exif data on most movies (although not this one even though there is some in it like capture date). It does import as application/octetstream . I've always converted my .mov and .avi files to mp4 x264 before importing to lychee as most browsers won't play mov and avi via html5 which lychee uses to display/play the movie. My swtup has_exiftool = 0 however, not sure if that makes a difference. I really don't know what that directive is as it does not seem to be documented. I'm not using through Docker.

73blazer avatar Dec 08 '20 16:12 73blazer

@73blazer this is probably because you are using the native adapter (no exiftool, no ffmpeg). The docker image has exiftool and FFMPEG in it.

The above PR handles the "same" error we handle during an exiftool failure with the try/catch. Exiftool throws and exception while FFMPEG adapter returns false.

felin-arch avatar Dec 10 '20 21:12 felin-arch