ozmartian / vidcutter

A modern yet simple multi-platform video cutter and joiner.
GNU General Public License v3.0
1.78k stars 134 forks source link

App hangs when cutting frame accurately #337

Open nedart opened 2 years ago

nedart commented 2 years ago

Poking around the logs and printing some variables from the python script, it looks like sometimes the files vidcutter is working with don't have audio/video streams in the format vidcutter is expecting. The output from mediainfo does not always contain an audio stream.

2021-12-06 21:31 - root - CRITICAL -   File "/usr/lib/python3.9/site-packages/vidcutter/videocutter.py", line 1421, in smartmonitor
    self.joinMedia(self.smartcut_monitor.clips)
  File "/usr/lib/python3.9/site-packages/vidcutter/videocutter.py", line 1434, in joinMedia
    if self.videoService.isMPEGcodec(filelist[0]):
  File "/usr/lib/python3.9/site-packages/vidcutter/libs/videoservice.py", line 608, in isMPEGcodec
    codec = self.codecs(source)[0].lower()
  File "/usr/lib/python3.9/site-packages/vidcutter/libs/videoservice.py", line 268, in codecs
    acodec = re.search(r'Stream.*Audio:\s(\w+)', result).group(1)

2021-12-06 21:31 - root - CRITICAL - <class 'AttributeError'>: 'NoneType' object has no attribute 'group'
Len-B commented 2 years ago

I'm also experiencing hanging when saving media. It nearly always hangs at 60%.

I have copied the log file entries in the hope that this might assist:

2021-12-18 15:50 - vidcutter.libs.videoservice - INFO - smartcut files are MPEG based so join via MPEG-TS 2021-12-18 15:50 - vidcutter.libs.videoservice - ERROR - Exception during MPEG-TS join Traceback (most recent call last): File "vidcutter\libs\videoservice.py", line 622, in mpegtsJoin File "ntpath.py", line 204, in splitext TypeError: expected str, bytes or os.PathLike object, not NoneType 2021-12-18 15:50 - vidcutter.libs.videoservice - INFO - smartcut MPEG-TS join failed, retry with standard concat 2021-12-18 15:50 - root - CRITICAL - File "vidcutter\libs\videoservice.py", line 418, in smartcheck File "vidcutter\libs\videoservice.py", line 445, in smartjoin File "vidcutter\libs\videoservice.py", line 459, in join File "ntpath.py", line 223, in dirname File "ntpath.py", line 185, in split

2021-12-18 15:50 - root - CRITICAL - <class 'TypeError'>: expected str, bytes or os.PathLike object, not NoneType 2021-12-18 15:57 - root - CRITICAL - File "vidcutter\videocutter.py", line 1361, in saveMedia File "vidcutter\videocutter.py", line 1406, in smartcutter File "vidcutter\libs\videoservice.py", line 331, in smartcut File "vidcutter\libs\videoservice.py", line 590, in getGOPbisections

2021-12-18 15:57 - root - CRITICAL - <class 'TypeError'>: '<' not supported between instances of 'str' and 'float'

Len-B commented 2 years ago

I've just disabled SmartCut mode and it appears to have solved my issue. The media save was very speedy.

nedart commented 2 years ago

I've just disabled SmartCut mode and it appears to have solved my issue. The media save was very speedy.

In my use case the point of using this app is to cut frame accurately, so this isn't an option for me. It works fine when I do that as well though, but I would like to use this mode.

vgstef commented 2 years ago

Same here. I'd really like to have accuracy. Someone know how to fix this?

polarathene commented 2 years ago

Ran into same issue, GUI hanged at 0%, I tried to restore the vcp project file I saved prior but that also failed to restore the clip start/end that was to be cut, only loaded the reference video and required cutting again.

Enabled verbose logging and ran from terminal, got the following output:

2022-03-07 16:48 - vidcutter.libs.videoservice - INFO - /usr/bin/ffprobe -hide_banner -v error -show_packets -select_streams v -show_entries packet=pts_time,flags -of csv "/data/video/sample.mp4"
2022-03-07 16:48 - vidcutter.libs.videoservice - INFO - -v 32 -i "/data/video/sample.mp4" -ss 61.862 -t 0.0 -c:v libvpx-vp9 -deadline best -quality best -c:a copy -c:s copy -map 0:0 -map 0:1 -map 0:2 -avoid_negative_ts 1 -y "/tmp/vidcutter/a_00_start_00.mp4"
2022-03-07 16:48 - vidcutter.libs.videoservice - INFO - -v error -ss 65.933 -t 0.0 -i "/data/video/sample.mp4" -c copy -map 0:0 -map 0:1 -map 0:2 -avoid_negative_ts 1 -y "/tmp/vidcutter/a_00_middle_00.mp4"
2022-03-07 16:48 - vidcutter.libs.videoservice - INFO - -v 32 -i "/data/video/sample.mp4" -ss 65.933 -t 1.2179999999999893 -c:v libvpx-vp9 -deadline best -quality best -c:a copy -c:s copy -map 0:0 -map 0:1 -map 0:2 -avoid_negative_ts 1 -y "/tmp/vidcutter/a_00_end_00.mp4"
2022-03-07 16:49 - vidcutter.libs.videoservice - INFO - SmartCut progress: {'start': False, 'middle': False, 'end': False}
2022-03-07 16:49 - vidcutter.libs.videoservice - INFO - SmartCut resulted in zero length file, trying again without all stream mapping
2022-03-07 16:49 - vidcutter.libs.videoservice - INFO - SmartCut progress: {'start': False, 'middle': False, 'end': False}
2022-03-07 16:49 - vidcutter.libs.videoservice - INFO - SmartCut resulted in zero length file, trying again without all stream mapping
2022-03-07 16:49 - root - CRITICAL -   File "/usr/lib/python3.10/site-packages/vidcutter/libs/videoservice.py", line 406, in smartcheck
    self.smartcut_jobs[index].procs[name].started.disconnect()

2022-03-07 16:49 - root - CRITICAL - <class 'TypeError'>: disconnect() failed between 'started' and all its connections

This was on a new install of Manjaro with vidcutter package. The apps about section notes:

version: 6.05.1
libmpv: 109.1
FFmpeg: n5.0
PyQt: 5.15.6
Python: 3.10.2

Solution was like shared in this discussion, to disable SmartCut feature that I explicitly enabled as a first-time user thinking it would be useful.

Without SmartCut, a 5 sec clip extracted from a 5 minute MP4 (source: 1440p@60FPS BT.2020 HDR VP9) instantly. However with SmartCut, an ffmpeg process used heavy CPU and worked for a few minutes, a temporary clip of size 0 was at /tmp/vidcutter as the logs indicate, eventually the process finished but the GUI remained stalled at 0%, no file was output to the destination and the /tmp/vidcutter one remained at 0B size.


EDIT: Not sure if this is about frame accurate cutting.. while without SmartCut my MP4 source was cut as I'd like, a transcoded version (MKV HEVC) cut very differently.. Playback resulted in initial footage of the original clip from the start of about 2 seconds, not the clip starting timestamp, then switched to my clip starting time but roughly 5 seconds earlier, and then my 5 second clip for a total duration of 13 seconds..

Not sure what happened there, footage was transcoded via Handbrake and NVENC. The transcoding is fine, but VidCutter seems to have trouble processing it correctly.

Choupinounours commented 2 years ago

I think I also had this problem, and it want to keep using smartcut brecause i need precision...

For me, the solution was to avoid the clip to begin at the start of the media.

Simply setting the beginning of the clip at 00.00.00.080 was enough to solve the problem !

I lot 1 frame, but i don't mind this much...

polarathene commented 2 years ago

Simply setting the beginning of the clip at 00.00.00.080 was enough to solve the problem !

That won't be a reliable workaround as my clip was over a minute in to extract.

I think the problem was VFR (Variable Frame Rate), instead of a constant frame rate like 30 FPS, scenes that had little to no motion would be much less frames but as content actually changes faster more frames are introduced.

Some video players and editors don't handle that well apparently, so perhaps the precise cut expects the video frames to be constant?

ghost commented 2 years ago

I have the same issue. Smart cut mode only works sometimes for me. Could a workaround be to convert the source video file to a format, that always cuts frame accurate? I know that when you record mkv, you have a working video file, even if your recording program crashes. Is there a 'frame accurate' video format? I don't even know what a keyframe is in detail.