Video Thumbnail Image Generation Issues
Hello,
I am running Motioneye in a Docker container on a Raspberrypi 4 streaming an IP camera on my local network using the ccrisan/motioneye:master-armhf image.
I sometimes have issues with the thumbnail of the videos being created and just get the default blank image like below:
I see these errors from the container:
ERROR: failed to open media preview image file: cannot identify image file <StringIO.StringIO instance at 0xf442d558>
ERROR: failed to create movie preview for /var/lib/motioneye/Camera1/2025-05-13/01-59-24.mp4: Command '[u'ffmpeg', u'-i', u'/var/lib/motioneye/Camera1/2025-05-13/01-59-24.mp4', u'-f', u'mjpeg', u'-vframes', u'1', u'-ss', u'4', u'-y', u'/var/lib/motioneye/Camera1/2025-05-13/01-59-24.mp4.thumb']' returned non-zero exit status 1
Has anyone faced a similar issue or have a work around? I have tried recreating the container/image but it still happens intermittently.
Same issue, also I am running Motioneye in a Docker container
Version: edge sha256:770d9868836f21ce75e095ec47a7ee90b5172c6ea3f37eee205890ce5a8f597a
ERROR: failed to create movie preview for /var/lib/motioneye/Camera2/2025-05-15/20-02-45.mp4: Command '['ffmpeg', '-i', '/var/lib/motioneye/Camera2/2025-05-15/20-02-45.mp4', '-f', 'mjpeg', '-vframes', '1', '-ss', '4', '-y', '/var/lib/motioneye/Camera2/2025-05-15/20-02-45.mp4.thumb']' returned non-zero exit status 234.
ERROR: failed to open media preview image file: cannot identify image file <_io.BytesIO object at 0x7f53cb429800>
ERROR: failed to open media preview image file: cannot identify image file <_io.BytesIO object at 0x7f53c8c557b0>
ERROR: failed to open media preview image file: cannot identify image file <_io.BytesIO object at 0x7f53c8c55760>
ERROR: failed to open media preview image file: cannot identify image file <_io.BytesIO object at 0x7f53c8d56fc0>
ERROR: failed to open media preview image file: cannot identify image file <_io.BytesIO object at 0x7f53c8c551c0>
ERROR: failed to open media preview image file: cannot identify image file <_io.BytesIO object at 0x7f53c8c556c0>
Same issue, also I am running Motioneye in a Docker container
Version: edge
sha256:770d9868836f21ce75e095ec47a7ee90b5172c6ea3f37eee205890ce5a8f597a
Interestingly enough when I switched to image: ghcr.io/motioneye-project/motioneye:edge@sha256:f8a08f37f069aa7fb419e60ffe73d998b798d8ae527be5992a8273ced48f1645 (the arm version mentioned in https://github.com/motioneye-project/motioneye/pkgs/container/motioneye ) the container has been running for a few days and it has been creating the video previews successfully plus I also noticed a decent amount of reduction in cpu usage.
Thank you, I tried this version ghcr.io/motioneye-project/motioneye@sha256:3a38c03592203b6039873be026238a625da3f7bab099b93faf3024542dfae14c and it is working perfectly now.
This issue is solved with the motionEye 0.43.y hence the edge container builds from here, right?
@MichaIng
unfortunately still some images are missing, I am using the latest version of docker image. (https://github.com/motioneye-project/motioneye/pkgs/container/motioneye edge)
ERROR: failed to create movie preview for /var/lib/motioneye/Camera2/2025-11-23/17-29-09.mp4: Command '['ffmpeg', '-i', '/var/lib/motioneye/Camera2/2025-11-23/17-29-09.mp4', '-f', 'mjpeg', '-vframes', '1', '-ss', '4', '-y', '/var/lib/motioneye/Camera2/2025-11-23/17-29-09.mp4.thumb']' returned non-zero exit status 234.
ERROR: failed to open media preview image file: cannot identify image file <_io.BytesIO object at 0x7f758d529e90>
ERROR: failed to open media preview image file: cannot identify image file <_io.BytesIO object at 0x7f758d52a390>
ERROR: failed to open media preview image file: cannot identify image file <_io.BytesIO object at 0x7f758d6f9210>
ERROR: failed to open media preview image file: cannot identify image file <_io.BytesIO object at 0x7f757fcfde40>
ERROR: failed to open media preview image file: cannot identify image file <_io.BytesIO object at 0x7f757fcfdee0>
ERROR: failed to open media preview image file: cannot identify image file <_io.BytesIO object at 0x7f757fcfdee0>
ERROR: failed to create movie preview for /var/lib/motioneye/Camera2/2025-11-23/17-39-02.mp4: Command '['ffmpeg', '-i', '/var/lib/motioneye/Camera2/2025-11-23/17-39-02.mp4', '-f', 'mjpeg', '-vframes', '1', '-ss', '4', '-y', '/var/lib/motioneye/Camera2/2025-11-23/17-39-02.mp4.thumb']' returned non-zero exit status 234.
Are there probably some invalid image files, like null byte files generated from the earlier motionEye version which was affected by the issue? Since ghcr.io/motioneye-project/motioneye@sha256:3a38c03592203b6039873be026238a625da3f7bab099b93faf3024542dfae14c worked perfectly as you stated, all newer versions/builds should do as well.
I'll try to add the image path to the failed to open media preview image file error message, though I guess it is exactly the /var/lib/motioneye/Camera2/2025-11-23/17-29-09.mp4.thumb and others where ffmpeg filed before. Maybe some cleanup of the failed preview image is missing, or a graceful skip when trying to open non-existing preview files.
For the ffmpeg call, maybe we can catch the STDERR.
@MichaIng
I believe the issue is related to the file size of the videos being processed. It seems that:
- If the video file size is less than 10MB, no preview image is generated.
- For videos that are 10MB or larger, a preview image is created.
Code to check: https://github.com/motioneye-project/motioneye/blob/dev/motioneye/mediafiles.py#L329
Maybe it attempts to generate an image every X seconds, which equals around 10 MiB in your case, and the first is done at X seconds, i.e. after video end 😅. Let's have a look.
EDIT: So there is the pre-capture setting, and it tries to create the preview image at either 2*that pre-capture time, but max 4 seconds. The 4 seconds -ss 4 can be seen in your logs. If the resulting file size is 0 bytes, it is tried again on 1st frame, but only if ffmpeg did not return an error. It did return error 234, which is sadly a pretty generic one, also happening on playback with unsupported codec/format etc.
@nasserbinlaboun
Can you check whether those movies are all >4 seconds long? Maybe ffmpeg errors out now if offset is more than length, while our code expects it to create a 0 bytes file with success.
@MichaIng All movies that do not have a preview image are 4 seconds or shorter.
Then I am pretty sure ffmpeg now errors out in this case. I guess we would need to check the movie duration then, and choose e.g. the rounded down middle as preview offset, if it is below 8 seconds duration or so.
If someone knows a good method with Python or ffmpeg to retrieve the duration or a video file, let me know.
ffprobe seems to be good for the job: https://superuser.com/a/945604/1183051
We can still revert to previous method with 4 seconds, if that probe fails. I.e. just adding it as additional Try: block with ignored (still logged) error, and use 4 seconds with 0 seconds attempt (on emtpy file) like before.