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)"
+ Reply to Thread
Results 1 to 5 of 5
-
-
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.
-
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.
-
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 -
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 eitheror my preference which isCode:rd %name% /S /Q
so I can recover it if needed.Code:nircmd.exe moverecyclebin "c:\N_m3u8DL-RE\%name%"
Similar Threads
-
N_m3u8DL-RE live output ?
By lasauce35 in forum Video Streaming DownloadingReplies: 22Last Post: 20th Jan 2026, 11:50 -
N_m3u8DL-RE download live stream at start?
By Cryosim in forum Video Streaming DownloadingReplies: 0Last Post: 13th Nov 2025, 15:21 -
N_m3u8DL-R fails downloading the live stream
By doganjr in forum Video Streaming DownloadingReplies: 1Last Post: 26th Feb 2025, 11:51 -
N_m3u8DL-RE live stream
By Sawyer in forum Video Streaming DownloadingReplies: 1Last Post: 14th Aug 2023, 06:32 -
n_m3u8dl-re restream live stream
By trucblah in forum Video Streaming DownloadingReplies: 1Last Post: 27th Dec 2022, 17:32



Quote