2
0
mirror of https://github.com/LCTT/TranslateProject.git synced 2025-03-24 02:20:09 +08:00

Merge pull request from lujun9972/translate-MjAxODA4MTUgSG93IHRvIENyZWF0ZSBNM1UgUGxheWxpc3RzIGluIExpbnV4IFtRdWljayBUaXBdLm1kCg==

translate done: 20180815 How to Create M3U Playlists in Linux [Quick …
This commit is contained in:
Xingyu.Wang 2018-10-04 08:00:22 +08:00 committed by GitHub
commit 0c047d32ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 83 additions and 84 deletions

View File

@ -1,84 +0,0 @@
translating by lujun9972
How to Create M3U Playlists in Linux [Quick Tip]
======
**Brief: A quick tip on how to create M3U playlists in Linux terminal from unordered files to play them in a sequence.**
![Create M3U playlists in Linux Terminal][1]
I am a fan of foreign tv series and its not always easy to get them on DVD or on streaming services like [Netflix][2]. Thankfully, you can find some of them on YouTube and [download them from YouTube][3].
Now there comes a problem. Your files might not be sorted in a particular order. In GNU/Linux files are not naturally sort ordered by number sequencing so I had to make a .m3u playlist so [MPV video player][4] would play the videos in sequence and not out of sequence.
Also sometimes the numbers are in the middle or the end like My Web Series S01E01.mkv as an example. The episode information here is in the middle of the filename, the S01E01 which tells us, humans, which is the first episode and which needs to come in next.
So what I did was to generate an m3u playlist in the video directory and tell MPV to play the .m3u playlist and it would take care of playing them in the sequence.
### What is an M3U file?
[M3U][5] is basically a text file that contains filenames in a specific order. When a player like MPV or VLC opens an M3U file, it tries to play the specified files in the given sequence.
### Creating M3U to play audio/video files in a sequence
In my case, I used the following command:
```
$/home/shirish/Videos/web-series-video/$ ls -1v |grep .mkv > /tmp/1.m3u && mv /tmp/1.m3u .
```
Lets break it down a bit and see each bit as to what it means
**ls -1v** = This is using the plain ls or listing entries in the directory. The -1 means list one file per line. while -v natural sort of (version) numbers within text
**| grep .mkv** = Its basically telling `ls` to look for files which are ending in .mkv . It could be .mp4 or any other media file format that you want.
Its usually a good idea to do a dry run by running the command on the console:
```
ls -1v |grep .mkv
My Web Series S01E01 [Episode 1 Name] Multi 480p WEBRip x264 - xRG.mkv
My Web Series S01E02 [Episode 2 Name] Multi 480p WEBRip x264 - xRG.mkv
My Web Series S01E03 [Episode 3 Name] Multi 480p WEBRip x264 - xRG.mkv
My Web Series S01E04 [Episode 4 Name] Multi 480p WEBRip x264 - xRG.mkv
My Web Series S01E05 [Episode 5 Name] Multi 480p WEBRip x264 - xRG.mkv
My Web Series S01E06 [Episode 6 Name] Multi 480p WEBRip x264 - xRG.mkv
My Web Series S01E07 [Episode 7 Name] Multi 480p WEBRip x264 - xRG.mkv
My Web Series S01E08 [Episode 8 Name] Multi 480p WEBRip x264 - xRG.mkv
```
This tells me that what Im trying to do is correct. Now just have to make that the output is in the form of a .m3u playlist which is the next part.
```
ls -1v |grep .mkv > /tmp/web_playlist.m3u && mv /tmp/web_playlist.m3u .
```
This makes the .m3u generate in the current directory. The .m3u playlist is nothing but a .txt file with the same contents as above with the .m3u extension. You can edit it manually as well and add the exact filenames in an order you desire.
After that you just have to do something like this:
```
mpv web_playlist.m3u
```
The great thing about MPV and the playlists, in general, is that you dont have to binge-watch. You can see however much you want to do in one sitting and see the rest in the next session or the session after that.
I hope to do articles featuring MPV as well as how to make mkv files embedding subtitles in a media file but thats in the future.
Note: Its FOSS doesnt encourage piracy.
--------------------------------------------------------------------------------
via: https://itsfoss.com/create-m3u-playlist-linux/
作者:[Shirsh][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://itsfoss.com/author/shirish/
[1]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/Create-M3U-Playlists.jpeg
[2]:https://itsfoss.com/netflix-open-source-ai/
[3]:https://itsfoss.com/download-youtube-linux/
[4]:https://itsfoss.com/mpv-video-player/
[5]:https://en.wikipedia.org/wiki/M3U

View File

@ -0,0 +1,83 @@
Linux下如何创建 M3U 播放列表 [小建议]
======
**简介关于如何在Linux终端中根据乱序文件创建M3U播放列表实现循序播放的小建议。**
![Create M3U playlists in Linux Terminal][1]
我是外国电视连续剧的粉丝这些连续剧不太容易从DVD或像[Netflix] [2]这样的流媒体上获得。还在您可以在YouTube上找到一些内容并[从YouTube下载][3]。
现在出现了一个问题. 你的文件可能不是按顺序存储的. 在GNU / Linux中文件不是按数字顺序自然排序的因此我必须创建.m3u播放列表以便[MPV视频播放器][4]可以按顺序播放视频而不是乱顺进行播放。
同样的,有时候表示第几集的数字实在文件名中间或结尾的,像这样 My Web Series S01E01.mkv. 这里的剧集信息位于文件名的中间,'S01E01'告诉我们人类,哪个是第一集,下一集是哪一个文件。
因此我要做的事情就是在视频墓中创建一个 m3u 播放列表并告诉MPV播放这个 .m3u 播放列表MPV自然会按顺序播放这些视频.
### 什么是M3U 文件?
[M3U][5] 基本上就是个按特定顺序包含文件名的文本文件. 当类似MPV或VLC这样的播放器打开M3U文件时, 它会尝试按给定的顺序播放指定文件.
### 创建M3U来按顺序播放音频/视频文件
就我而言, 我使用了下面命令:
```
$/home/shirish/Videos/web-series-video/$ ls -1v |grep .mkv > /tmp/1.m3u && mv /tmp/1.m3u .
```
然我们拆分一下看看每个部分表示什么意思
**ls -1v** = 这就是用普通的 ls 来列出目录中的内容. 其中 `-1` 表示每行显示一个文件. 而 `-v` 表示根据文本中的数字(版本)进行自然排序
**| grep .mkv** = 基本上就是告诉 `ls` 寻找那些以 `.mkv` 结尾的文件. 它也可以是 `.mp4` 或其他任何你想要的媒体文件格式.
通过在控制台上运行命令来进行试运行通常是个好主意:
```
ls -1v |grep .mkv
My Web Series S01E01 [Episode 1 Name] Multi 480p WEBRip x264 - xRG.mkv
My Web Series S01E02 [Episode 2 Name] Multi 480p WEBRip x264 - xRG.mkv
My Web Series S01E03 [Episode 3 Name] Multi 480p WEBRip x264 - xRG.mkv
My Web Series S01E04 [Episode 4 Name] Multi 480p WEBRip x264 - xRG.mkv
My Web Series S01E05 [Episode 5 Name] Multi 480p WEBRip x264 - xRG.mkv
My Web Series S01E06 [Episode 6 Name] Multi 480p WEBRip x264 - xRG.mkv
My Web Series S01E07 [Episode 7 Name] Multi 480p WEBRip x264 - xRG.mkv
My Web Series S01E08 [Episode 8 Name] Multi 480p WEBRip x264 - xRG.mkv
```
结果显示我要做的事情是正确的. 现在下一步就是让输出以 `.m3u` 播放列表的格式输出.
```
ls -1v |grep .mkv > /tmp/web_playlist.m3u && mv /tmp/web_playlist.m3u .
```
这就在当前目录中创建了 `.m3u` 文件. 这个`.m3u`播放列表只不过是一个.txt文件其内容与上面相同扩展名为.m3u。 你也可以手动编辑它,并按照想要的顺序添加确切的文件名。
之后你只需要这样做:
```
mpv web_playlist.m3u
```
一般来说关于MPV和播放列表的好处在于你不需要一次性全部看完。 您可以一次看任意长时间,然后在下一次查看其余部分。
我希望写一些有关MPV的文章以及如何制作在媒体文件中嵌入字幕的mkv文件但这是将来的事情了。
注意: 这是开源软件,不鼓励盗版
--------------------------------------------------------------------------------
via: https://itsfoss.com/create-m3u-playlist-linux/
作者:[Shirsh][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://itsfoss.com/author/shirish/
[1]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/Create-M3U-Playlists.jpeg
[2]:https://itsfoss.com/netflix-open-source-ai/
[3]:https://itsfoss.com/download-youtube-linux/
[4]:https://itsfoss.com/mpv-video-player/
[5]:https://en.wikipedia.org/wiki/M3U