Posted: . At: 8:05 AM. This was 1 year ago. Post ID: 17506
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.



Sponsored



How to stream a TikTok video into MPV with the command line on Linux.


It is possible to stream a TikTok video into MPV using yt-dlp. I have recently discovered how to do this.

Do it like this.

yt-dlp https://www.tiktok.com/@howridiculous/video/7171031296284658945 -o - | mpv -

This will pipe nicely to MPV. But it does not work with any videos that require verification to view.

This piping option is the key.

-o – | mpv –

This does the trick nicely with the current yt-dlp and MPV.

(base) ┌─jason-Lenovo-H50-55@jason⬎
└─◉ 5.1-~-07:36-⚫ ◉--[$]  ☕ yt-dlp https://www.tiktok.com/@howridiculous/video/7171031296284658945 -o - | mpv -
[file] Reading from stdin...
[TikTok] 7171031296284658945: Downloading video details
WARNING: [TikTok] Expecting value: line 1 column 1 (char 0). Retrying... (attempt 1 of 5)
[TikTok] 7171031296284658945: Downloading video details
WARNING: [TikTok] Expecting value: line 1 column 1 (char 0). Retrying... (attempt 2 of 5)
[TikTok] 7171031296284658945: Downloading video details
WARNING: [TikTok] Expecting value: line 1 column 1 (char 0). Retrying... (attempt 3 of 5)
[TikTok] 7171031296284658945: Downloading video details
WARNING: [TikTok] Expecting value: line 1 column 1 (char 0). Retrying... (attempt 4 of 5)
[TikTok] 7171031296284658945: Downloading video details
WARNING: [TikTok] 7171031296284658945: Failed to parse JSON  (caused by JSONDecodeError('Expecting value: line 1 column 1 (char 0)')); please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U; Retrying with feed workaround
[TikTok] 7171031296284658945: Downloading video feed
[info] 7171031296284658945: Downloading 1 format(s): h264_540p_2414552-2
[download] Destination: -
[download]   0.7% of 4.40MiB at 10.09MiB/s ETA 00:00 (+) Video --vid=1 (*) (h264 576x1024 25.000fps)
 (+) Audio --aid=1 (*) (aac 1ch 44100Hz)
File tags:
 Comment: vid:v10044g50000ce29tijc77ubke4fd8i0
[download]   5.7% of 4.40MiB at  1.83MiB/s ETA 00:02AO: [pulse] 44100Hz stereo 2ch float
VO: [gpu] 576x1024 yuv420p
[download] 100% of 4.40MiB in 00:01
AV: 00:00:15 / 00:00:15 (99%) A-V:  0.000 ct:  0.161 Cache: 0.0s
 
Exiting... (End of file)

But this is a great tip anyway. This is required for TikTok, but Youtube videos may be played directly with MPV and do not require this trick.

Although, it can be used with Youtube videos anyway.

(base) ┌─jason-Lenovo-H50-55@jason⬎
└─◉ 5.1-~-07:45-⚫ ◉--[$]  ☕ yt-dlp https://www.youtube.com/watch?v=yqTG345TdA8 -o - | mpv -

Play a Youtube video flipped upside down and horizontally.

(base) ┌─jason-Lenovo-H50-55@jason⬎
└─◉ 5.1-~-07:45-⚫ ◉--[$]  ☕ yt-dlp https://www.youtube.com/watch?v=yqTG345TdA8 -o - | mpv - -vf=hflip,vflip

Play a Youtube video and scale the output to a certain size.

(base) ┌─jason-Lenovo-H50-55@jason⬎
└─◉ 5.1-~-07:58-⚫ ◉--[$]  ☕ yt-dlp https://www.youtube.com/watch?v=yqTG345TdA8 -o - | mpv - -vf=scale=160:120

How to hardcode yt-dlp options in a configuration file. Create the file ~/.config/yt-dlp.conf and put the content below in it.

~/.config/yt-dlp.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#Separates videos by channel
-o ~/Downloads/YouTube/%(uploader)s/%(title)s.%(ext)s
 
# Grab Best Audio/Video Format
--format 'bv+ba/b'
 
#Removes usury
#--sponsorblock-remove sponsor,selfpromo,interaction
--sponsorblock-remove sponsor,selfpromo
 
#Coloca thumbnail no video
--embed-thumbnail
 
# Include Media Metadata
--add-metadata
 
# Make Subtitle Format SRT
--convert-subtitles=srt

This will embed thumbnails and also ensure you download the best possible audio and video quality as well. Plus download srt format subtitles. Videos will be saved under the ~/Downloads YouTube/ folder.

Stream a Twitter video directly to MPV from a Twitter post with yt-dlp and MPV.

(base) ┌─jason-Lenovo-H50-55@jason⬎
└─◉ 5.1-~/Downloads/YouTube-09:18-⚫ ◉--[$]  ☕ yt-dlp https://twitter.com/DVATW/status/1618148565217579008 -o - | mpv -

This works perfectly, but possibly not with private videos.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.