fe80Grau / m3uEditor

A basic script to filter m3u on the fly
2 stars 0 forks source link

Usage of this script? #1

Open CrazyWolf13 opened 1 year ago

CrazyWolf13 commented 1 year ago

Hi I discovered this script and I'm wondering what it can be used for?

As I don't really understand spanish, maybe you could give me some hints.

((Is it even possible to do m3u editing on the fly on a raspberrypi? Because i use streamlink to download twitch streams, but sadly they have some sort of id3 stream that includes subtitles? Which blocks jellyfin(media player) from playing then natively via browser direct stream. So I'm wondering if this script is capable of removing this stream?))

fe80Grau commented 1 year ago

Hi @CrazyWolf13 , this script only gets m3u text from URL, parse it and return a reconstruction of m3u text file. In my case i use it to split a large m3u by categories.

M3U list: https://github.com/iptv-org/iptv/blob/master/streams/es.m3u

Example splitting 1080p channels. http://127.0.0.1:5001/filter_m3u?url=https%3A%2F%2Fgithub.com%2Fiptv-org%2Fiptv%2Fblob%2Fmaster%2Fstreams%2Fes.m3u&text=1080p

URL from m3u list needs to be httpencoded (An online tool for example: https://www.urlencoder.org/) text, this scripts will search a coincidence in m3u file, the last example filter list to get onlye the 1080p channels. (because the list include 1080p text in channel line)

Then i put http://127.0.0.1:5001/filter_m3u?url=https%3A%2F%2Fgithub.com%2Fiptv-org%2Fiptv%2Fblob%2Fmaster%2Fstreams%2Fes.m3u&text=1080p in m3u jellyfin settings or VLC player

If you want to remux or package media stream i need more information, maybe a piece of your streamlink command to download twitch streams?

CrazyWolf13 commented 1 year ago

Oh I see. Sorry, my bad, a little bit wrong interpreted.

I can surely provide my command for streamlink, but I don't really think it will be of any use, because my raspberrypi is just not powerful enough to load the jellyfin and download a stream while remuxing it. Remuxing on the fly with only removing the faulty id3 tag with ffmpeg got me barely above 1x speed.

But still thank you for the explanation:)

fe80Grau commented 1 year ago

If you are downloading and storage videos, you can make async workflow like this:

1 - Download video with custom extension ( video.mp4.crazywolf13 for example) or another folder not configured as Jellyfin library, (to avoid Jellyfin read) 2 - After download video execute ffmpeg to reencode/package (i need to see yout media to help you with ffmpeg command) and move to Jellyfin library folder or rename with original extension, video.mp4 3 - Enjoy it in Jellyfin

Alternative solution is chaning the server for your service. You can use a free ARM instance from Oracle (Spain and France, normaly have ARM instances available, other countries are full bussy). You can make an 4vCPU and 24GB RAM "always free". I'm working with this since 6 month an all is working very fine.

https://www.oracle.com/cloud/free/

CrazyWolf13 commented 1 year ago

Thank you for this detailed guide, I thought about something similar, but ditched it, because of other projects.

streamlink --twitch-disable-ads --output "/mnt/Music/${name^} ({time:%Y.%m.%d.%H.%M}).mp4" > for file in /mnt/Seagate/Musik/*.mp4; do audio_file="/mnt/Audio-Only/${file##*/}" audio_file="${audio_file%.*}.mp3" if [ ! -f "$audio_file" ]; then ffmpeg -hide_banner -i "$file" -vn -c:a libmp3lame -b:a 320k "$audio_file" fi done

This is my current command to download the streams and convert to an audio only version. And here some info about the media from twitch via ffprobe. My research led me to the conclusion that the timed id3 is a problem for jellyfin, but that could be wrong. Also a bit surprising is the mpegts at the end, this is eventually also connected to some jellyfin issues. { "streams": [ { "index": 0, "codec_name": "aac", "codec_long_name": "AAC (Advanced Audio Coding)", "profile": "LC", "codec_type": "audio", "codec_time_base": "1/48000", "codec_tag_string": "[15][0][0][0]", "codec_tag": "0x000f", "sample_fmt": "fltp", "sample_rate": "48000", "channels": 2, "channel_layout": "stereo", "bits_per_sample": 0, "id": "0x100", "r_frame_rate": "0/0", "avg_frame_rate": "0/0", "time_base": "1/90000", "start_pts": 1882803930, "start_time": "20920.043667", "duration_ts": 156508800, "duration": "1738.986667", "bit_rate": "157500", "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 } }, { "index": 1, "codec_name": "h264", "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10", "profile": "High", "codec_type": "video", "codec_time_base": "1/120", "codec_tag_string": "[27][0][0][0]", "codec_tag": "0x001b", "width": 1920, "height": 1080, "coded_width": 1920, "coded_height": 1088, "closed_captions": 0, "has_b_frames": 2, "sample_aspect_ratio": "1:1", "display_aspect_ratio": "16:9", "pix_fmt": "yuv420p", "level": 42, "color_range": "tv", "color_space": "bt709", "color_transfer": "bt709", "color_primaries": "bt709", "chroma_location": "left", "field_order": "progressive", "refs": 1, "is_avc": "false", "nal_length_size": "0", "id": "0x101", "r_frame_rate": "60/1", "avg_frame_rate": "60/1", "time_base": "1/90000", "start_pts": 1882802880, "start_time": "20920.032000", "duration_ts": 156319530, "duration": "1736.883667", "bits_per_raw_sample": "8", "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 } }, { "index": 2, "codec_name": "timed_id3", "codec_long_name": "timed ID3 metadata", "codec_type": "data", "codec_tag_string": "ID3 ", "codec_tag": "0x20334449", "id": "0x102", "r_frame_rate": "0/0", "avg_frame_rate": "0/0", "time_base": "1/90000", "start_pts": 1882802880, "start_time": "20920.032000", "duration_ts": 156419640, "duration": "1737.996000", "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 } } ], "format": { "filename": "/mnt/Music/Test.mp4", "nb_streams": 3, "nb_programs": 1, "format_name": "mpegts", "format_long_name": "MPEG-TS (MPEG-2 Transport Stream)", "start_time": "20920.032000", "duration": "1738.998334", "size": "1391842960", "bit_rate": "6402963", "probe_score": 50 } } I have heard about oracle cloud solutions quite a few times, but at the moment I prefer not to rely on them, maybe this will come later.

Thank you very much for looking into this,