[FFmpeg-user] Force target DTS == source DTS -- How?
Andrew Randrianasulu
randrianasulu at gmail.com
Fri Jan 12 04:42:37 EET 2024
пт, 12 янв. 2024 г., 05:18 Mark Filipak <markfilipak.imdb at gmail.com>:
> On 1/10/24 16:50, Devin Heitmueller wrote:
> > On Wed, Jan 10, 2024 at 4:26 PM Mark Filipak <markfilipak.imdb at gmail.com>
> wrote:
> >> The change from 1048560 to 1174560 has to be happening inside the
> muxer, wouldn't you say? We now
> >> know that what's going into the muxer is right. Here is what went to
> the target file in the last run:
> >>
> >> 0, 1170806, 1174560, 3753, 640646, 0x900a1a7a, S=1, 1
> >
> > Try setting -muxdelay 0 on the output options. If not specified it
> > defaults to 0.7, and the delta between 1174560 and 1048560 is exactly
> > 1.4 seconds. I don't know why you're getting exactly 2x the mux delay
> > rather than just being off by 0.7s, but I suspect it's the muxdelay
> > that is causing you to get PTS values which are not what you would
> > expect.
> >
> > Devin
> >
>
> When I wrote "That did it", I 'spoke' too soon. I'm still being driven
> nuts.
> There are 4 questions at the end.
> -- Mark.
>
> set TRIM=-ss 20.061708333 -to 40.123416666
> set SOURCE=h:\BDMV\STREAM\00305.m2ts
> set CODE=-c copy -sn -dn
> set TARGET=c:\FANNY AND ALEXANDER [1982(1983)] 1of4.mp4
> ffmpeg -report %TRIM% -copyts -i %SOURCE% -map 0 %CODE% -muxdelay 0
> "%TARGET%"
> (The report is attached.)
>
> ___ THE INPUT M2TS (the cut is PTS=2854113)
> :
> 0, 2839098, 2839098, 3753, 25719, 0x6f77b9b6
> 1, 2839920, 2839920, 960, 1084, 0xe54d2b6f
> 1, 2840880, 2840880, 960, 1084, 0xe54d2b6f
> 1, 2841840, 2841840, 960, 1084, 0xe54d2b6f
> 1, 2842800, 2842800, 960, 1084, 0xe54d2b6f
> 0, 2842852, 2842852, 3753, 22455, 0xaa9655b8
> 1, 2843760, 2843760, 960, 1084, 0xe54d2b6f
> 1, 2844720, 2844720, 960, 1084, 0xe54d2b6f
> 1, 2845680, 2845680, 960, 1084, 0xe54d2b6f
> -cut- +---------+
> 0, 2846606, ¦ 2854113 ¦ 3753, 640646, 0x3a5a0c45
> 1, 2846640, +---------+ 960, 1084, 0xe54d2b6f
> 1, 2847600, 2847600, 960, 1084, 0xe54d2b6f
> 1, 2848560, 2848560, 960, 1084, 0xe54d2b6f
> 1, 2849520, +---------+ 960, 1084, 0xe54d2b6f
> 0, 2850360, ¦ 2850360 ¦ 3753, 640646, 0xfed1d09a <= TO BE CUT
> 1, 2850480, +---------+ 960, 1084, 0xe54d2b6f
> 1, 2851440, 2851440, 960, 1084, 0xe54d2b6f
> 1, 2852400, 2852400, 960, 1084, 0xe54d2b6f
> 1, 2853360, 2853360, 960, 1084, 0xe54d2b6f
> 0, 2854113, 2861621, 3753, 640646, 0x02208727
> :
>
> ___ THE OUTPUT MP4 (the cut is PTS=2854080)
> 1, 1492608, 1492608, 512, 60, 0xec16103f
> : 50 audio packets, total
> 1, 1517696, 1517696, 512, 1084, 0xe54d2b6f
> -cut- +---------+
> 0, 2846573, ¦ 2854080 ¦ 3753, 640654, 0xb9811068
> 1, 1518208, +---------+ 512, 1084, 0xe54d2b6f
> 1, 1518720, 1518720, 512, 1084, 0xe54d2b6f
> 1, 1519232, 1519232, 512, 1084, 0xe54d2b6f
> 1, 1519744, +---------+ 512, 1084, 0xe54d2b6f
> 0, 2850327, ¦ 2850327 ¦ 3753, 640652, 0xbf9ad2d1 <= NOT CUT
> 1, 1520256, +---------+ 512, 1084, 0xe54d2b6f
> 1, 1520768, 1520768, 512, 1084, 0xe54d2b6f
> 1, 1521280, 1521280, 512, 1084, 0xe54d2b6f
> 1, 1521792, 1521792, 512, 1084, 0xe54d2b6f
> 0, 2854080, 2861588, 3753, 640652, 0x8f98895e
> :
>
> Q1: How can I force the mp4 muxer to use the existing PTSs?
> Q2: Why are there 50 audio packets ahead of the -cut-?
> Q3: How can I force the mp4 audio time_base to 1/90000?
>
https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/HEAD:/libavformat/movenc.c
(oh, it grow to 300 kb?) there are options
"movie_timescale", "set movie timescale"
and
video_track_timescale", "set timescale of all video tracks"
AND
"pts", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = MOV_PRFT_SRC_PTS}, 0, 0,
AV_OPT_FLAG_ENCODING_PARAM, "prft"},
but you probably need to consult documentation on how exactly they used
https://ffmpeg.org/ffmpeg-formats.html#Options-4
but if you have some time it will be interesting to hear if script I found
on videohelp forums for testing open-gop/closed gop situations shows
something interesting for your source file?
Somewhere at second level someone said that blurays specifically not
mandate closed-gop video streams, and only demand full decoder refres (IDR
frame) at chapter marks.
I wonder if your m2ts stream encoded like this ?
How exactly you determinated keyframe to cut at, initially?
Q4: Why wasn't INPUT PTS=2850360 cut off?
> _______________________________________________
> 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