Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Channels DVR EDL "Merge cuts" not creating chapters from merged segments in Plex #1223

Closed
petebocken opened this issue Jul 12, 2022 · 16 comments

Comments

@petebocken
Copy link

Describe the bug
I am recording shows with Channels DVR and have it generating an EDL file. LossLessCut's exported file when played in Plex does not contain chapter markers when using the LossLessCut "merge cuts" and "create chapters from merged segments".

To Reproduce
Steps to reproduce the behavior:

  1. Record show with Channels DVR and enable EDL file creation.
  2. Load recorded video file and EDL file into LossLessCut
  3. Enabled "yingyang" button to "discard selected segments".
  4. Select matroska file format (however this appears to not matter which is selected)
  5. Select Merge cuts
  6. Click Export + Merge button
  7. Under Advanced Options, set "Create chapters from merged segments" to Yes.
  8. Click Export+merge button
  9. Load exported video file in Plex
  10. Chapter markers do not exist.

Expected behavior
Chapters markers for exported video file should be present in Plex.

Other testing
Testing a video file recorded from HDHomeRun DVR and MCEBuddy generated EDL file run through the same LossLessCut settings results in Plex chapter markers as expected. The MCEBuddy EDL file uses type "0"(cut) and Channels DVR uses type "3"(commercial break). I did try changing the Channels DVR EDL file to "0" but that did not make a difference.

Desktop (please complete the following information):

  • Windows 10 Pro
  • Plex Media Server 1.27.2.5929
  • Plex Web 4.85.1
  • LossLessCut 3.45.0

Example files:
I can provide the before and after export video file and EDL file if needed.

Problem report:

No error

{
  "state": {
    "filePath": "C:\\Users\\peter\\Downloads\\Justice for All With Judge Cristina Pérez 2012-09-17 2022-07-10-0929.mpg",
    "fileFormat": "matroska",
    "mainStreams": [
      {
        "index": 0,
        "codec_name": "mpeg2video",
        "codec_long_name": "MPEG-2 video",
        "profile": "Main",
        "codec_type": "video",
        "codec_tag_string": "[2][0][0][0]",
        "codec_tag": "0x0002",
        "width": 704,
        "height": 480,
        "coded_width": 0,
        "coded_height": 0,
        "closed_captions": 0,
        "has_b_frames": 1,
        "sample_aspect_ratio": "40:33",
        "display_aspect_ratio": "16:9",
        "pix_fmt": "yuv420p",
        "level": 8,
        "color_range": "tv",
        "chroma_location": "left",
        "field_order": "tt",
        "refs": 1,
        "id": "0x61",
        "r_frame_rate": "30000/1001",
        "avg_frame_rate": "30000/1001",
        "time_base": "1/90000",
        "start_pts": 1597102810,
        "start_time": "17745.586778",
        "duration_ts": 167357190,
        "duration": "1859.524333",
        "disposition": {
          "default": 0,
          "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
        },
        "side_data_list": [
          {
            "side_data_type": "CPB properties"
          }
        ]
      },
      {
        "index": 1,
        "codec_name": "ac3",
        "codec_long_name": "ATSC A/52A (AC-3)",
        "codec_type": "audio",
        "codec_tag_string": "AC-3",
        "codec_tag": "0x332d4341",
        "sample_fmt": "fltp",
        "sample_rate": "48000",
        "channels": 2,
        "channel_layout": "stereo",
        "bits_per_sample": 0,
        "dmix_mode": "-1",
        "ltrt_cmixlev": "-1.000000",
        "ltrt_surmixlev": "-1.000000",
        "loro_cmixlev": "-1.000000",
        "loro_surmixlev": "-1.000000",
        "id": "0x64",
        "r_frame_rate": "0/0",
        "avg_frame_rate": "0/0",
        "time_base": "1/90000",
        "start_pts": 1597042894,
        "start_time": "17744.921044",
        "duration_ts": 167359680,
        "duration": "1859.552000",
        "bit_rate": "192000",
        "disposition": {
          "default": 0,
          "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
        },
        "tags": {
          "language": "eng"
        }
      }
    ],
    "copyStreamIdsByFile": {
      "C:\\Users\\peter\\Downloads\\Justice for All With Judge Cristina Pérez 2012-09-17 2022-07-10-0929.mpg": {
        "0": true,
        "1": true
      }
    },
    "cutSegments": [
      {
        "start": 348.92,
        "end": 472.17
      },
      {
        "start": 1124.8600000000001,
        "end": 1248.08
      }
    ],
    "mainFileFormatData": {
      "filename": "C:\\Users\\peter\\Downloads\\Justice for All With Judge Cristina Pérez 2012-09-17 2022-07-10-0929.mpg",
      "nb_streams": 2,
      "nb_programs": 1,
      "format_name": "mpegts",
      "format_long_name": "MPEG-TS (MPEG-2 Transport Stream)",
      "start_time": "17744.921044",
      "duration": "1860.190067",
      "size": "572160928",
      "bit_rate": "2460655",
      "probe_score": 50
    },
    "rotation": 360,
    "shortestFlag": false,
    "effectiveExportMode": "merge"
  },
  "platform": "win32",
  "version": "3.45.0"
}
@mifi
Copy link
Owner

mifi commented Jul 16, 2022

hi. on the top of my head i think yin yang doesn't work with chapters. disable that and try to instead use the tools -> segments -> invert

@petebocken
Copy link
Author

It's still not doing what I'm expecting or wanting it to do.

Here is what I'm looking for:

  • Generate a single container file (mkv or mp4).
  • File contains chapters of only the segments from the EDL file.
  • These segment cut points(chapters) are the beginning of the show after the commercial breaks.
  • The commercial breaks are maintained in the final file. So if I was to watch the video in Plex straight through, it would contain the entire broadcast including the show and commercials.
  • The result is that I can watch the show and when a commercial starts, I can select the next chapter and it will skip past the commercials each time.

I've only been able to achieve the following with Losslesscut:

  • "Merge cuts" with chapters: results in a file with the commercials cut out and chapters for when the program returns from the commercial breaks. Good, but I want to keep the commercials intact in the video file.
  • "Chapters Only": results in chapters of each time the show returns from a commercial break (perfect!), however chapters are also created for each commercial break, even though these are not displayed in the segments sidebar, so not sure why chapters are being created.

@mifi
Copy link
Owner

mifi commented Jul 17, 2022

I think mp4 chapters cannot have gaps, or am I wrong?

@petebocken
Copy link
Author

I think mp4 chapters cannot have gaps, or am I wrong?

Well, here is the EDL created from Channels DVR recorded as mpeg file.

0 39.64  3
507.40000000000003	717.65  3
1101.63	1236.83  3
1549.28	1759.42	 3
1841.67	1859.75	 3

I am trying to attempt to use Losslesscut as a replacement for MCEBuddy. The only difference (I believe) between the EDL generated from MCEBuddy and Channels DVR is 0 is used instead of 3, which I'm not sure matters? I tried manually changing the 3's to 0's with LLC and it made no difference.

The video files created with HDHomeRun and Channels DVR are both mpg file extension.

When I run the HDHomeRun file through MCEBuddy (which is using comskip), it creates an EDL and a mp4 file with chapters. Chapter 1 is the start of the video and ends after the first commercial break. Chapter 2 starts when the first commercial break ends, and so forth. So when the first commercial break starts, you can select chapter 2 and skip past the first commercial break.

Does this make sense? Obviously I am comparing a difference software to yours, but I just want to make sure that I am not missing a way to do this.

@mifi
Copy link
Owner

mifi commented Jul 17, 2022

is it possible to share an mp4 or mkv file that has these kinds of chapters with (desired) gaps in it?

@petebocken
Copy link
Author

is it possible to share an mp4 or mkv file that has these kinds of chapters with (desired) gaps in it?

Here is an example mp4 and EDL generated by MCEBuddy.

https://drive.google.com/file/d/1b3Jn6hlPs_-VZfcFfwrHWxCzktjcq3-2/view?usp=sharing

Load this into Plex and view how the chapters are setup with the commercial breaks.

@mifi
Copy link
Owner

mifi commented Jul 17, 2022

thanks. i ran ffprobe:

ffprobe file.mp4  -show_chapters -of json
{
    "chapters": [
        {
            "id": 0,
            "time_base": "1/1000",
            "start": 0,
            "start_time": "0.000000",
            "end": 34020,
            "end_time": "34.020000",
            "tags": {
                "title": ""
            }
        },
        {
            "id": 1,
            "time_base": "1/1000",
            "start": 34020,
            "start_time": "34.020000",
            "end": 408520,
            "end_time": "408.520000",
            "tags": {
                "title": "Chapter 1"
            }
        },
        {
            "id": 2,
            "time_base": "1/1000",
            "start": 408520,
            "start_time": "408.520000",
            "end": 937070,
            "end_time": "937.070000",
            "tags": {
                "title": "Chapter 2"
            }
        },
        {
            "id": 3,
            "time_base": "1/1000",
            "start": 937070,
            "start_time": "937.070000",
            "end": 1386420,
            "end_time": "1386.420000",
            "tags": {
                "title": "Chapter 3"
            }
        },
        {
            "id": 4,
            "time_base": "1/1000",
            "start": 1386420,
            "start_time": "1386.420000",
            "end": 1858970,
            "end_time": "1858.970000",
            "tags": {
                "title": "Chapter 4"
            }
        },
        {
            "id": 5,
            "time_base": "1/1000",
            "start": 1858970,
            "start_time": "1858.970000",
            "end": 1859930,
            "end_time": "1859.930000",
            "tags": {
                "title": "Chapter 5"
            }
        }
    ]
}

as far as I can see, your file contains no gaps, as every chapter is a continuation of the previous chapter (and commercials are also chapters). I don't know if there is something wrong with ffprobe, or am I misunderstanding something. Does Plex not show the commercials as chapters? If so, I wonder how it can distinguish between commercial chapters and non-commercial chapters

@petebocken
Copy link
Author

petebocken commented Jul 17, 2022

Here is what Plex shows as the chapters for that file.

Screen Shot 2022-07-17 at 14 43 28

It actually shows two "Chapter 1". The first Chapter 1 consists of the first 30 seconds that is recorded ahead of the recording time (set by HDHomeRun). The second Chapter 1 is the start of the program. That Chapter 1 then ends at the end of the first commercial break. So then Chapter 2 starts after the first commercial break ends and the program returns. There are 6 total chapters. Individual commercial breaks do not get their own chapters.

Obviously I could manually adjust segments in LLC to accomplish this, but I am looking to automate this later with the CLI and a shell script.

@mifi
Copy link
Owner

mifi commented Jul 17, 2022

Ok, so it seems like plex works the same as llc if I understand correctly. As far as I can see from your plex screenshot, it looks identical to what my ffprobe command above returned (and what losslesscut shows). There are also 6 chapters. If I export your file with "Chapters only", and then open the exported file again in losslesscut, it looks identical. So I'm not sure exactly what you need

@petebocken
Copy link
Author

Right, this file was recorded with HDHomeRun and EDL created with MCEBuddy. This setup when run through LLC appears to work as expected.

Now try this file recorded with Channels DVR with EDL creation option enabled (zip contains original recording, EDL, and exported LLC file with inverted timeline segments, "Chapters Only", MKV ):
https://drive.google.com/file/d/13CPDJZntFbNLkED7jKlHqNd-42jXl8qQ/view?usp=sharing

LLC shows 5 segments will be created:
Screen Shot 2022-07-17 at 15 10 20

However, when played in Plex, 10 chapters are shown which includes a chapter for each commercial break.
Screen Shot 2022-07-17 at 15 05 26
Screen Shot 2022-07-17 at 15 05 33

@mifi
Copy link
Owner

mifi commented Jul 17, 2022

Ok, now I see. The reason is that losslesscut auto-creates chapters for the gaps. If this is not done, ffmpeg (which losslesscut uses), will create incorrect chapters. I just tested with your file (by disabling autocreation of chapters for gaps in the code), and the first chapter will start from 0 and the second chapter is missing. So that's the reason.

If you manually expand the segments to fill the gaps, it should work. We could introduce a function for auto-expanding all segments to fill the gaps until the next segment

@petebocken
Copy link
Author

How would I manually expand the segments to fill the gaps?

@mifi
Copy link
Owner

mifi commented Jul 17, 2022

in the segment list, double click on the last segment. then single click on the segment before. then press o

@petebocken
Copy link
Author

This appears to work. If you setup a function for auto-expanding, would that be accessible via the CLI as well?

Overall, if I want to script this. Would I use the CLI or the FFMPEG command? The "Last ffmpeg commands" don't appear to include the EDL filepath, so I'm assuming that won't work. Some initial searching shows that maybe you can include all the cuts in a single command or possible multiple.

Or can I just use the CLI to accomplish this easier? The CLI section on the readme just says "arguments", do you have more documentation on what those arguments are and how to use the CLI?

@mifi
Copy link
Owner

mifi commented Jul 17, 2022

you can't really automate/script much with losslesscut, as it was never designed for that. There is a feature request to add more automation in losslesscut, but i'm not sure if I want to go that way: #980

I think I would just use the ffmpeg CLI if I were you.

As for losslesscut CLI docs in readme, there exists just one available cli argument, list files to open, and one option (--settings-json)

@petebocken
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants