#9904 closed defect (invalid)

Differences in trimming mp 4 and mkv

Reported by: Jozef Chutka Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Jozef Chutka Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Using ffmpeg version 2022-08-31-git-319e8a49b5-full_build-www.gyan.dev

I have noticed there are differences in cutting videos outside its keyframe and its later use.

Generating sources .mkv and .mp4 sources which contain frame counter (30fps, keyint=300):

ffmpeg -filter_complex "smptehdbars=size=400x200:rate=30,drawtext=fontfile=c\\:/Windows/Fonts/arial.ttf:timecode=00\\:00\\:00.00:rate=30:fontsize=72:fontcolor=white:x=(w-tw)/2:y=10*h/100:box=1:boxcolor=0x00000000@1;sine=frequency=440:sample_rate=48000:beep_factor=2" -t 60 -c:v libx264 -x264-params keyint=300 -c:a aac -y source.mp4

ffmpeg -filter_complex "smptehdbars=size=400x200:rate=30,drawtext=fontfile=c\\:/Windows/Fonts/arial.ttf:timecode=00\\:00\\:00.00:rate=30:fontsize=72:fontcolor=white:x=(w-tw)/2:y=10*h/100:box=1:boxcolor=0x00000000@1;sine=frequency=440:sample_rate=48000:beep_factor=2" -t 60 -c:v libx264 -x264-params keyint=300 -c:a aac -y source.mkv

Fast cutting at 15s using -ss before -i (keyframes on 10s, 20s etc.):

ffmpeg -ss 15 -i source.mp4 -t 10 -c:0 copy -y trim.mp4
ffmpeg -ss 15 -i source.mkv -t 10 -c:0 copy -y trim.mkv

Notice, both trim.mp4 and trim.mkv renders 10s in video on the first frame as expected. (sadly mp4 renders few following frames broken)

Finally, using these intermediates:

ffmpeg -f lavfi -i nullsrc=400x200:20:4 -filter_complex movie=trim.mp4[v];[0][v]overlay -y trim-out.mp4
ffmpeg -f lavfi -i nullsrc=400x200:20:4 -filter_complex movie=trim.mkv[v];[0][v]overlay -y trim-out.mkv

trim-out.m4 renders, surprisingly 15s in counter in the first frame, while trim-out.mkv renders 10s in video in its first frame.

I am not sure which behavior is expected, but wondering if this difference can/should be fixed?

Change History (1)

comment:1 by Elon Musk, 20 months ago

Resolution: invalid
Status: newclosed

There is nothing to fix, behavior is correct, containers are different.
Use intra only video coding if seeking is important.

Note: See TracTickets for help on using tickets.