VideoHelp Forum




+ Reply to Thread
Results 1 to 5 of 5
  1. Member
    Join Date
    Sep 2005
    Location
    Darkest Peru
    Search Comp PM
    I've been playing around for the first time using this with a live stream instead of yt-dlp.

    I found some odd things, but I now have it mostly where I want it. It live merges the segments to a .ts file and then converts it to .mp4 when the record time limit is reach and I now have it deleting the segments when done.
    ...except it isn't deleting the empty temporary fold that it downloads the segments to.

    Is this an issue with N_m3u8dl-re or something I'm missing?

    Code:
    N_m3u8DL-RE.exe -M format=mp4 -sv best --check-segments-count false --live-real-time-merge --live-keep-segments false --live-record-limit "01:01:01" "(url)"
    Quote Quote  
  2. To delete temporary folders, here is a Python version:

    Code:
    import subprocess
    import shutil
    import os
    import time
    from datetime import datetime
    
    def parse_duration(user_input):
        user_input = user_input.strip()
    
        # Case 1: Only minutes (e.g. "90")
        if user_input.isdigit():
            total_minutes = int(user_input)
            hours = total_minutes // 60
            minutes = total_minutes % 60
            return f"{hours:02d}:{minutes:02d}:00"
    
        # Case 2: Hours:Minutes (e.g. "1:30")
        if ":" in user_input:
            parts = user_input.split(":")
            if len(parts) == 2 and all(p.isdigit() for p in parts):
                hours = int(parts[0])
                minutes = int(parts[1])
                return f"{hours:02d}:{minutes:02d}:00"
    
        return None
    
    
    def record_stream(url, duration):
        tmp_dir = f"temp_segments_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
    
        cmd = [
            "N_m3u8DL-RE.exe",
            "-M", "format=mp4",
            "-sv", "best",
            "--check-segments-count", "false",
            "--live-real-time-merge",
            "--live-keep-segments", "false",
            "--live-record-limit", duration,
            "--tmp-dir", tmp_dir,
            url
        ]
    
        try:
            print(f"Recording for {duration}...")
            subprocess.run(cmd, check=True)
            print("Recording finished.")
        except subprocess.CalledProcessError:
            print("Error during recording.")
        except KeyboardInterrupt:
            print("\nUser interrupted the recording.")
        finally:
            time.sleep(2)
            if os.path.isdir(tmp_dir):
                try:
                    shutil.rmtree(tmp_dir)
                    print(f"Temporary folder removed: {tmp_dir}")
                except Exception as e:
                    print(f"Could not remove {tmp_dir}: {e}")
    
    
    # === Usage ===
    URL = input("PLEASE ENTER THE VIDEO URL: ")
    duration_input = input("ENTER DURATION (minutes OR H:MM): ")
    
    duration_str = parse_duration(duration_input)
    
    if duration_str:
        record_stream(URL, duration_str)
    else:
        print("Invalid format. Use either:")
        print("  90      (minutes)")
        print("  1:30    (hours:minutes)")
    Last edited by sesamap159; 27th Feb 2026 at 10:00.
    Quote Quote  
  3. Member
    Join Date
    Sep 2005
    Location
    Darkest Peru
    Search Comp PM
    Yeah, I don't know python.
    I can write a command line script, but for non-live downloads, n_m3u8dl-re DOES delete the folders. So it's a bug?
    Last edited by doctorm; 1st Mar 2026 at 21:26.
    Quote Quote  
  4. Originally Posted by doctorm View Post
    Yeah, I don't know python.
    I can't write a command line script, but for non-live downloads, n_m3u8dl-re DOES delete the folders. So it's a bug?
    N_m3u8dl-re do not delete the folder that was created temporarily.
    If you want to delete the temporary folder created since N_m3u8dl-re, you can do so from a batch version.

    Code:
    @echo off
    setlocal
    
    :: ===== CONFIG =====
    set URL=(url)
    set TMPDIR=temp
    set RECORDTIME=01:01:01
    
    :: ===== RECORD =====
    N_m3u8DL-RE.exe -M format=mp4 -sv best --live-real-time-merge --live-keep-segments false --live-record-limit "%RECORDTIME%" --tmp-dir "%TMPDIR%" "%URL%"
    
    :: Short pause for safety
    timeout /t 2 /nobreak >nul
    
    :: ===== CLEANUP =====
    if exist "%TMPDIR%" (
        rmdir "%TMPDIR%" 2>nul
        if exist "%TMPDIR%" (
            echo Folder not empty, forcing deletion...
            rmdir /s /q "%TMPDIR%"
        ) else (
            echo Temporary folder removed.
        )
    )
    
    echo Done.
    pause
    Quote Quote  
  5. Member
    Join Date
    Sep 2005
    Location
    Darkest Peru
    Search Comp PM
    So it IS a bug and not my fault. That's what I wanted to know. Maybe it'll get fixed in an update.

    In my batch script since I have the folder name, I can either
    Code:
    rd %name% /S /Q
    or my preference which is
    Code:
    nircmd.exe moverecyclebin "c:\N_m3u8DL-RE\%name%"
    so I can recover it if needed.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!