[FFmpeg-trac] #9904(undetermined:new): Differences in trimming mp 4 and mkv

FFmpeg trac at avcodec.org
Mon Sep 5 10:00:08 EEST 2022


#9904: Differences in trimming mp 4 and mkv
-------------------------------------+-------------------------------------
             Reporter:  Jozef        |                     Type:  defect
  Chutka                             |
               Status:  new          |                 Priority:  normal
            Component:               |                  Version:
  undetermined                       |  unspecified
             Keywords:               |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 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 at 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 at 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?
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/9904>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list