Replies: 2 comments 3 replies
-
Hi and thanks for your research
Isn't this a lossy operation that will re-encode the whole video? |
Beta Was this translation helpful? Give feedback.
-
Sure. I think I should explain a bit how I came to this frame cut idea. Keyframe cut is just perfect when I wanna cut non adjacent segments. One idea would be cut the segments as it is yes and use the first cmd that I proposed to remove the last or the 2 last frames of the seg1 (which would be also lossless). The only thing is that I am not sure if it is always 1 or 2 frames that are duplicated or even more maybe. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I just wrote a small lua script to used in mpv player to be able to cut at the exact time cursor.
After a lot of different test I am happy with the result based on frame cut.
Seems to be exact cut frame, the audio seems fine and no duplicates frames.
What is your point of view about it and what do you think of a new cut function based on frames ?
I have however no idea of the reproducibility of this with other extension and codec (using mp4 and h264).
The idea is as follow:
ffprobe -v error -select_streams v:0 -show_entries stream=r_frame_rate -print_format default=nokey=1:noprint_wrappers=1 input.mp4
ffprobe -v error -select_streams v:0 -count_frames -show_entries stream=nb_read_frames -print_format default=nokey=1:noprint_wrappers=1 input.mp4
ffprobe -v error -select_streams a:0 -count_frames -show_entries stream=nb_read_frames -print_format default=nokey=1:noprint_wrappers=1 input.mp4
ffmpeg -i input.mp4 -frames:v cvf1 -c:v copy -c:a copy output_seg1.mp4
ffmpeg -i input.mp4 -vf select="between(n\, cf2 \, vf ),setpts=PTS-STARTPTS" -af aselect="between(n\, caf2 \, af ),asetpts=PTS-STARTPTS" output_seg2.mp4
Practical example is here :
input.mp4:
Lua script is available here
Beta Was this translation helpful? Give feedback.
All reactions