User avatar
RPi_Mike
Posts: 91
Joined: Sat Dec 09, 2017 12:57 am
Location: United States

Build FFmpeg and mpv – Automatically in 54 Minutes!

Sat Sep 01, 2018 6:55 pm

mpv_Version_Info_RPi_Mike.png
mpv_Version_Info_RPi_Mike.png (202.3 KiB) Viewed 1440 times

Live_Stream_via_RPi_Mike_Script_Build_01.jpg
Live_Stream_via_RPi_Mike_Script_Build_01.jpg (184.18 KiB) Viewed 1440 times

Live_Stream_via_RPi_Mike_Script_Build_02.jpg
Live_Stream_via_RPi_Mike_Script_Build_02.jpg (138.03 KiB) Viewed 1440 times

To view any of these images at full resolution, right-click and select "open image in new tab" – or on phones and tablets, "tap and hold" and save it to your pictures for full-size viewing.

User avatar
RPi_Mike
Posts: 91
Joined: Sat Dec 09, 2017 12:57 am
Location: United States

Build FFmpeg and mpv – Automatically in 54 Minutes!

Sat Sep 01, 2018 6:58 pm

Live_Stream_via_RPi_Mike_Script_Build_03.jpg
Live_Stream_via_RPi_Mike_Script_Build_03.jpg (190.47 KiB) Viewed 1439 times

To view this image at full resolution, right-click and select "open image in new tab" – or on phones and tablets, "tap and hold" and save it to your pictures for full-size viewing.

User avatar
RPi_Mike
Posts: 91
Joined: Sat Dec 09, 2017 12:57 am
Location: United States

APPENDICES: Build FFmpeg and mpv – Automatically in 54 Minutes!

Sat Sep 01, 2018 7:01 pm

APPENDICES: Build FFmpeg and mpv – Automatically in 54 Minutes!

---

ALL 10 APPENDICES IN FULL – FULLY UPDATED FOR MY NEW SCRIPT-BASED TUTORIAL (September 1, 2018):

I have made numerous additions and enhancements to my FFmpeg and mpv tutorial and script. So much has been added, in fact, that I have now exceeded the 60,000-character posting limit!

As a result, I had to free up space by removing several appendices from my tutorial's main page:

Build FFmpeg and mpv – Automatically in 54 Minutes!

I am therefore including all 10 appendices in this (separate) post:



---------
APPENDIX 1: MOST ESSENTIAL MPV KEYBOARD CONTROLS & OPTIONS:


f key: Toggle the video between full screen and actual size

space bar: Toggle the video (or audio) between pause and play

left and right arrow keys: Rewind and fast-forward by 6 seconds

up and down arrow keys: Rewind and fast-forward by 1 minute

9 and 0 keys: Lower and raise the volume

o key: Make the on-screen display briefly appear to show time remaining, etc.

[ and ] keys: Speed up or slow down the video

q key: Quit out of the video (or audio)


CUSTOMIZE MPV's BEHAVIOR: If you wish to customize things further, you can always modify mpv's configuration file (mpv.conf). The mpv.conf file is a standard text file (but with a ".conf" extension) that can be quickly modified with the standard Text Editor. It's located at /home/pi/.config/mpv (you may have to temporarily click View | Show Hidden in order to see these hidden files and folders in File Manager). In my script, I already included 3 of the most useful customizations inside the mpv.conf file:

--fullscreen <---This forces all videos, both large and small, to automatically expand to fill your screen. To prevent any distortion, this option always maintains the native aspect ratio of the video. By design, it will never "stretch" or "squeeze" the video to fit the shape of your monitor or TV. But as long as the video's aspect ratio matches the aspect ratio of your screen, the video will completely and perfectly FILL the screen. For example, if you have a 480p, 720p or 1080p video (all of which would normally have a 16:9 aspect ratio) – and you also have a monitor or TV with a 16:9 aspect ratio – then your entire screen will be filled with active pixels.

rpi-background=yes <---Sometimes, you may watch an old video – or one that's simply not as "wide" as a 16:9 aspect ratio. For example, you might have an old video from a VHS tape with a low resolution of 320 x 240 (a 4:3 aspect ratio). Or you might have a DVD video with a resolution of 720 x 480 (a 3:2 aspect ratio). Either way, these videos are not "wide" enough to perfectly fit the shape of a modern 16:9 display without being stretched or distorted. In those cases, the "rpi-background=yes" option will automatically add black bars to the left and right sides of your screen so that there are no visual distractions in the background!

screenshot-format=png <---By pressing "s" on your keyboard, mpv will take a screenshot (however, for it to work on MP4 videos, you need to use my "screenshot trick" below). By default, it will save it to your home directory – /home/pi. Mpv's default format for screenshots is the lossy JPG standard. By explicitly specifying it in the mpv.conf file, I'm forcing mpv to use the lossless PNG standard instead. It's rare that I take a screenshot anyway, so I figure I might as well have a "perfect" original. Feel free to delete this line from the mpv.conf file if you'd prefer JPGs.

SCREENSHOT TRICK: With MP4 videos you will normally get a message from mpv that says "taking screenshot failed". Yet with WebM videos, it works just fine. Why the difference? It's because MP4 videos are accelerated by the GPU, whereas WebM videos are handled by the CPU. In "standard" video mode, video handled by the GPU is simply not compatible with screenshots – at least when it comes to mpv. However, I came up with a simple trick to get around this issue. If you have a MP4 video that you want to take screenshots from, you can manually play the video with a special option flag. It basically tricks mpv into entering what I would call a "pseudo-GPU" mode – hardware acceleration still works almost as well as it normally would, yet screenshots work too! It does this by requesting a hardware decoding mode (vaapi) that makes absolutely no sense in the context of the Raspberry. Mpv therefore ignores it and still uses the Raspberry's GPU, but for unknown reasons it "jars loose" the screenshot capability! It's just a ridiculously obscure trick I discovered through lots of testing. So let's say you have a video called "My Vacation.mp4" that you wish to take screenshots from. Just open Terminal and run the following command line – you can then tap "s" on your keyboard and take as many screenshots as you want! Pro tip: Pause the video just before the scene you want to capture and then use the ">" key to advance frame-by-frame through the video until you find the perfect shot:

mpv --hwdec=vaapi "/home/pi/Videos/My Vacation.mp4"


--loop <---I did NOT add this option to the mpv.conf file because most people would not want this as the default behavior. But if you're using your Raspberry to power a display in a doctor's waiting room, trade show, retail setting or some other venue, this is a great way to make the video automatically play over and over again.

geometry=20%+0+0 <---This mpv.conf line will force a 1080p video to play at only 4% of the total surface area of a 1080p monitor or TV – and it will place it in the upper-left corner of your screen. NOTE: In case you're wondering how 20% becomes 4%, it all comes down to understanding the difference between linear dimensions and surface dimensions. Assuming the native resolution of the video is the same as your screen's resolution, 20% smaller across the X axis AND 20% smaller across the Y axis means the video would only cover 4% of your screen's total surface area (20% x 20% = 4%).

geometry=20%+1536+0 <---And what if I want a tiny video to appear in the upper-right corner of my screen? For this mpv.conf example, simple math is in order: My 1080p monitor is 1920 pixels across. 20% of 1920 is 384. And 1920 - 384 = 1536. That means the upper-left corner of the video should start at 1536 on the X axis and 0 on the Y axis. In both of these examples, tapping the "f" key will instantly toggle the video back and forth between FULL SCREEN and TINY SCREEN. Mpv handles it beautifully in the blink of an eye.

TAKE MANUAL CONTROL OF MPV: The contents of the mpv.conf file affects mpv's "fundamental" behavior. In other words, it will always affect the way mpv behaves when it plays video and audio. But for some options, you can temporarily invoke a behavior on a one-time basis without modifying your mpv.conf file. Generally, this only works for options that begin with 2 dashes (--). For example, let's say you do NOT have the "--loop" option in your mpv.conf file, but you still want to launch a video with that behavior on a one-time basis. To do that, you can manually launch the video inside Terminal (instead of double-clicking it in File Manager as you would normally do). Here are some common syntax examples for manual launching of multimedia files:

EXAMPLE A: This is the MANUAL way to play a video with mpv. Normally, as I just mentioned, you would simply double-click the file and it would automatically start playing – but I'm including these manual examples for the benefit of interested users. In this example, we are NOT invoking any special options (other than what's already in your mpv.conf file). It also assumes that Terminal is currently open inside the same folder as your video:

mpv video.mp4


EXAMPLE B: This manually instructs the video to loop continuously (in addition to whatever else your mpv.conf file may have it do). It also assumes that Terminal is currently open inside the same folder as your video:

mpv --loop video.mp4


EXAMPLE C: This does the same thing as Example B, but it does so for a video that's in a completely different folder than the one Terminal is currently located in (which is normally your "home" folder by default – /home/pi). In other words, in this example, you're using the FULL DIRECT PATH to the video. The full path to a file can be easily obtained by right-clicking any file in File Manager and selecting "Copy Path(s)". This syntax is necessary whenever Terminal and the video are in different locations:

mpv --loop /home/pi/vacations/hawaii/video.mp4


EXAMPLE D: This also does the same thing as Example B, but it places the full path inside standard quote marks. Why is this important? You must do this any time there are SPACES in the file path. That's a Linux thing, not a mpv thing. For example:

mpv --loop "/home/pi/truly awesome vacations/hawaii/video.mp4"


MPV HAS HUNDREDS OF OTHER OPTIONS AND FEATURES: For complete details, please review the extremely thorough manual at mpv's official website.






---------
APPENDIX 2: DOWNLOAD AND RETAIN HIGH-QUALITY VIDEOS FROM HUNDREDS OF WEBSITES – WITH YOUTUBE-DL:


UPDATE YOUTUBE-DL EVERY NOW AND THEN: Although my script automatically downloads and installs youtube-dl, websites constantly change the way they handle video and the developers of youtube-dl keep updating their code in order to stay on top of it. So every now and then, it's a good idea to make sure you have the very latest version of youtube-dl. There are various ways to do that, but this is probably the easiest. Just run this in Terminal:

sudo pip install --upgrade youtube_dl



DOWNLOADING MP4 VIDEOS (H.264 / AAC): Let’s say you have your Raspberry hooked up to a high-definition 1920 x 1080 monitor or TV and you wish to download and enjoy a NASA video, at maximum resolution and quality, of two neutron stars colliding – with the screen completely filled-up by the video. Here’s how you do that with youtube-dl:

STEP 1: Identify the URL of the page that contains the video you want. In this example, it’s a YouTube video at the following URL:

https://www.youtube.com/watch?v=x_Akn8fUBeQ


STEP 2: Open the Terminal window and enter the following code (make sure you use a capital "-F"):

youtube-dl -F https://www.youtube.com/watch?v=x_Akn8fUBeQ


STEP 3: You will then see an impressive list of all the different audio and video formats that the YouTube server has available for the NASA video. If you look carefully, you will see there’s a video track with a resolution of 1920 x 1080 that uses the "avc1" codec at 30 FPS (Frames Per Second). "AVC1" is simply another name for the H.264 codec. The Raspberry’s GPU has been specifically optimized to play H.264 video with full-blown hardware acceleration. On the far left column, you will see a "format code" for that particular video format. In this case, it’s code "137". You will also see a high-quality audio track that’s described as an "m4a" with a sampling rate of 44100Hz. That’s YouTube's terminology for an AAC audio track. It has format code "140". It's the best choice for this example, since an AAC audio track is specifically designed to work with an H.264 video track when creating an MP4 video. To download the high-resolution video (with sound), you will therefore issue the following command (make sure you use a lower-case "-f"):

1920 x 1080 MP4 – 30 FPS:
youtube-dl -f 137+140 https://www.youtube.com/watch?v=x_Akn8fUBeQ

Once the download is complete, be sure to close the Terminal window or you will lose keyboard control of mpv. Then, simply double-click the MP4 video you just downloaded and mpv will automatically start playing it full screen! If you downloaded a resolution smaller than your screen, you can tap the "f" key to toggle back and forth between actual size and full screen mode.



DOWNLOADING WEBM VIDEOS (VP9 / Opus): If you want a much smaller file size at a surprisingly high quality – albeit with lower resolutions of 720p or 480p – the "VP9" format for video and the "Opus" format for audio are the ones you want. They are the most advanced compression technologies currently available. The two tracks will be automatically combined by youtube-dl (using the FFmpeg engine) and merged into a standard WebM video. Be aware that the Raspberry’s GPU is only designed to provide full hardware acceleration for MP4 videos using H.264 – so a 1080p VP9-based WebM video will push your Raspberry to the absolute limit and will likely result in at least some stutter. That's why I recommend 720p and 480p resolutions for VP9-based videos. They also, of course, should not exceed 30 FPS. Finally, if you wish to share the video with someone else who doesn’t have an advanced player like mpv, it’s best to stick with a standard H.264-based MP4 video for compatibility reasons. For the NASA video, here are the two best command lines if you want smaller file sizes (for example, if you're using a cellular connection and need to conserve your data usage). When it's competently encoded by the uploader, I've been consistently amazed by how good a humble 480p video can look when viewed full screen on my large 24 inch 1080p monitor.

1280 x 720 WEBM – 30 FPS:
youtube-dl -f 247+249 https://www.youtube.com/watch?v=x_Akn8fUBeQ

854 x 480 WEBM – 30 FPS:
youtube-dl -f 244+249 https://www.youtube.com/watch?v=x_Akn8fUBeQ



CAUTION: Don't assume the format codes will always be the same. YouTube is quite consistent – but even with them, the available formats can vary from one video to another. For example, I've noticed that YouTube's servers will often place different formats in a queue, prioritizing H.264 over VP9. Even for the mighty Google, encoding video is very computationally intensive and time consuming – so it makes sense for them to quickly get the H.264 version up on their server, and then process the VP9 version an hour or half hour later. Other video sites, however, use completely different format codes and are typically limited to H.264 videos – so for them, you'll want to first run youtube-dl's "-F" option (capital F), as explained above, to see exactly what formats are available. Finally, be aware that most other sites tend to integrate the video and audio tracks into a single pre-packaged MP4 video – so there won't be separate video and audio formats to choose from. YouTube does this as well, by the way. It's usually listed in the last couple lines of their available formats. In YouTube's case, you'll know if everything's already been combined if it says both "avc1" and "mp4a" in the description. In those cases, you would not use the "+" symbol. Instead, you would simply use a single format code.

YOUTUBE-DL HAS MANY OTHER FEATURES AND CAPABILITIES: To learn more, visit youtube-dl's official website.






---------
APPENDIX 3: PLAY ONLINE VIDEOS AUTOMATICALLY WITH MPV (WITHOUT ANY MANUAL DOWNLOADING):

Personally, I like to review all the available video and audio formats before I download a video. If it's a concert or music video, I may want to enjoy it multiple times. By downloading it, as described in Appendix 2, I have immediate access to it at the highest quality – even if I'm offline. Downloading is also crucial if you're using a cellular data connection and need to conserve your data. Even with an "unlimited" plan, your carrier may still throttle back your speed once you reach a monthly limit. For those instances, I've found that 480p videos that use the advanced VP9 video codec and Opus audio codec at 50 or 70 kbps are the perfect balance between file size and quality. In an HD aspect ratio, they typically have resolutions of 854 x 480. For a relatively small video, they look surprisingly good on my large 1080p monitor in full screen mode. Of course, if you want the absolute best in quality on a 1080p screen and data use is not a concern, there's nothing like a 1080p video.

In many cases, however, data use may not be a concern. You also may not have any desire to manually download (and retain) the video. And finally, you may not really care if you're viewing the most optimal format and quality – because you just want to watch a video without any thought. In those cases, I have configured my script to support tight integration between mpv and youtube-dl. As long as you have properly followed this tutorial and have installed a recent copy of youtube-dl (see Appendix 2), all you have to do is enter a URL after the mpv command! That will automatically invoke youtube-dl, which will start downloading the first several seconds of the video (invisibly as a background process). It does this to create a sufficient cache to help prevent buffering interruptions while playing. Once it's done that, mpv will automatically start playing the video! Generally, when operating in this mode, youtube-dl's algorithm will attempt to choose the "best quality" version of the video. It works well on leading video sites like YouTube, but there are no guarantees with less sophisticated websites. If you're unsatisfied with the results on other sites, nothing of course beats a manual review of the available formats (as described in Appendix 2).

As an example, if you want to automatically play the NASA video mentioned in Appendix 2, this simple command line is all it takes:

mpv https://www.youtube.com/watch?v=x_Akn8fUBeQ






---------
APPENDIX 4: STREAM LIVE TELEVISION FROM AROUND THE WORLD:

Not only can you "download and play" and "auto play" videos from sites like YouTube, but you can also use the mpv / youtube-dl combination to stream live television broadcasts from around the world. This is often referred to as IPTV – Internet Protocol TV.

Quality television requires considerable resources to produce – so most high-end content is not freely available. But there are a few sources of free, high-quality streaming content. These are typically government-funded broadcasters that wish to freely share their nation's culture and perspective with the larger world. Perhaps the best examples of this are the national news broadcasters of Australia, Germany, Japan, and France. And although it's corporately-owned, Sky News – headquartered in metro London – also provides excellent 24/7 global news coverage.

All five of these broadcasters make their live TV streams openly and freely available on their public websites – so they definitely want people to watch them!

You can also watch these feeds from inside the Raspberry's web browser – but that typically results in stuttering video. Mpv provides a much smoother, customizable, full-screen experience.

All five networks offer live, 24-hour TV news that is generally regarded as relatively fair and journalistically professional. To the best of my knowledge, these are the only "reputable" sources of FREE TV news from major, internationally-recognized outlets that broadcast in English. The BBC, though also very reputable, limits its TV streams to UK citizens and paying international subscribers only. There are other free "news" broadcasts available – but many of them act as propaganda outlets for various dictatorships around the world.

In my testing, it usually took about 10 seconds from the moment I entered the following command lines until the live TV broadcasts appeared (youtube-dl has to first analyze the stream before it hands it off to mpv, which then buffers and plays it). Technically, due to buffering and other factors, you will see these broadcasts on a slight "tape delay". In other words, as you're watching the news, you're actually seeing it between 10 and 50 seconds in the past. I calculated the typical delays by noting the exact moment the "top of the hour" broadcasts appeared and compared those times to an atomically-synchronized clock. Though technically interesting, this tiny "tape delay" obviously has no meaningful impact on the value of these feeds.

If you're a "cord cutter" and have cancelled your cable or satellite TV, there are also legitimate IPTV subscription services that will provide dozens or hundreds of streams for a monthly fee.

Here, now, are the five best freely available sources of live, international TV news. For each broadcaster, the first command line will simply cause mpv to play the stream. The second command line will play the stream AND save the video to your system. Be aware that this recording capability is an experimental feature of mpv with absolutely no guarantees – although it worked extremely well in my testing of these five news sites. My suggested command lines will save the video as a ".ts" file to /home/pi (you can change the path to any location you wish). Mpv can play .ts video files at any time:


AUSTRALIA – ABC News – Australian Broadcasting Corporation [854 x 480; 4.5 MB per minute; H.264 stream]

mpv --ytdl-format=94 https://www.youtube.com/watch?v=sSTH5sBWcVQ

mpv --ytdl-format=94 https://www.youtube.com/watch?v=sSTH5sBWcVQ --record-file="/home/pi/Australia_News.ts"



GERMANY – DW News – Deutsche Welle [1280 x 720; 14.5 MB per minute; H.264 stream]

mpv --ytdl-format=95 https://www.youtube.com/watch?v=m5Nst2zMZVY

mpv --ytdl-format=95 https://www.youtube.com/watch?v=m5Nst2zMZVY --record-file="/home/pi/Germany_News.ts"



JAPAN – NHK World – Japan Broadcasting Corporation [1280 x 720; 9.6 MB per minute; H.264 stream]

mpv https://nhkwtvglobal-i.akamaihd.net/hls/live/263941/nhkwtvglobal/index_1180.m3u8

mpv https://nhkwtvglobal-i.akamaihd.net/hls/live/263941/nhkwtvglobal/index_1180.m3u8 --record-file="/home/pi/Japan_News.ts"



UNITED KINGDOM – Sky News [1920 x 1080; 28.3 MB per minute; H.264 stream; see all available resolutions]

mpv --ytdl-format=96 https://www.youtube.com/watch?v=XOacA3RYrXk

mpv --ytdl-format=96 https://www.youtube.com/watch?v=XOacA3RYrXk --record-file="/home/pi/Sky_News.ts"



FRANCE – France 24 – France Vingt-Quatre [1920 x 1080; 24.7 MB per minute; H.264 stream]

mpv --ytdl-format=96 https://www.youtube.com/watch?v=J78SdCzzumA

mpv --ytdl-format=96 https://www.youtube.com/watch?v=J78SdCzzumA --record-file="/home/pi/France_News.ts"




CRITICAL NOTE: I picked the highest-resolution format codes for the live streams above. But if you need to limit your data use, or don't currently have a good Internet connection, you can easily find out all the other resolutions that are available by using youtube-dl's "-F" option (capital F). Be aware that data rates – even for the same stream at the same resolution – can vary quite a bit depending on how complex the live stream happens to be at any given moment (for example, a person calmly sitting at a desk presenting the news is a much less complex scene than a fast-paced sporting event shot from multiple angles). My estimate of "data use per minute", therefore, merely reflects the data rate I experienced when I randomly tuned in to the live feed. Now that you understand that, let's get back to the various resolutions available for each stream: For example, to find all the streams available for France 24, simply run this command line:

youtube-dl -F https://www.youtube.com/watch?v=J78SdCzzumA


And you will see that there are 6 resolutions available – via format codes 91, 92, 93, 94, 95, and 96 (truncated by me to only show what's relevant; estimated data usage also added by me):

Format Code........ Resolution........ Data Use Per Minute
91......................... 256x144.................... 1.2 MB
92......................... 426x240.................... 2.5 MB
93......................... 640x360.................... 5.8 MB
94......................... 854x480.................... 9.2 MB
95........................ 1280x720................... 14 MB
96....................... 1920x1080.................. 25 MB



UPDATE – SEPTEMBER 2018: As you can see, live news from Australia, Germany and France is now available directly from YouTube! Until recently, you had to find the "direct" links in order to play their live streams. I have therefore updated all the URLs you see above accordingly. Given YouTube's extremely robust infrastructure, this not only makes the live feeds more reliable but it also makes it very unlikely that the links will "expire" (unless of course one of the broadcasters changes its mind in the future and decides to withdraw from YouTube for some reason). At the time of this writing, only NHK World from Japan is not available via YouTube – but I just checked the link above and the live stream from Japan still works perfectly. Even though most of the broadcasters are now available via YouTube, I've decided to keep all the information below in this appendix. I wrote it just a few months ago and it's still quite useful in that it describes a generalized technique that can be used on almost any live stream site to determine the "hidden" URL and format codes in order to play them on mpv!


UPDATE – SEPTEMBER 2018: If you're a gamer and like to watch Twitch, I've confirmed that the above method works perfectly on Twitch.com. Simply pick out a live Twitch broadcast you like and copy its URL. Then use youtube-dl's "-F" option to determine the format code for the resolution you want to watch and start watching! It's exactly the same method I just described above for France 24. And just like France 24 and the other news broadcasters, you can either just watch it – or watch it AND record it at the same time!


CRITICAL NOTE (originally written May 2018): The URLs in the above command lines could change or expire at any time – so you may have to search for updated m3u8 streams – or use the technique I developed which appears below. If you get an error message that mentions "[ytdl_hook]" and it says "unable to download webpage", or you see a reference to "HTTP error 403", the URL is either temporarily down or has expired and become a dead link. The source for the above news streams is located at the LegalStream GitHub site. Finally, in addition to my build of mpv, you must of course have youtube-dl for the streaming function to work (preferably the latest version; see Appendix 2 for details). Hat tip to user "johndavies" for his suggestion to include streaming news!


FIND THE LATEST STREAMING URLs ON YOUR OWN Since these m3u8 streaming links can change or expire at any time, I developed the following technique to obtain the latest streaming URL for a major national broadcaster. In this case, I'm using the live TV news feed from the Australian Broadcasting Corporation as an example (the same outlet listed above). My method has the added advantage of getting the URL "straight from the source" rather than a third-party website that may have old links. It also lets you choose the resolution (and corresponding data usage). Keep in mind that although I'm using ABC News as an example, my basic approach will work on other websites as well. Whether or not it works on any particular site depends on what's available in the HTML code! Technical Note: URLs that end with m3u8 use the HLS streaming protocol, the most popular modern standard (the other leading streaming standard is the DASH protocol, which is heavily used by YouTube).


1: Visit the ABC News channel at this URL:

http://www.abc.net.au/news/newschannel

NOTE: This must be done with Chromium – the built-in web browser that comes with the Raspbian operating system. If you can do it with an alternate browser, that's fine too – just know that I have only tested it with Chromium.


2: On your keyboard, press CTRL + S. (You can also click the tiny button in the upper-right corner with the 3 vertical dots; then click "More tools"; then click "Save page as...")


3: In the bottom-right corner of the "Save File" window that appears, you'll see a drop-down button that lets you save the "Complete" web page or just the "HTML Only" version. For our purposes, you only need to save the "HTML Only" version. This has the added advantage of saving only ONE simple file to your system. Once you've set it to "HTML Only", make note of the folder it's saving it to. By default, the file will probably be called "ABC News (Australian Broadcasting Corporation).html". But to make things simple, change the file name to ABC.html and click the Save button!


4: Using File Manager, right-click the ABC.html file and then click Text Editor.


5: On your keyboard, press CTRL + F and do a text search for "m3u8" (no quotes). Note: Video streams can use extensions other than m3u8 – so if you're trying this technique on a different website, you can also search for URLs ending in .mpd, .f4m, .mp4, etc.


6: As of this writing, you'll find only one "hit" in the HTML code for "m3u8". It should appear at the very end of a URL that begins with http or https


7: That's it – that's the latest m3u8 streaming URL for ABC's 24-hour news channel! So carefully copy that URL!


8: You can now place the "mpv" command right before that URL and start watching live TV news from Australia!


CRITICAL NOTE: The URL I'm using below works perfectly at the time of this writing – but you may need to occasionally repeat the above procedure to get the latest URL if the old one expires. It's also possible that this entire procedure will suddenly stop working due to a major change in the design of the ABC website. The m3u8 link could suddenly disappear from their HTML code, for example. Nonetheless, at the time of this writing, you would simply use one of the following command lines in Terminal:

VIEW ONLY:
mpv https://abc-iview-mediapackagestreams-1.akamaized.net/out/v1/50345bf35f664739912f0b255c172ae9/index.m3u8

VIEW AND RECORD:
mpv https://abc-iview-mediapackagestreams-1.akamaized.net/out/v1/50345bf35f664739912f0b255c172ae9/index.m3u8 --record-file="/home/pi/Australia_News.ts"



WANT TO GET MORE SOPHISTICATED? I also figured out how to obtain ALL the video formats that are currently available on the streaming server used by ABC! By "formats", I mean the many different resolutions that are available. In my testing, when you do Step 8 above, the server will automatically feed the highest-resolution format to your Raspberry (1024x576). But if you need to limit your data usage for whatever reason, it can be extremely useful to know how to access the other formats.

To do that, just follow these 2 simple steps:


1: Copy the m3u8 URL you obtained previously in Step 7 and use it with youtube-dl's "-F" command (capital F). Like this, for example:

youtube-dl -F https://abc-iview-mediapackagestreams-1.akamaized.net/out/v1/50345bf35f664739912f0b255c172ae9/index.m3u8


After a few seconds, you will get a response like this (truncated by me to only show what's relevant; estimated data usage also added by me):

Format Code........ Resolution........ Data Use Per Minute
365...................... 320x180..................... 3.1 MB
691...................... 512x288..................... 5.4 MB
932...................... 640x360..................... 7.1 MB
1276.................... 800x450..................... 9.3 MB
1826.................... 1024x576................. 13.1 MB


2: Do you see the format codes and their corresponding resolutions? Simply pick one and use it with mpv's "--ytdl-format=" option like this:

VIEW ONLY – 512 x 288 RESOLUTION:
mpv --ytdl-format=691 https://abc-iview-mediapackagestreams-1.akamaized.net/out/v1/50345bf35f664739912f0b255c172ae9/index.m3u8

VIEW AND RECORD – 512 x 288 RESOLUTION:
mpv --ytdl-format=691 https://abc-iview-mediapackagestreams-1.akamaized.net/out/v1/50345bf35f664739912f0b255c172ae9/index.m3u8 --record-file="/home/pi/Australia_News.ts"

CRITICAL NOTE: In the above command lines, I used format code "691" to retrieve the rather tiny 512x288 resolution format. If you're concerned about data usage, this actually might be the "best bang for the buck" as it looked surprisingly good at full screen on my large 1080p monitor. Feel free to replace the "691" format code with 365, 932, 1276 or 1826. Keep in mind, of course, that those are the available format codes as of this writing. In the future, you can re-do the above procedure to verify that those codes still apply – or to obtain new ones!






---------
APPENDIX 5: SAMPLE FFMPEG COMMAND LINES – TO ENCODE OR PROCESS VIDEO AND AUDIO:

NOTE: In the following examples, simply right-click any folder that contains the media files you wish to encode or process and click "Open in Terminal". Then, run the following command lines (changing the file names and settings where appropriate).

TIP: Unless it's necessary, try not to have your media folder open in File Manager while FFmpeg is actively running (by "media folder", I mean the folder in which you're encoding and processing files with FFmpeg). Remember – you can select "Open in Terminal" without actually opening a folder. Depending on what kind of work you're doing, having a folder open (whether its contents are visible on your screen or not) can slow things down considerably – because File Manager will keep automatically refreshing its contents, thus unnecessarily wasting CPU cycles.



EXAMPLE 1: Convert an old AVI video (with sound) – or any other input video format you choose – into a modern MP4 (with H.264 video and AAC audio):

ffmpeg -i input.AVI -vf format=yuv420p -c:v libx264 -crf 23 -c:a libfdk_aac -b:a 128k output.MP4

NOTE: This example uses the higher-quality (but slower) x264 software-based encoder. That means there is no GPU hardware acceleration – however it does use a CPU optimization known as "NEON" that helps to speed up the encoding. The "-crf 23" setting is the default video quality and generally produces excellent results. The lower the number, the higher the encoding quality (at the expense of a larger file size). A setting of 18 is said to be "visually lossless" – but the file size will be almost double that of a 23 setting. Be aware that the number scale is non-linear – but as a rough rule of thumb, a change of 5 to 6 will double (or cut in half) the file size. In many cases, when a smaller file size is important, a setting of 26 still maintains a high-quality appearance. Finally, the "-c:a libfdk_aac -b:a 128k" part indicates that the audio will be converted with the Fraunhofer AAC codec, at a bit rate of 128 kbps.



EXAMPLE 2: Resize a large "1080p" MP4 video (1920 x 1080) with sound into a smaller "480p" MP4 video (854 x 480) with sound – without (unnecessarily) re-encoding the original audio:

ffmpeg -i input.MP4 -vf "format=yuv420p, scale=854:480:flags=lanczos" -c:v libx264 -crf 23 -c:a copy output.MP4

NOTE: In the above FFmpeg command line, "-c:a copy" means that the audio track in the input file will be directly COPIED over to the output file without any transcoding (re-encoding). If you're certain the original audio is already in the desired format, that is the best course of action – because any additional encoding of an already-encoded file will result in some degradation in quality. If, however, the original audio is in the MP3 format (for example) and for some reason you want the output video to use ACC audio instead, then you would simply replace the "-c:a copy" with "-c:a libfdk_aac -b:a 128k".



EXAMPLE 3: Extract every frame from a 30 FPS MP4 video and output it as a padded, 7-digit numerical JPEG image sequence:

ffmpeg -i video.mp4 -vf fps=30 -q:v 2 %07d.jpg



EXAMPLE 4: Convert an alphanumeric image sequence of JPEG pictures into a 30 FPS MP4 video:

ffmpeg -framerate 30 -pattern_type glob -i "*.jpg" -vf format=yuv420p -c:v libx264 -crf 23 output.MP4



EXAMPLE 5: Add a transparent overlay – such as text or a logo – on top of a video:

ffmpeg -i input.MP4 -i overlay.png -filter_complex "[0:v][1:v] overlay=0:0" -c:v libx264 -crf 23 -c:a copy output.MP4

NOTE: The "overlay.png" file must be a transparent PNG file (with alpha channel) that includes your text or logo. This can be created with any standard image-manipulation program like GIMP or Photoshop. The dimensions of the overlay image should obviously be the same as the video's resolution. Also, in this particular example, the inputted MP4 video is assumed to have a proper sound track that can simply be copied over without re-encoding. If the sound requires encoding, simply change "-c:a copy" to "-c:a libfdk_aac -b:a 128k".



EXAMPLE 6: Use the hardware-accelerated H.264 encoder to convert an AVI into an MP4:

ffmpeg -i input.AVI -c:v h264_omx -b:v 4500k -c:a copy output.MP4

NOTE: The hardware encoder, though about 3 times faster, has fewer options and generally, bit for bit, produces a decent but lower-quality result. The software-based encoder, which relies on the versatile and general-purpose CPU, provides the programmers maximum flexibility to use whatever coding techniques they like – but a hardware encoder, by its very nature, is constrained by the features the GPU supports. Like most things in life, there are pros and cons to each approach. In this example, the "-b:v 4500k" part indicates a bit rate of 4,500 kbps – which is generally good for a large 1080p video. Unlike the software-based encoder, there is no "crf" quality setting, since the hardware-based encoder uses bit rate as a proxy for quality. If your video is smaller than 1080p, you will obviously want to lower the bit rate accordingly – to 2,000, 1,500, etc. Finally, this example assumes the existing audio is already in an MP4-compatible format, such as an AAC or MP3, and can thus be copied over. Other audio formats are NOT compatible with the MP4 container – so if you need to transcode the audio to a compatible format, simply change "-c:a copy" to "-c:a libfdk_aac -b:a 128k".



EXAMPLE 7: Create an MP3 audio file with the highly-regarded LAME encoder:

ffmpeg -i input.WAV -c:a libmp3lame -q:a 5 output.MP3

NOTE: In this example, we're converting a .wav audio file to a .mp3 audio file (the input file can be almost any audio format of your choosing). The "-q:a 5" part is the encoding quality. The LAME encoder supports a variety of settings, but my example features a quality-centric setting rather than one that attempts to achieve an EXACT – but entirely arbitrary – bit rate. This approach is known as variable bit-rate encoding (VBR). In the case of stereo sound, "-q:a 5" will yield an overall bit rate that's ABOUT (but not exactly) 128 Kbps. This is the most commonly used bit rate, and it roughly approximates "CD-quality" sound. The highest-quality setting, "-q:a 0", will produce an overall bit rate of ABOUT 256 Kbps. Finally, the lowest-quality setting, "-q:a 9", yields an overall bit rate of about 64 to 80 Kbps. For all of these quality settings, the actual bit rate will depend on the overall complexity of the sounds in the input file. Also, if it's a mono recording instead of stereo, the bit rates will be cut roughly in half. Sample rate – such as 22.05 KHz instead of the more common 44.1 KHz – will also lower the overall bit rate. Don't necessarily be dissuaded by the "lowest quality" setting. For a non-musical voice recording, such as an interview, this setting is still quite excellent and produces a file that's roughly 3 to 4 times smaller than the highest-quality setting. If you want to take a "deep dive" on how the "-q:a" setting affects perceived quality, take a sample audio file and encode it 3 separate times – with a "-q:a" of 0, 5, and 9. In many cases, unless you're an expert audiophile with a golden ear, you may not even notice a difference! Finally, be aware there are reports that some MP3 players from the 1990s and early 2000s may not be able to play files that use VBR encoding. I have not personally encountered that issue and won't bother addressing it here – just be aware that LAME also supports constant bit-rate encoding (CBR) in case you experience that issue with an antiquated player.



LEARN MORE ABOUT FFMPEG: The 7 examples I just explained are only a small sample of the astonishing capabilities of FFmpeg. For more information, visit FFmpeg's official website.






---------
APPENDIX 6: IF FOR SOME UNKNOWN REASON YOU WISH TO COMPLETELY UNINSTALL ALL 6 PROGRAMS THAT WERE BUILT AND INSTALLED BY MY SCRIPT, SIMPLY RUN THE FOLLOWING COMMAND LINE IN TERMINAL:

sudo dpkg -r ffmpeg mpv x264 fdk-aac mp3lame libass


THEN, DELETE THE "preferences" FILE MY SCRIPT USED TO "PIN" THE PROGRAMS (IF YOU HAVE MANUALLY PINNED OTHER PROGRAMS UNRELATED TO THIS TUTORIAL, YOU WOULD OBVIOUSLY WANT TO EDIT THIS FILE, NOT DELETE IT):

sudo rm /etc/apt/preferences


FINALLY, YOU CAN OPTIONALLY REMOVE ALL REFERENCE TO MPV IN YOUR FILE ASSOCIATIONS BY DELETING ALL MPV-RELATED LINES IN YOUR MIMEAPPS FILE. YOU CAN EASILY EDIT THAT FILE BY RUNNING THIS COMMAND LINE:

leafpad /home/pi/.config/mimeapps.list






---------
APPENDIX 7: IF FOR SOME REASON YOU NEED TO RE-INSTALL ALL THE PROGRAMS IN THIS TUTORIAL ON YOUR *EXISTING* SYSTEM, YOU CAN DO IT IN LESS THAN ONE MINUTE! BY "EXISTING" SYSTEM, I MEAN THE SAME RASPBERRY WITH THE SAME OPERATING SYSTEM THAT YOU WERE USING WHEN YOU RAN MY SCRIPT. BY "EXISTING" SYSTEM, I ALSO MEAN THAT YOUR CORE SYSTEM AND "FIRMWARE" FILES HAVE NOT BEEN ALTERED. IF YOU HAVE SINCE RE-INSTALLED THE OPERATING SYSTEM OR IT'S A NEW SYSTEM – OR IT JUST ISN'T YOUR "EXISTING" SYSTEM FOR WHATEVER REASON – YOU NEED TO USE APPENDIX 8 INSTEAD. BUT IF IT TRULY IS YOUR EXISTING SYSTEM, SIMPLY RIGHT-CLICK WHATEVER FOLDER CONTAINS ALL THE ".DEB" FILES, SELECT "Open in Terminal", AND RUN THE FOLLOWING COMMAND (SEE THE NOTES INSIDE MY SCRIPT FOR MORE INFORMATION ON THE DEBIAN PACKAGE FILES). THERE SHOULD BE EXACTLY 6 .DEB FILES IN THE FOLDER:

sudo dpkg -i *.deb






---------
APPENDIX 8: IF YOU WISH TO INSTALL ALL THE PROGRAMS IN THIS TUTORIAL ON ANOTHER RASPBERRY PI 3 – OR ON THE SAME RASPBERRY PI 3 AFTER A FRESH INSTALL OF THE OPERATING SYSTEM – IT ONLY TAKES A FEW MINUTES! JUST FOLLOW THESE 8 SIMPLE STEPS:

STEP 1: Make sure the other Raspberry has a completely normal, standard copy of the Raspbian Stretch operating system. Please see my tutorial to find out exactly what I mean by "normal" – both the requirements section and Step 2 have critical information on this topic. If you're certain that everything is perfectly "normal" with the other Raspberry, simply open Terminal and do a standard update to make sure everything is current:

sudo apt-get update

sudo apt-get dist-upgrade



STEP 2: Set your GPU memory allocation to 128 MB (mpv requires 128 MB to work). Proceed as follows:

Click the Raspberry Menu | Preferences | Raspberry Pi Configuration | Performance Tab

Change "GPU Memory" to 128

Click OK | Click YES to reboot!

CRITICAL NOTE: If the GPU memory is already at 128 MB, reboot anyway – to make sure the system upgrade in Step 1 has fully kicked in!



STEP 3: Install the dependencies required by the pre-compiled Debian packages that my script created. Because the ".deb" files have already been compiled, most of the dependencies have already been "baked in" during the building process – which explains why there are only 9 dependencies in this step (instead of the 26 development-related dependencies that appear in my script). Amazingly, all of this requires less than a 1 MB download:

sudo apt-get install libsdl2-2.0-0 libva-wayland1 libluajit-5.1-2 xdotool libcdio-cdda1 libcdio-paranoia1 libdvdread4 libdvdnav4 libbluray1



STEP 4: Install the OpenGL ES (GLES) and EGL files from the official Raspberry GitHub site. These GPU-related files are essential for mpv to function. Since we're installing pre-compiled ".deb" files in this procedure, the compiling has already "baked in" 2 of the 4 GPU-related files – which explains why we only need to download 2 small files in this step:

sudo wget -P /opt/vc/lib https://github.com/raspberrypi/firmware/raw/master/hardfp/opt/vc/lib/libGLESv2.so

sudo wget -P /opt/vc/lib https://github.com/raspberrypi/firmware/raw/master/hardfp/opt/vc/lib/libEGL.so



STEP 5: Install all the programs that my script previously built: Locate the folder that contains all the Debian package files – these ".deb" files might be on a separate thumb drive, or wherever you put them for safe keeping. Then, right-click that folder, select "Open in Terminal", and run the following command. There should be exactly 6 ".deb" files in the folder:

sudo dpkg -i *.deb



STEP 6: This step accomplishes 4 separate things – automatically in one shot with a mini-script! (1) It runs sudo ldconfig so that all "shared libraries" are properly recognized by FFmpeg and mpv; (2) It create mpv's configuration file (mpv.conf); (3) It associates all common video and audio file types with mpv (so that double-clicking them in File Manager will cause mpv to automatically play them); and (4) it "pins" the advanced versions of FFmpeg and mpv so that they won't be wrongly interpreted by the package manager as being "old" and therefore designated for overwritting by the older and more primitive versions in the Raspbian repository.


CRITICAL NOTE: Do you see the little "curly brace" ---> { } <--- at the beginning and end of the following very long block of code? All you have to do is copy everything that appears below and paste it into Terminal and hit Enter. But don't forget to include the curly braces or it will not work!


{
sudo ldconfig


mkdir -p /home/pi/.config/mpv

echo "--fullscreen
rpi-background=yes
screenshot-format=png
ytdl-format=bestvideo[height<=?1080][fps<=?30][vcodec!=?vp9]+bestaudio/best
--alsa-buffer-time=800000" > /home/pi/.config/mpv/mpv.conf


cp /home/pi/.config/mimeapps.list /home/pi/.config/mimeapps.list_BACKUP &> /dev/null

echo "[Added Associations]
video/mp4=mpv.desktop;
video/webm=mpv.desktop;
video/x-matroska=mpv.desktop;
video/mp2t=mpv.desktop;
video/quicktime=mpv.desktop;
video/x-msvideo=mpv.desktop;
video/x-ms-wmv=mpv.desktop;
video/mpeg=mpv.desktop;
audio/x-wav=mpv.desktop;
audio/mpeg=mpv.desktop;
audio/mp4=mpv.desktop;
audio/flac=mpv.desktop;
text/plain=leafpad.desktop;

[Default Applications]
video/mp4=mpv.desktop
video/webm=mpv.desktop
video/x-matroska=mpv.desktop
video/mp2t=mpv.desktop
video/quicktime=mpv.desktop
video/x-msvideo=mpv.desktop
video/x-ms-wmv=mpv.desktop
video/mpeg=mpv.desktop
audio/x-wav=mpv.desktop
audio/mpeg=mpv.desktop
audio/mp4=mpv.desktop
audio/flac=mpv.desktop
text/plain=leafpad.desktop

[Removed Associations]" > /home/pi/.config/mimeapps.list


echo "[Desktop Entry]
Type=Application
Name=MPV
Exec=lxterminal -t mpv_control -e bash -c \"sleep 0.25; xdotool search --name mpv_control windowactivate; mpv %f\"
NoDisplay=true
Icon=mpv" > /home/pi/.local/share/applications/mpv.desktop


sudo cp /etc/apt/preferences /etc/apt/preferences_BACKUP &> /dev/null

echo "Package: ffmpeg
Pin: version 4.0.2-1
Pin-Priority: 1001

Package: mpv
Pin: version 0.29.0-1
Pin-Priority: 1001

Package: x264
Pin: version 0.155-1
Pin-Priority: 1001

Package: fdk-aac
Pin: version 0.1.6-1
Pin-Priority: 1001

Package: mp3lame
Pin: version 3.100-1
Pin-Priority: 1001

Package: libass
Pin: version 0.14.0-1
Pin-Priority: 1001" | sudo cp /dev/stdin /etc/apt/preferences

sudo chmod 644 /etc/apt/preferences
}



STEP 7: Install youtube-dl by running this in Terminal:

sudo pip install --upgrade youtube_dl



STEP 8: REBOOT! When installing mpv for the very first time in this manner, I have found rebooting is necessary for it to perform at its best!






---------
APPENDIX 9: TROUBLESHOOTING:

If you encounter any issues in the future, a good thing to try is to simply re-install all the ".deb" packages that my script created. The entire process takes less than one minute! See Appendix 7 for details.

If mpv generates any "port" or "MMAL" errors, make sure your GPU memory allocation is 128 MB (as indicated in my instructions). If mpv generates a "failed to add service" error, make sure you're not using the experimental desktop GL drivers known as Full KMS and Fake KMS (as indicated in my requirements section). And if you get a "[ytdl_hook] youtube-dl failed" message, it means you probably didn't install youtube-dl (see Appendix 2 for instructions).






---------
APPENDIX 10: TECHNICAL NOTES AND OBSERVATIONS:

DEPENDENCIES: There are only 26 "explicitly" required dependencies in my script. In other words, only 26 software packages are explicitly listed BY NAME in the "sudo apt-get install" stanza. However, some of the 26 dependencies have dependencies of their own that will automatically "come along for the ride". Some of these other dependencies are necessary for my script to compile and build, and some of them are not. Either way, those other dependencies are determined by the maintainers of the official Raspbian repository – not me. Through careful testing, I have identified the other dependencies whose installation is automatically "triggered" by the 26 explicit dependencies. As just one example, I observed that the explicit installation of "automake" automatically triggers the installation of "autoconf". Autoconf is a critical dependency for my script to work, yet I have deliberately NOT included it due to the fact that its installation is automatically triggered by the installation of automake! Two other essential dependencies that I have NOT explicitly listed are libxcb1-dev and libxcb-xfixes0-dev – both of which are automatically installed as a result of installing libsdl2-dev (one of the 26 explicit dependencies). Theoretically, there is some risk in not explicitly requesting more dependencies – because at some point in the future, the repository behavior could change – resulting in critical dependencies not being installed. Nonetheless, my minimalist philosophy considers it "bad form" to explicitly list more dependencies than necessary. The stanza I created, therefore, has been carefully optimized and verified to provide everything the script needs – no more, no less. Of course, since I obviously don't have a crystal ball, it should go without saying that I can only certify the truth of my statements "at the time of their writing"!

WEBM PERFORMANCE: The perfect or near-perfect performance that I'm reporting for 1080p WebM videos is nothing less than astounding when you consider that WebM videos get no help from the Raspberry's GPU! (Among modern video formats, the Raspberry's GPU is only designed to accelerate MP4 video – which is not so bad when you consider the overwhelming popularity of MP4s!) Be aware, however, that for you to achieve my impressive results with "high-complexity" 1080p WebMs – those with lots of movement and detail from frame-to-frame – the Raspberry's tiny CPU must be able to devote as much as 100% of its resources to the video. That means analog audio output, which has at least some impact on the CPU, MAY cause demanding 1080p WebMs to drop frames. I say "may" because I'm admittedly a tough tester. The testing video I use is a music performance filmed entirely from a constantly moving "telescopic multi-axis camera crane" – the kind that takes those amazingly fluid shots where the camera swoops in from high above while simultaneously panning and tilting. The point is, although it's not filming something extremely "computationally intense" like a high-speed car chase with a constantly changing background, the entire "pixel field" is still changing continuously from frame-to-frame. Other 1080p WebM videos – like a newscaster filmed from a perfectly still camera while sitting calmly at a desk – may only require 30% of the CPU! In cases were CPU utilization is under 90 or 95%, use of the analog audio output should have absolutely no effect on the video. Personally, I always use a USB speaker or a USB DAC headphone amp – simply because they produce much higher-quality sound than the analog audio jack, which was never intended for anything beyond basic audio output. Like all standard USB speakers, mine has a built-in sound card that converts the digital audio signals to analog. By using the USB speaker, I'm "off-loading" almost all of the audio-related computation from the CPU to my speaker – which explains why my Raspberry's CPU has always had just enough horsepower – barely – to do an amazing job with even the most demanding 1080p WebM videos! None of this applies to MP4 videos, of course. Thanks to the Raspberry's powerful GPU doing all the heavy lifting, 1080p MP4 video requires only 5% of the CPU's resources – so there's plenty of horsepower left over no matter what audio option you choose! [On a side note, I've had unsatisfying results with Bluetooth audio, which seems to work especially poorly when WiFi is also turned on; this potential conflict makes sense, since both are handled internally by the same chip. All of this has made me even more fond of my USB sound devices!]






---------
THIS PAGE ONLY CONTAINS THE APPENDICES – PLEASE VISIT MY MAIN TUTORIAL AND SCRIPT PAGE:

Build FFmpeg and mpv – Automatically in 54 Minutes!

.
Last edited by RPi_Mike on Sat Sep 08, 2018 2:39 am, edited 3 times in total.

gkreidl
Posts: 5711
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Sun Sep 02, 2018 5:33 am

In my testing, it usually took about 10 seconds from the moment I entered the following command lines until the live TV broadcasts appeared (youtube-dl has to first analyze the stream before it hands it off to mpv, which then buffers and plays it).
You still have not realized that youtube-dl (for extracting the stream URL) runs about 4 seconds faster if you install it using pip.

You'll find a timing comparison in this posting (at the bottom): https://www.raspberrypi.org/forums/view ... 5#p1289651
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

User avatar
RPi_Mike
Posts: 91
Joined: Sat Dec 09, 2017 12:57 am
Location: United States

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Sun Sep 02, 2018 11:06 am

gkreidl wrote:
Sun Sep 02, 2018 5:33 am
You still have not realized that youtube-dl (for extracting the stream URL) runs about 4 seconds faster if you install it using pip.

Looks like someone scrutinized all 16,000 words of my tutorial in a failed attempt to play "gotcha" and say something negative!

And the best he could come up with is the false claim that I could do something in 6 seconds instead of 10 seconds???

Here's the funniest and most ironic part: If only he had looked more carefully at my brand-new script, he would have seen that I am indeed using pip to install youtube-dl! I also mentioned it at the top of Appendix 2, but he clearly missed that as well in his eagerness to disparage my hard work.

To the good readers out there who appreciate my efforts: I'm very conservative in my testing and never exaggerate. Some live streams take closer to 10 seconds to buffer and begin while others are much closer to 5 seconds – like Twitch, for example, which is usually the fastest. Much of the variability is due to the responsiveness of the remote servers and the quality of one's Internet connection – completely external factors that are subject to change from one moment to the next.

gkreidl
Posts: 5711
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Sun Sep 02, 2018 11:55 am

RPi_Mike wrote:
Sun Sep 02, 2018 11:06 am
gkreidl wrote:
Sun Sep 02, 2018 5:33 am
You still have not realized that youtube-dl (for extracting the stream URL) runs about 4 seconds faster if you install it using pip.

Looks like someone scrutinized all 16,000 words of my tutorial in a failed attempt to play "gotcha" and say something negative!

And the best he could come up with is the false claim that I could do something in 6 seconds instead of 10 seconds???

Here's the funniest and most ironic part: If only he had looked more carefully at my brand-new script, he would have seen that I am indeed using pip to install youtube-dl! I also mentioned it at the top of Appendix 2, but he clearly missed that as well in his eagerness to disparage my hard work.

To the good readers out there who appreciate my efforts: I'm very conservative in my testing and never exaggerate. Some live streams take closer to 10 seconds to buffer and begin while others are much closer to 5 seconds – like Twitch, for example, which is usually the fastest. Much of the variability is due to the responsiveness of the remote servers and the quality of one's Internet connection – completely external factors that are subject to change from one moment to the next.
I must admit that I did not re-read the x-thousand words of your tutorial and so I just assumed that you are still using the youtube-dl fake binary instead of using a pip install for two reasons:
10 seconds delay (mentioned by you)
I suggested it quite some time ago and you have been arguing against using the pip method.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

User avatar
RPi_Mike
Posts: 91
Joined: Sat Dec 09, 2017 12:57 am
Location: United States

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Sun Sep 02, 2018 12:59 pm

gkreidl wrote:
Sun Sep 02, 2018 11:55 am
so I just assumed

Thanks for admitting you made a false assumption!

I can't say I'm surprised by any of this, however:

It's inevitable that a high-quality tutorial like mine is going to attract a variety of unprovoked and baseless attacks.

That's the power of jealousy.

seanp25
Posts: 7
Joined: Mon Apr 16, 2012 2:08 pm

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Mon Sep 03, 2018 2:32 pm

Thanks a lot RPi_Mike!

Great tutorial just got even better.

There's a YouTube link also for Sky News UK, which I find works perfectly in 1080p on the RPi3: https://www.youtube.com/watch?v=XOacA3RYrXk

User avatar
RPi_Mike
Posts: 91
Joined: Sat Dec 09, 2017 12:57 am
Location: United States

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Sat Sep 08, 2018 1:19 am

seanp25 wrote:
Mon Sep 03, 2018 2:32 pm
Thanks a lot RPi_Mike!

Great tutorial just got even better.

There's a YouTube link also for Sky News UK, which I find works perfectly in 1080p on the RPi3.

Thanks seanp25!

I like the Sky News link you suggested and have therefore added it to the other news sources in Appendix 4 of my tutorial – "Stream Live Television from around the World".

To the other readers out there: I've already explored the topic of live TV in great detail in Appendix 4, but I'm taking this opportunity to flesh things out even more and add some new material specific to Sky News:

For those who have my new script-based build of FFmpeg and mpv, all you need to do is open Terminal and enter "mpv + URL" to watch any live feed. In other words, if you find a live broadcast you like – such as Sky News via YouTube – just run the following command line:

mpv https://www.youtube.com/watch?v=XOacA3RYrXk

As soon as you do that, mpv and youtube-dl will automatically work together to play the best-quality stream available. In the case of Sky News, that's a high-definition 1080p video feed (1920 x 1080).

But in some cases, you may not want the highest-resolution video. For example:

1: You might have a limited data plan and don't want to burn up your monthly allotment.

2: For whatever reason, either temporarily or permanently, you simply don't have a fast Internet connection.

3: For whatever reason, your connection is not consistently stable.

4: You have a perfectly stable high-speed Internet connection with no data limit – but you wish to "multitask" and do other things while the live feed takes up only a small portion of your screen. Since there's no reason to "hog data" you're not using, you may wish to use the "geometry" technique I describe in Appendix 1 to force the video into the upper-right corner of your screen (or wherever you so choose). For this purpose, a small 144p or 240p video stream would be ideal.

To do any of this, you first need to determine the "format code" for the resolution you want. In the case of Sky News, for example, you would simply enter this into Terminal:

youtube-dl -F https://www.youtube.com/watch?v=XOacA3RYrXk

But to make things even easier for those interested in Sky News, I've already incorporated the proper format codes into the following command lines. They will also record the broadcast for later viewing (placing the .ts video file at /home/pi). Recording is technically an "experimental" feature of mpv with no guarantee – but in my testing so far, it has worked perfectly. If you don't wish to record the stream, simply remove the ending of the command line (the part that begins with "--record-file"):


SKY NEWS – LIVE 24/7 BROADCAST FROM METRO LONDON VIA THE RPI_MIKE SCRIPT BUILD – AVAILABLE RESOLUTIONS AND DATA RATES:


256 x 144
1.4 MB Per Minute

mpv --ytdl-format=91 https://www.youtube.com/watch?v=XOacA3RYrXk --record-file="/home/pi/Sky_News_144p.ts"


426 x 240
2.6 MB Per Minute

mpv --ytdl-format=92 https://www.youtube.com/watch?v=XOacA3RYrXk --record-file="/home/pi/Sky_News_240p.ts"


640 x 360
4.5 MB Per Minute

mpv --ytdl-format=93 https://www.youtube.com/watch?v=XOacA3RYrXk --record-file="/home/pi/Sky_News_360p.ts"


854 x 480
8.6 MB Per Minute

mpv --ytdl-format=94 https://www.youtube.com/watch?v=XOacA3RYrXk --record-file="/home/pi/Sky_News_480p.ts"


1280 x 720
16.2 MB Per Minute

mpv --ytdl-format=95 https://www.youtube.com/watch?v=XOacA3RYrXk --record-file="/home/pi/Sky_News_720p.ts"


1920 x 1080
28.3 MB Per Minute

mpv --ytdl-format=96 https://www.youtube.com/watch?v=XOacA3RYrXk --record-file="/home/pi/Sky_News_1080p.ts"


IMPORTANT NOTES: The only real difference among the above command lines are the 2-digit "format codes" that I've highlighted in red. That code determines the resolution of the H.264 video stream. The output file name for the recorded video is a matter of personal preference (as long as it ends in .ts to indicate it's a "transport stream"). Also, be aware that the per-minute data rates, which are based on my testing, are a general guideline only. They can vary significantly due to the overall "scene complexity" and frame-to-frame motion inside the video. These factors can obviously change from one moment to the next. The higher or lower the complexity and motion, the higher or lower the data rate. The variation can be as much as +/- 50%, but is typically less than 25%.

jappenzeller
Posts: 1
Joined: Wed Sep 12, 2018 4:35 pm

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Wed Sep 12, 2018 4:36 pm

Have you tried compiling ffmpeg with the newtek ndi support? Been trying myself and not having luck. But so far your script has been a huge help and time saver for me.

User avatar
RPi_Mike
Posts: 91
Joined: Sat Dec 09, 2017 12:57 am
Location: United States

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Thu Sep 13, 2018 1:23 am

jappenzeller wrote:
Wed Sep 12, 2018 4:36 pm
Have you tried compiling ffmpeg with the newtek ndi support? Been trying myself and not having luck. But so far your script has been a huge help and time saver for me.

Glad you liked my script!

NDI didn't even exist until almost 2016. While it's true that a small number of bleeding-edge nerds are excited about it for use in building broadcast-grade video production environments, it's also a topic that few on here have even heard of.

While there may be some support for NDI hidden away inside FFmpeg's latest source code, that alone won't get you anywhere. That's because NewTek, the company behind the standard, also has to fully support the ARM architecture upon which the Raspberry is based. Their focus, quite understandably, has been on Intel and AMD-based systems – systems with much greater horsepower than the Raspberry. In fact, year-old postings on NewTek's official website – dated information that may or may not be true anymore – clearly state that NDI only supports the sending of video on ARM-based systems – with no support whatsoever for receiving. But who knows – that fact may have changed just days, weeks, or months ago.

Whatever the case, one thing's for sure – this is a topic in which I have no interest or expertise. It's also an off-topic discussion for this thread. My best advice is to participate at forums.newtek.com and encourage the company to fully support ARM-based systems like the Raspberry. With millions and millions of Raspberries out there, it's in their interest to pursue it.

Even better, NewTek should make a clearly-written tutorial and script like I did that automatically builds a fully functioning NDI system on a Raspberry in 54 minutes or less!

If the company wants NDI to succeed in the highly competitive landscape of technology standards, they better get on the stick and do exactly that.

Suicinivrovich
Posts: 2
Joined: Thu Sep 20, 2018 6:16 pm

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Thu Sep 20, 2018 6:36 pm

@RPI_Mike, When I followed the tutorial and had everything working you had already reached the status of Rockstar to me, and today because of a automated script gone wild and deleting most of my files and messing with the setup I created through the tutorial (not backed up of course, including the deb pkgs...), I made my way here to start following the tutorial again and find that you created an automated script! :shock: :shock: :shock: :shock: :shock:

Man, bless you!!!!!

Just want to thank you and say "keep up the good work" and forget the bad criticism (H8ers gonna h8 :D ) such as font size :lol: .

Thanks and honestly, though I saw that you donated your time, I'd happily send some bucks your way so you can buy a beer or coffee to steer your attention away from those trying to correct spelling or whatever.

Again thanks!

Suicinivrovich
Posts: 2
Joined: Thu Sep 20, 2018 6:16 pm

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Thu Sep 20, 2018 8:40 pm

Hi,
All worked fine and smooth except that for whatever reason mpv dis not compile, failing at the “waf configure” step saying the below:

Code: Select all

Checking for libav* is Libav                                         : no
Checking for Libav/FFmpeg library versions                           : no ('libavutil >= 56.12.100 libavcodec >= 58.16.100 libavformat >= 58.9.100 libswscale >= 5.0.101 libavfilter >= 7.14.100 libswresample >= 3.0.100' not found) 
Unable to find development files for some of the required FFmpeg/Libav libraries. Git master is recommended.
Now ffmpeg has installed with no issues, and
is returning greater versions for all of them I am guessing it is the mpv script that is not able to assess the versions correctly:

Code: Select all

[email protected]:~/Vidware_Build/mpv $ ffmpeg 
ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1+deb9u1) 20170516
  configuration: --prefix=/usr --enable-gpl --enable-nonfree --enable-static --enable-libtheora --enable-libvorbis --enable-omx --enable-omx-rpi --enable-mmal --enable-libxcb --enable-libfreetype --enable-libass --enable-gnutls --disable-opencl --enable-libcdio --enable-libbluray --extra-cflags='-march=armv8-a+crc -mfpu=neon-fp-armv8 -mtune=cortex-a53' --enable-libx264 --enable-libfdk-aac --enable-libmp3lame
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
Ideas?

User avatar
RPi_Mike
Posts: 91
Joined: Sat Dec 09, 2017 12:57 am
Location: United States

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Fri Sep 21, 2018 7:07 am

Suicinivrovich wrote:
Thu Sep 20, 2018 6:36 pm
@RPI_Mike, When I followed the tutorial and had everything working you had already reached the status of Rockstar to me

Sometimes, unfortunately, even a "rockstar" must disappoint a fan with some bad news.


Suicinivrovich wrote:
Thu Sep 20, 2018 6:36 pm
[But] today because of a automated script gone wild and deleting most of my files and messing with the setup I created through the tutorial (not backed up of course, including the deb pkgs...), I made my way here to start following the tutorial again and find that you created an automated script! :shock: :shock: :shock: :shock: :shock:

Man, bless you!!!!!

All worked fine and smooth except that for whatever reason mpv dis not compile, failing at the “waf configure” step saying the below..... I am guessing it is the mpv script that is not able to assess the versions correctly.

NOTE TO THE OTHER READERS: This person is talking about some other "automated script" – NOT MINE – that 'went wild and deleted most of his files and messed with his setup'.

So here's the bad news from the "rockstar": There's no magic trick to fix your problem. By your own admission, some random script 'went wild and deleted a bunch of your files and messed with your setup'.

And no, there's nothing about the mpv portion of my script "that is not able to assess the versions correctly", as you put it. I know this for a fact for one simple reason – my script does NOT assess anything when it comes to FFmpeg or its component libraries! Instead, it's mpv's source code, which comes inside the tarball made by mpv's developers, that does all the assessing. My script merely invokes that process – an invocation that occurred successfully (I know it was successful because the error you report would not have even appeared if this were not the case). And if you're referring to mpv's internal scripting, there's nothing wrong with that either. If FFmpeg and its libraries are presenting themselves in a fully "proper" and unobstructed manner, mpv will find them.

The bottom line is that my entire script is "known good". It has been thoroughly tested – personally by me – on a clean, properly-working copy of Raspbian Stretch. So I can't get into an off-topic back-and-forth that attempts to fix your obviously broken system. All it would do is clutter this thread with scary-looking talk about all kinds of problems and errors. Advanced users who take the time to read through everything would realize it has absolutely nothing to do with my perfectly-working script. But for a beginner who's just scrolling through, it would look horrible and frightening!

One quick thought which comes to mind is that skipping my "Warning #4" – which explicitly states that those who have done my old tutorial must first remove the old versions of FFmpeg and mpv before they proceed – could certainly cause all kinds of weird problems (including mpv getting confused about which version of FFmpeg you have – and all the component libraries, such as libavutil and libavcodec, that come with it).

But I'm not even slightly suggesting that you skipped anything – I'm just tossing that out there. In fact, it's precisely because there are dozens and dozens of things that could be causing your problem – all things that are wrong with your system and not my script – that I'm simply not willing to even speculate about the ultimate "cause" of your problem.

Quite frankly, my best advice is to not waste your time trying to figure things out. Just back up all your personal data and NUKE your system. If you start with a clean, properly-working copy of Raspbian Stretch, my script is guaranteed to work.*

*Is my script really guaranteed to work with absolute metaphysical certitude? No, it is not! Is anything in this world? Nope! For example, just 12 hours ago the Raspberry Pi Foundation could have issued some unusual operating system update that somehow "broke" the source code in FFmpeg or mpv. Nothing in life is guaranteed and I'm certainly not going to re-run my entire script every day to rule out such unlikely possibilities. In this case, however, there's nothing to suggest any such thing occurred.

HSlover
Posts: 3
Joined: Fri Sep 21, 2018 9:54 am

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Fri Sep 21, 2018 9:59 am

Fantastic work @RPi_Mike, I used to do every piece manually without a script.
Thank you for your efforts.
Could you please explain to me the differences between Full and Lite Stretch versions, and why it only works with the full one?
The obtained libmpv could also be used in a Qt5/QML app, like a video player for example?
Thanks.

User avatar
RPi_Mike
Posts: 91
Joined: Sat Dec 09, 2017 12:57 am
Location: United States

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Fri Sep 21, 2018 1:24 pm

HSlover wrote:
Fri Sep 21, 2018 9:59 am
Fantastic work @RPi_Mike, I used to do every piece manually without a script.
Thank you for your efforts.
Could you please explain to me the differences between Full and Lite Stretch versions, and why it only works with the full one?
The obtained libmpv could also be used in a Qt5/QML app, like a video player for example?.

"Lite" Raspbian, as you probably know, is the stripped-down version of the full "desktop" version of Raspbian. It's "command line only" with the GUI ripped out.

It's been more than nine months since I first published my findings, so I can't recall the specific showstoppers I encountered with the lite version — but I know there were several. I freely admit, however, that I didn't make any big effort on that front for one simple reason: I don't personally use the "lite" version and didn't want to waste my time. I'm glad I didn't, by the way — because you're the very first person to ask about it in all this time!

Finally, as for using QT or QML — or anything else — to somehow embed mpv inside a GUI or another app: That would be a big mistake, at least on the Raspberry. Due to the peculiarities of the VideoCore GPU, high-performance video must be fed to the screen as a windowless overlay. Sure, you can force it into a window, but introducing a windowed middleman will slow everything down and defeat the very purpose of hardware acceleration.

Besides, I and many others prefer the unadorned, uncluttered look of "pure" video without a pointless "frame" wrapped around it. It's a feature, not a limitation.

HSlover
Posts: 3
Joined: Fri Sep 21, 2018 9:54 am

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Fri Sep 21, 2018 1:32 pm

RPi_Mike wrote:
Fri Sep 21, 2018 1:24 pm
HSlover wrote:
Fri Sep 21, 2018 9:59 am
Fantastic work @RPi_Mike, I used to do every piece manually without a script.
Thank you for your efforts.
Could you please explain to me the differences between Full and Lite Stretch versions, and why it only works with the full one?
The obtained libmpv could also be used in a Qt5/QML app, like a video player for example?.

"Lite" Raspbian, as you probably know, is the stripped-down version of the full "desktop" version of Raspbian. It's "command line only" with the GUI ripped out.

It's been more than nine months since I first published my findings, so I can't recall the specific showstoppers I encountered with the lite version — but I know there were several. I freely admit, however, that I didn't make any big effort on that front for one simple reason: I don't personally use the "lite" version and didn't want to waste my time. I'm glad I didn't, by the way — because you're the very first person to ask about it in all this time!

Finally, as for using QT or QML — or anything else — to somehow embed mpv inside a GUI or another app: That would be a big mistake, at least on the Raspberry. Due to the peculiarities of the VideoCore GPU, high-performance video must be fed to the screen as a windowless overlay. Sure, you can force it into a window, but introducing a windowed middleman will slow everything down and defeat the very purpose of hardware acceleration.

Besides, I and many others prefer the unadorned, uncluttered look of "pure" video without a pointless "frame" wrapped around it. It's a feature, not a limitation.
Thank you @RPi_Mike, I was asking because I always use the Lite one for a cross compile Qt5 environment... I know you can install raspberrypi-ui-mods to get close to the full desktop...
For QML issue, isn't libmpv capable of zero-copy rendering, without a middleware?
As far as I know, it's one of the key differences between libmpv and libvlc, but I haven't tested it yet.

User avatar
RPi_Mike
Posts: 91
Joined: Sat Dec 09, 2017 12:57 am
Location: United States

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Fri Sep 21, 2018 2:04 pm

HSlover wrote:
Fri Sep 21, 2018 1:32 pm
For QML issue..... but I haven't tested it yet.

I can tell you have some very passionate and specific ideas of your own. But as I'm sure you realize, QML and QT are never once mentioned in my tutorial or script. I'd therefore like to keep things focused and on-topic and not go down an unrelated rabbit hole about the intricacies of GUI programming and what may or may not be possible. (There's actually a separate area in the forums that's specifically dedicated to graphics programming.)

Nonetheless, you're welcome to use my script as the basis for your own experiments and testing. If you do decide to create a new thread, consider taking the time to first develop, validate and write-up a step-by-step tutorial or script that will allow ordinary people to enjoy whatever you achieve.

HSlover
Posts: 3
Joined: Fri Sep 21, 2018 9:54 am

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Fri Sep 21, 2018 2:08 pm

RPi_Mike wrote:
Fri Sep 21, 2018 2:04 pm
HSlover wrote:
Fri Sep 21, 2018 1:32 pm
For QML issue..... but I haven't tested it yet.

I can tell you have some very passionate and specific ideas of your own. But as I'm sure you realize, QML and QT are never once mentioned in my tutorial or script. I'd therefore like to keep things focused and on-topic and not go down an unrelated rabbit hole about the intricacies of GUI programming and what may or may not be possible. (There's actually a separate area in the forums that's specifically dedicated to graphics programming.)

Nonetheless, you're welcome to use my script as the basis for your own experiments and testing. If you do decide to create a new thread, consider taking the time to first develop, validate and write-up a step-by-step tutorial or script that will allow ordinary people to enjoy whatever you achieve.
Thank you, I'll write up my findings ;)

bemused
Posts: 1
Joined: Thu Jul 31, 2014 2:10 am

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Sun Sep 23, 2018 2:30 pm

thanks for sharing your experience and keeping the instructions updated! two related things from my own experiments:
..
  1. if you'd like to use this on a pi zero change your compile flags to

    Code: Select all

     --extra-cflags="-march=armv6zk -mfloat-abi=hard -mfpu=vfp"
    takes ages to compile of course but works fine here
  2. if you'd like to control mpv with c,lua,javascript,python .. you need to compile libmpv as well. use

    Code: Select all

    --enable-shared
    for all dependencies including ffmpeg (instead of --enable-static) and add

    Code: Select all

    --libmpv-shared
    to mpvs waf configure
cheers,
jasper

mikekscholz
Posts: 2
Joined: Wed Sep 26, 2018 5:07 pm

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Mon Oct 01, 2018 4:51 am

OMG... Thank you... Ive been digging, searching, hacking and coding for like 2 weeks, and until now this never popped up in my searches, And just as I start looking into buying a lattepanda so I can just get VLC on a windows based board, I found this. I had omxplayer solutions running okay, but when trying to use my bluetooth headphones by setting output to alsa, suddenly the video speed would be running at like 30x speed and silent and would have keyboard slow it down to zero and back up and then the audio would start playing, then the video would keep hauling at 30x until it caught up with the audio... I almost went to an external bluetooth audio transmitter.... So I reload an image of my current install that had only the most minimal updates for my hyperpixel display and a bluez upgrade compiled from source... and ran your installer.... and when the script finished, it started playing flawlessly, and was automatically playing through my bluetooth headphones without even needing to change any settings!!!.... im pretty sure that yours is the ONLY media player outputting thru bluez-alsa with no dirty hack arounds.... THANK YOU.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 20465
Joined: Sat Jul 30, 2011 7:41 pm

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Thu Oct 04, 2018 9:06 am

Mod: Just deleted the last two posts.

One was a request for help on using this tutorial on a completely different system, the second a complaint from the thread starter about it.

I can absolutely see the second posts point, but its was a bit over the top, so deleted both.

So, for future posters on this thread - Keep it to the subject in hand - building ffmpg on Raspian. Other OS combinations are off topic and will be deleted.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

usable
Posts: 4
Joined: Fri Mar 02, 2018 10:00 am

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Sun Oct 07, 2018 11:04 am

Just signed in to say thank you so much. You are awesome, man! ;) ;) ;)

joural
Posts: 1
Joined: Mon Oct 08, 2018 10:42 am

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Mon Oct 08, 2018 10:49 am

okey, first i have to say thank you, Thank you very much for this script and all the hard work you put into constructing it.
it helped me big time.
I have enquiry as well... i want to use python-mpv, and for it i need libmpv.so
my system is refusing to find it and i cannot find anything useful from google. would you be able to point me right way please?
thank you again

User avatar
RPi_Mike
Posts: 91
Joined: Sat Dec 09, 2017 12:57 am
Location: United States

Re: GIANT UPDATE: Build FFmpeg and mpv – Automatically in 54 Minutes!

Tue Oct 09, 2018 12:30 am

joural wrote:
Mon Oct 08, 2018 10:49 am
okey, first i have to say thank you, Thank you very much for this script and all the hard work you put into constructing it.
it helped me big time.
I have enquiry as well... i want to use python-mpv, and for it i need libmpv.so
my system is refusing to find it and i cannot find anything useful from google. would you be able to point me right way please?
thank you again

Glad you liked my script!

My build of mpv was never intended to provide a "library" for programming languages – be it Python, C, or JavaScript. Though a small number of people may have an interest in this subject, it's well outside the scope of this tutorial and is therefore off topic.

However, let me briefly say this: If you do want that capability, you'll need to modify my script by adding code that specifically compiles libmpv. In fact, a user named "bemused" briefly described that approach just a couple weeks ago on this thread.

Be aware, however, that I have no personal interest in this subject and have therefore not explored or tested this scenario in any way.

Best of luck!
Last edited by RPi_Mike on Tue Oct 09, 2018 4:09 am, edited 1 time in total.

Return to “Graphics, sound and multimedia”

Who is online

Users browsing this forum: jimthedj65 and 9 guests