0

Two different videos are giving me troubles when coming up with code to cut them at a given time, because the same code does not clip the videos in the same way when processed through the same ffmpeg command

With the first video, if I specify a -to of 10, it'll cut at one frame before.

With the second video, if I specify a -to of 10, it'll cut on that frame.

From reading a comment here, one person says "seeking is not always performed on dts, it actually depends on the container. If the container timestamps are pts, seeking is in pts; if container timestamps are dts, seeking is in dts."

What can I do to determine how my cuts will operate beforehand?

Ideally, I'd like to be able to find the information in the output of a ffprobe command, and then adjust my logic accordingly

video 1

ffprobe -hide_banner steamedHams.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'steamedHams.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2018-02-17T02:19:35.000000Z
  Duration: 00:02:43.10, start: 0.000000, bitrate: 190 kb/s
    Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 116 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 72 kb/s (default)
    Metadata:
      creation_time   : 2018-02-17T02:19:35.000000Z
      handler_name    : IsoMedia File Produced by Google, 5-11-2011

video 2

ffprobe -hide_banner trailer.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'trailer.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 2018-03-14T22:10:26.000000Z
    encoder         : HandBrake 1.0.7 2017040900
  Duration: 00:00:33.02, start: 0.000000, bitrate: 2778 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt470bg/bt709), 1920x1080 [SAR 1:1 DAR 16:9], 2653 kb/s, 25 fps, 25 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      creation_time   : 2018-03-14T22:10:26.000000Z
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 159 kb/s (default)
    Metadata:
      creation_time   : 2018-03-14T22:10:26.000000Z
      handler_name    : Stereo

1 Answers1

0

Sure, you can use ffprobe to inspect the frames and packets:

ffprobe -select_streams v -show_packets \
-show_entries packet=pts_time,dts_time -of compact=p=0 input.mp4

This will show PTS and DTS of every packet.

The following post may help you identify the closest keyframe before a given timestamp.

slhck
  • 235,242