[FFmpeg-user] cutting mp4 with ffmpeg

DEF shaker.doc at gmail.com
Sat Jan 13 20:22:05 EET 2024


On Sat, 13 Jan 2024 at 19:09, Andrew Randrianasulu
<randrianasulu at gmail.com> wrote:
>

>
> also
>
> /dev/shm/ffmpeg/ffmpeg -i /dev/shm/6029_cut_2.mp4 -vf showinfo -f null
> /dev/null
>
> last lines were
>
> [Parsed_showinfo_0 @ 0xee202580] n:1612 pts:5803200 pts_time:64.48
> duration:      0 duration_time:0       fmt:yuv420p cl:left sar:0/1
> s:720x400 i:P iskey:0 type:B checksum:498D7D18
> plane_checksum:[7C011A9A 72D078F0 1749E97F] mean:[84 158 80]
> stdev:[10.1 3.4 8.2]
> [Parsed_showinfo_0 @ 0xee202580] color_range:tv color_space:smpte170m
> color_primaries:smpte170m color_trc:bt709
> [Parsed_showinfo_0 @ 0xee202580] n:1613 pts:5806800 pts_time:64.52
> duration:      0 duration_time:0       fmt:yuv420p cl:left sar:0/1
> s:720x400 i:P iskey:0 type:B checksum:FB6C528A
> plane_checksum:[BC0C2674 7A2A71F8 E2E7BA0F] mean:[84 158 80]
> stdev:[10.1 3.3 8.1]
> [Parsed_showinfo_0 @ 0xee202580] color_range:tv color_space:smpte170m
> color_primaries:smpte170m color_trc:bt709
> [Parsed_showinfo_0 @ 0xee202580] n:1614 pts:5810400 pts_time:64.56
> duration:      0 duration_time:0       fmt:yuv420p cl:left sar:0/1
> s:720x400 i:P iskey:0 type:P checksum:32E560F5
> plane_checksum:[237A0A01 F76B8D20 1D72C9C5] mean:[84 158 80]
> stdev:[10.1 3.2 8.0]
> [Parsed_showinfo_0 @ 0xee202580] color_range:tv color_space:smpte170m
> color_primaries:smpte170m color_trc:bt709
> [Parsed_showinfo_0 @ 0xee202580] n:1615 pts:5814000 pts_time:64.6
> duration:      0 duration_time:0       fmt:yuv420p cl:left sar:0/1
> s:720x400 i:P iskey:1 type:I checksum:C9E56CD5
> plane_checksum:[1254795B 75287B1F 720B784C] mean:[83 158 80]
> stdev:[10.1 3.0 7.8]
> [Parsed_showinfo_0 @ 0xee202580] color_range:tv color_space:smpte170m
> color_primaries:smpte170m color_trc:bt709
> [Parsed_showinfo_0 @ 0xee202580] n:1616 pts:5828400 pts_time:64.76
> duration:      0 duration_time:0       fmt:yuv420p cl:left sar:0/1
> s:720x400 i:P iskey:0 type:P checksum:07418607
> plane_checksum:[A672B48D A7D7BD5B 3D4D1410] mean:[83 158 79]
> stdev:[9.7 2.3 7.0]
> [Parsed_showinfo_0 @ 0xee202580] color_range:tv color_space:smpte170m
> color_primaries:smpte170m color_trc:bt709
> [out#0/null @ 0xbf59800] video:543kB audio:12112kB subtitle:0kB other
> streams:0kB global headers:0kB muxing overhead: unknown
> frame= 1617 fps=493 q=-0.0 Lsize=N/A time=00:01:04.61 bitrate=N/A speed=19.7x
>
>
> doesn't this mean ffmpeg cut one frame too much ?

Yes it will and it could.
As long as you are not encoding the video, ffmpeg will cut at the
nearest iframes.
If you are particular then you need to re-encode the video.

/dev/shm/ffmpeg/ffmpeg -i ~/6029.mp4   -c:v libx264 -c:a pcm_s16le
-t 64.600 /dev/shm/6029_cut_2.mp4

avoid using "-to" in the place of "-t" like i explained.

if you must not reencode and you want to use copyts then you must add
the option
"-avoid_negative_ts make_zero"  after your copyts.

DEF


More information about the ffmpeg-user mailing list