mifi / lossless-cut

The swiss army knife of lossless video/audio editing
https://losslesscut.app/
GNU General Public License v2.0
26.72k stars 1.28k forks source link

Setting the start of a segment does not remove video prior to segment start #1568

Closed RodBarnes closed 1 year ago

RodBarnes commented 1 year ago

I have a lot of issues to go through, so in order to make it easier for me to help you, I ask that you please try these things first

Operating System

Windows 11

Steps to reproduce

  1. Add video to LossLessCut.
  2. Move segment start to some point beyond the beginning.
  3. Click [Export].

Expected behavior

Having set the segment start at some point after the beginning of the original video, it should output ONLY the segment.

Actual behavior

It outputs the video INCLUDING the section BEFORE the segment start.

Share log

No response

RodBarnes commented 1 year ago

This link is to a video that demonstrates this issue. It appears to happen on all of them but this is one example. LINK

mifi commented 1 year ago

Works for me. I tried cutting from 13:00 and it does cut. Maybe you're using "chapters only" export mode? if not, please include a report from the help menu

RodBarnes commented 1 year ago

[NOTE: I do think this is a great idea and I've been wanting something like this for a long time. I have plenty of video production tools that allow me to produce videos but something as simple as trimming parts still required producing the video all over. This tool should let me do what I often want to do -- just trim in place. So, I previously donated to you. Good work!]

But, now to the issue... It still happens for me -- and I may be doing something wrong. The exported video continues to include the video before the start-segment mark. I recorded the process and the video is here.

I do not find an option for "chapters only"?

I used "Report an Error" and have included that output.

No error occurred.

{
  "state": {
    "ffmpegExperimental": false,
    "preserveMovData": false,
    "movFastStart": true,
    "preserveMetadataOnMerge": false,
    "filePath": "C:\\Users\\rodba\\Downloads\\Process.mp4",
    "fileFormat": "mp4",
    "externalFilesMeta": {},
    "mainStreams": [
      {
        "index": 0,
        "codec_name": "h264",
        "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
        "profile": "High",
        "codec_type": "video",
        "codec_tag_string": "avc1",
        "codec_tag": "0x31637661",
        "width": 2560,
        "height": 1440,
        "coded_width": 2560,
        "coded_height": 1440,
        "closed_captions": 0,
        "film_grain": 0,
        "has_b_frames": 0,
        "sample_aspect_ratio": "1:1",
        "display_aspect_ratio": "16:9",
        "pix_fmt": "yuv420p",
        "level": 50,
        "color_range": "tv",
        "color_space": "gbr",
        "color_transfer": "reserved",
        "color_primaries": "reserved",
        "chroma_location": "left",
        "field_order": "progressive",
        "refs": 1,
        "is_avc": "true",
        "nal_length_size": "4",
        "id": "0x1",
        "r_frame_rate": "143/6",
        "avg_frame_rate": "67200000/2823757",
        "time_base": "1/1000000",
        "start_pts": 0,
        "start_time": "0.000000",
        "duration_ts": 84712710,
        "duration": "84.712710",
        "bit_rate": "3105206",
        "bits_per_raw_sample": "8",
        "nb_frames": "2016",
        "extradata_size": 110,
        "disposition": {
          "default": 1,
          "dub": 0,
          "original": 0,
          "comment": 0,
          "lyrics": 0,
          "karaoke": 0,
          "forced": 0,
          "hearing_impaired": 0,
          "visual_impaired": 0,
          "clean_effects": 0,
          "attached_pic": 0,
          "timed_thumbnails": 0,
          "captions": 0,
          "descriptions": 0,
          "metadata": 0,
          "dependent": 0,
          "still_image": 0
        },
        "tags": {
          "language": "und",
          "handler_name": "VideoHandler",
          "vendor_id": "[0][0][0][0]"
        }
      },
      {
        "index": 1,
        "codec_name": "aac",
        "codec_long_name": "AAC (Advanced Audio Coding)",
        "profile": "LC",
        "codec_type": "audio",
        "codec_tag_string": "mp4a",
        "codec_tag": "0x6134706d",
        "sample_fmt": "fltp",
        "sample_rate": "48000",
        "channels": 2,
        "channel_layout": "stereo",
        "bits_per_sample": 0,
        "id": "0x2",
        "r_frame_rate": "0/0",
        "avg_frame_rate": "0/0",
        "time_base": "1/48000",
        "start_pts": 0,
        "start_time": "0.000000",
        "duration_ts": 4066304,
        "duration": "84.714667",
        "bit_rate": "115690",
        "nb_frames": "3973",
        "extradata_size": 2,
        "disposition": {
          "default": 1,
          "dub": 0,
          "original": 0,
          "comment": 0,
          "lyrics": 0,
          "karaoke": 0,
          "forced": 0,
          "hearing_impaired": 0,
          "visual_impaired": 0,
          "clean_effects": 0,
          "attached_pic": 0,
          "timed_thumbnails": 0,
          "captions": 0,
          "descriptions": 0,
          "metadata": 0,
          "dependent": 0,
          "still_image": 0
        },
        "tags": {
          "language": "und",
          "handler_name": "SoundHandler",
          "vendor_id": "[0][0][0][0]"
        }
      }
    ],
    "copyStreamIdsByFile": {
      "C:\\Users\\rodba\\Downloads\\Process.mp4": {
        "0": true,
        "1": true
      }
    },
    "cutSegments": [
      {
        "start": 4.900162110784314
      }
    ],
    "mainFileFormatData": {
      "filename": "C:\\Users\\rodba\\Downloads\\Process.mp4",
      "nb_streams": 2,
      "nb_programs": 0,
      "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
      "format_long_name": "QuickTime / MOV",
      "start_time": "0.000000",
      "duration": "84.715000",
      "size": "34167195",
      "bit_rate": "3226554",
      "probe_score": 100,
      "tags": {
        "major_brand": "isom",
        "minor_version": "512",
        "compatible_brands": "isomiso2avc1mp41",
        "encoder": "Lavf59.3.100"
      }
    },
    "rotation": 360,
    "shortestFlag": false,
    "effectiveExportMode": "separate",
    "outSegTemplate": "${FILENAME}-${CUT_FROM}-${CUT_TO}${SEG_SUFFIX}${EXT}"
  },
  "platform": "win32",
  "version": "3.54.0"
}
mifi commented 1 year ago

thanks for sharing screen recording.

have you seen this? https://github.com/mifi/lossless-cut/blob/master/issues.md#cutting-times-are-not-accurate

The problem is that you're cutting probably right before a keyframe. it's not possible to cut before keyframes so losslesscut will instead round to the nearest previous keyframe, which is the beginning of the video. try to cut a bit after the keyframe instead.