Skip to content

Incorrect Log Entry for External FFmpeg pipe (movie_extpipe_use on) #1971

Description

@rdorsch

Did you read the guide?

Yes

What is the base version number of Motion being used?

4.7.x

What was the install method?

Installed via package tool

What is base architecture?

x86/x64

What is the distro being used?

Debian

Disto version number

13.6

Camera/Sound type(s) being used?

Network camera with RTSP

Describe the issue/problem and steps to reproduce

This is a borderline issue, could also go as enhancement.

Issue Summary

When using Motion with movie_extpipe to enforce custom encoding settings (such as generating H.264 MP4 files with -profile:v high and -movflags +faststart for mobile browser compatibility, e.g., Firefox on Android), Motion's internal logger (event_newfile) outputs an incomplete file path that lacks the file extension.

While FFmpeg correctly creates the file on disk (e.g., path/filename.mp4), Motion's system logs report writing to path/filename without the .mp4 extension.

Background & Problem Description

Root Cause for extpipe: Standard built-in Motion movie generation outputs containers that may fail to stream smoothly or play natively on mobile browsers (such as Firefox on Android) due to missing yuv420p pixel format constraints or missing MOOV atom faststart placement (-movflags +faststart).

The Workaround: To resolve playback issues, movie_extpipe is used to pipe raw video directly into an external FFmpeg process:

movie_extpipe_use on
movie_extpipe ffmpeg -y -f rawvideo -pix_fmt yuv420p -video_size %wx%h -framerate %{fps} -i pipe:0 -vcodec libx264 -profile:v high -pix_fmt yuv420p -movflags +faststart -f mp4 %f.mp4

The Logging Bug: Motion's %f variable represents the base path without an extension. When FFmpeg runs, it evaluates %f.mp4 and writes the correct file to disk. However, Motion's internal logging routine in event.c logs %f directly.

Steps to Reproduce

Configure motion.conf to use movie_extpipe appending .mp4 to %f:

movie_filename CAM0_%t-%Y%m%d-%H%M%S-%v
movie_extpipe_use on
movie_extpipe ffmpeg ... -f mp4 %f.mp4

Trigger a motion detection event.

Observe the system logs (journalctl / Motion logs).

Expected Behavior

The log entry should reflect the actual destination file created on disk:

[1:ml1:Cam1] [NTC] [EVT] event_newfile: Writing movie to file: /path/to/CAM1_101-20260904-111339-01.mp4

Actual Behavior

The execution pipe log evaluates correctly, but the subsequent Motion event_newfile log omits the .mp4 extension:

[1:ml1:Cam1] [NTC] [EVT] event_create_extpipe: pipe: ffmpeg ... -f mp4 /path/to/CAM1_101-20260904-111339-01.mp4
[1:ml1:Cam1] [NTC] [EVT] event_newfile: Writing movie to file: /path/to/CAM1_101-20260904-111339-01

Suggested Fix

Introduce a dedicated configuration option, such as movie_extpipe_extension or movie_filename_extension (e.g., movie_filename_extension mp4), to explicitly declare the file extension when using external piping (at least for the logging part).

Relevant Motion log output (at log_level 8)

[1:ml1:Cam1] [NTC] [EVT] event_create_extpipe: pipe: ffmpeg ... -f mp4 /path/to/CAM1_101-20260904-111339-01.mp4
[1:ml1:Cam1] [NTC] [EVT] event_newfile: Writing movie to file: /path/to/CAM1_101-20260904-111339-01

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions