MPV can be used to record a television stream. This allows the recording of TV shows. This tip works with MPV on Ubuntu.
Here is an example of recording a TV stream. This uses the ts format. This works best when recording live streams. It can be reencoded to another format later.
<pre lang="bash"> ┌──[jason@11000000.10101000.00000001.00000010]─[~] └──╼ ╼ $ mpv https://i.mjh.nz/7-per1ml.m3u8 --geometry=963x542+1+37 --no-resume-playback --stream-record=stream.ts |
So, this is how to record television with MPV. This works perfectly. This is how flexible the MPV media player is, it can play movies, play online streams, and also record a stream to a file. I do wish I could start and stop recordings whilst the player is running, but that might require a script. Anyway, it works just fine. This might be very useful for recording some music videos from a music channel.
This can be used to record a Youtube video using MPV.
┌──[jason@11000000.10101000.00000001.00000010]─[~] └──╼ ╼ $ mpv https://www.youtube.com/watch?v=pVhNi5cU8mo --stream-record=youtube.ts |
This works perfectly. Another very useful way to play online videos and save a copy.
The –stream-record=stream.ts parameter works just fine to save a stream to a video file that may then be transcoded to a better video format.
Here is another example. This encodes to the MP4 format.
┌──[jason@11000000.10101000.00000001.00000010]─[~] └──╼ ╼ $ mpv https://i.mjh.nz/7-per1ml.m3u8 --geometry=963x542+1+37 --no-resume-playback --stream-record=tv.mp4 |
FFprobe tells us that this is indeed an MP4 format.
┌──[jason@11000000.10101000.00000001.00000010]─[~] └──╼ ╼ $ ffprobe tv.mp4 ffprobe version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2007-2021 the FFmpeg developers built with gcc 11 (Ubuntu 11.2.0-19ubuntu1) configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 70.100 / 56. 70.100 libavcodec 58.134.100 / 58.134.100 libavformat 58. 76.100 / 58. 76.100 libavdevice 58. 13.100 / 58. 13.100 libavfilter 7.110.100 / 7.110.100 libswscale 5. 9.100 / 5. 9.100 libswresample 3. 9.100 / 3. 9.100 libpostproc 55. 9.100 / 55. 9.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'tv.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : mpv 0.34.1 experimental stream recording feature (can generate broken files - please report bugs) Duration: 00:01:21.03, start: 0.000000, bitrate: 2579 kb/s Stream #0:0(und): Audio: aac (HE-AAC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 62 kb/s (default) Metadata: handler_name : SoundHandler vendor_id : [0][0][0][0] Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv), 1280x720 [SAR 1:1 DAR 16:9], 2514 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default) Metadata: handler_name : VideoHandler vendor_id : [0][0][0][0] |
Awesome. Some stream sites started blocking opening HLS m3u8 streams with VLC and using this works to bypass it.
mpv https://URL.m3u8 –stream-record=stream.ts
Thanks to both of you :)
–record-file is deprecated, use –stream-record