Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken .mkv movies after midnight #197

Open
restorepoint1 opened this issue Nov 16, 2024 · 13 comments
Open

Broken .mkv movies after midnight #197

restorepoint1 opened this issue Nov 16, 2024 · 13 comments
Labels
bug Something isn't working Unable to Reproduce Developers are unable to reproduce the issue

Comments

@restorepoint1
Copy link

Did you read the guide?

Yes

What is the base version number of MotionPlus being used?

0.2.x

What was the install method?

Built from source code

What is base architecture?

x86/x64

What is the distro being used?

Ubuntu

Disto version number

24.04

Camera/Sound type(s) being used?

Network camera with RTSP

Describe the issue/problem and steps to reproduce

Motionplus d79e5c5 commit

I have 2 cameras with different configs: CAM1 and CAM2
CAM1 config:

device_name CAM1
device_id 1
pause on

netcam_url rtsp://x.x.x.x
width 1920
height 1080

timelapse_interval 1
timelapse_filename laps_%Y-%m-%d
timelapse_container mpeg4

picture_output off
picture_filename pic_%Y-%m-%d_%H-%M-%S

movie_output on
movie_filename mov_%Y-%m-%d_%H-%M-%S
movie_passthrough on

So it is 1 fps 24/7 daily laps recording and external api calls (eventstart and eventend) for 5 fps movies. Everything was ok but today after 12:00AM movies become broken until sudo service motionplus restart
All files attached

image_2024-11-16_18-48-54

journalctl.zip
mov_ok.zip
mov_broken.zip

Relevant MotionPlus log output (at log_level 8)

Attached
@restorepoint1 restorepoint1 added the bug Something isn't working label Nov 16, 2024
@Mr-Dave
Copy link
Member

Mr-Dave commented Nov 16, 2024

Looks like somehow the PTS got messed up. Can you run the following command and tell me the value of the first PTS in the resulting file?

ffprobe -v 0 -show_entries packet=pts,duration -select_streams v ./mov_2024-11-16_17-39-35.mkv >probetest.txt
(I want to see if the PTS reset to a different number after Motionplus was restarted.)

Also, do you know if the camera rebooted at 12?

@restorepoint1
Copy link
Author

Autoreboot is configured every tuesday and there is no any logs about linkdown (Last Link Up Time: Nov/12/2024 04:20:05). Today after midnight the situation is same, new movies after 0:00 are broken (0:00 is time of creation new laps file). I can keep it broken for you

image
probetest_ok.txt
probetest_broken.txt

@restorepoint1
Copy link
Author

I used old motion (not motionplus) for years and there was no such issue.
Also i can switch timelapse to hourly to check movies

@Mr-Dave
Copy link
Member

Mr-Dave commented Nov 17, 2024

Just to confirm. This is passthrough recording correct?

If so, when it is broken, can you use the web control to change the fflog_level to something higher so that those messages appear. Also validate that the camera is still feeding live images and that the problem is with the recording instead of the capture.

@restorepoint1
Copy link
Author

restorepoint1 commented Nov 17, 2024

This is passthrough recording correct?

Yes, movie_passthrough on

validate that the camera is still feeding live

Camera is working correcly, i can watch it via vlc rtsp, motion web and also timelapse has correct recording during broken movies time

I have changed fflog level but there is no changes. So i changed it in conf, switched timelapse to hourly and restarted service.

Where is fflog has to be stored? I am not observing any changes in journalctl.

@restorepoint1
Copy link
Author

After i switched timelapse to hourly the movie file between two hourly files are ok yet

@restorepoint1
Copy link
Author

Today broken videos started after 08:00
image

I will try to switch it back to daily

@Mr-Dave
Copy link
Member

Mr-Dave commented Nov 18, 2024

I've still not been able to recreate this but I think that the time of the broken MKVs being correlated to the timelapse option provides some clues.

In Motionplus the movie and timelapse are separate objects but perhaps there are some interactions inside the ffmpeg libs. If the broken MKVs go back to being corrupted past midnight once you change it back to daily, I think we can confirm that something behind the scenes is occurring.

As for the resolution, my first thought would be to change this line from retcd = av_interleaved_write_frame(oc, pkt); to retcd = av_write_frame(oc, pkt); and see if that was the cause of the cross contamination.

Let me know if you'd be able to test that change.

@restorepoint1
Copy link
Author

Today (when hourly timelapse configured) issue reverted:
Screenshot_2

let me know if you still need test with movie.cpp

@Mr-Dave
Copy link
Member

Mr-Dave commented Nov 19, 2024

You can try it. I'm at a loss as to what could be causing this. From the ffprobe of the broken MKVs, it appears that something this wrong with the PTS values. But there isn't much that Motionplus does with those. It just copies from the source, rescales to the container and writes them.

It could be interesting to know whether the issue persists when there is not any timelapse running. Or whether it happens when the mov or mp4 containers are used. After that, I'd think that a lot of debugging messages would have to be added to determine when the PTS values were getting messed up. e.g. Are they coming in from the camera wrong, rescaled wrong or only after they are written out. (That would be a massive amount of output since the issue is intermittent.)

@Mr-Dave Mr-Dave added the Unable to Reproduce Developers are unable to reproduce the issue label Nov 22, 2024
@restorepoint1
Copy link
Author

is there any little manual to build it locally using buildplus.sh?
or should i read source code of .sh?

@Mr-Dave
Copy link
Member

Mr-Dave commented Nov 22, 2024

You could use the buildplus.sh but that could be a bit much for testing purposes. (I'd only do that for long term use). I would just create a directory in your home and follow the directions for building except do not do the make install.

Once it is built, use the command /path/to/build/of/motionplus/src/motionplus -c /path/to/your/motionplus.conf That will use your newly built version of Motionplus without changing the existing install.

If you want to use the changed version long term, then you could use the buildplus.sh. If you put the buildplus.sh script into the motionplus directory and run it from there, it will use that local copy of the source code rather then cloning a fresh version from this repo.

@restorepoint1
Copy link
Author

I didnt build yet, but maybe it is important info to reproduce that i have second camera (almost the same) with config:

emulate_motion on

device_name CAM2
device_id 2

netcam_url x.x.x
width 800
height 448

timelapse_interval 0
timelapse_filename laps_%Y-%m-%d
timelapse_container mpeg4

picture_output off
picture_filename pic_%Y-%m-%d_%H-%M-%S

movie_output on
movie_filename mov_%Y-%m-%d_%H-%M-%S
movie_passthrough on
movie_max_time 3600

target_dir /mnt/share/camera/cam2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Unable to Reproduce Developers are unable to reproduce the issue
Projects
None yet
Development

No branches or pull requests

2 participants