[FFmpeg-user] cutting mp4 with ffmpeg

Andrew Randrianasulu randrianasulu at gmail.com
Sun Jan 14 10:25:09 EET 2024


On Sun, Jan 14, 2024 at 8:24 AM Mark Filipak <markfilipak.imdb at gmail.com> wrote:
>
> This is not the way to do things, Andrew.
>
> Please do not add your notice of a trac ticket submission to my reply. It has nothing to do with my
> reply.
>
> Your ticket has justifiably been closed.
>
> Trac is not a place to get extra help. It is for bug reporting. Instead to a trac ticket, post your
> concerns here and try to gain help/confirmation/clarification here.

well, at least it was closed with explanation:

============

There is a limitation with time value displays in showinfo but this is
not it. showinfo uses a field width of 7 characters, so it can and
does display e.g. 2.96667. When there are fewer characters shown, it
means the remaining digits are 0 i.e. pts_time:1 indicates 1.00000.

As for ffprobe, using the bare command will just show the input dump
(same as ffmpeg) which is meant to be a summary display. For
precision, you should use the sectional display. For input container
duration, you would use

ffprobe -show_entries format=duration -i INPUT which will print with
microsecond precision, e.g.

[FORMAT]
duration=179.468005
[/FORMAT]

======

this is valuable information

>
> --Mark.
>
> On 13/01/2024 22.11, Andrew Randrianasulu wrote:
> > On Sat, Jan 13, 2024 at 10:27 PM Mark Filipak
> > <markfilipak.imdb at gmail.com> wrote:
> >>
> >> On 13/01/2024 12.50, Andrew Randrianasulu wrote:
> >>> On Sat, Jan 13, 2024 at 8:57 PM Def Etienne <shaker.doc at gmail.com> wrote:
> >> -snip-
> >>>> ffmpeg -i ~/6029.mp4  -copyts  c:v copy -c:acopy -t 64.600 dev/shm/6029_cut.mp4
> >>
> >> According to Devon Heitmueller -- thanks again, Devon -- '-copyts' and '-muxdelay 0' are _both_ needed.
> >>
> >> '-copyts' -- before the input -- bypasses a routine that apparently is named "tsfixup".
> >>
> >> '-muxdelay 0' -- after the input -- bypasses another ts fixup that defaults to adding 0.7 seconds to
> >> the timestamps.
> >>
> >> Exactly why ffmpeg does those fixups is a mystery.
> >>
> >> I can confirm that when cutting off the beginning:
> >> ffmpeg -copyts -ss ... -i ... -c copy -muxdelay 0 ...
> >> works. It preserves the timestamps (DTS, PTS).
> >>
> >>
> >> Regarding cutting off the ending:
> >> ffmpeg -to ... -i ... -c copy ...
> >> I am trying to determine the behavior of '-to'. Is it PTS? Or is it ticks (i.e., duration in
> >> timebase units)? And does ffmpeg do fixups for '-to' clauses, also? It appears there are such '-to'
> >> fixups.
> >>
> >>
> >> Also be aware that MPV rounds time, and rounds to milliseconds whereas ffmpeg truncates time and
> >> truncates frame numbers, DTSs, and PTSs. So times from MPV may miss an I-frame in ffmpeg. What I do
> >> is use MPV times to find approximate frame number. Then I use '-vf showinfo' to find exact frame
> >> number. Then I compute exact DTS and exact PTS from exact frame number. Then I convert DTS and PTS
> >> to nanoseconds in the '-ss' clause.
> >
> > I added ticket about ffprobe/vf_showinfo displaying truncated duration:
> >
> > https://trac.ffmpeg.org/ticket/10799#ticket
> >
> >
> >>
> >> Why does 'ffmpeg -ss' use times instead of relative timebase ticks (i.e. durations) or absolute DTSs
> >> and PTSs? Your guess is as good as mine, but it is a super PITA.
> >>
> >> Why does ffmpeg apply ts fixups? Your guess is as good as mine, but it is a super PITA.
> >>
> >>
> >> Also, be aware that in this listing:
> >>
> >>> [Parsed_showinfo_0 @ 0xee202580] n:1612 pts:5803200 ...
> >>
> >> the reported PTS is _not_ PTS. It is ticks (i.e., duration in timebase units) that is marked "pts"
> >> but isn't -- another super PITA.
> >>
> >>
> >> Also, remuxing from M2TS to MP4 for example, applies more unknown fixups even when they have the
> >> exact same timebase -- another super PITA -- so don't change packet type until the very end of your
> >> timming and concatenating.
> >>
> >> --Mark.
>
>
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-user mailing list