Using ffmpeg to record what comes from the web browser

Technical issues/questions of an intermediate or advanced nature.
Kulle
Warlord
Warlord
Posts: 591
Joined: 28 Jan 2017, 10:39
Distribution: v4.0 64bit Xfce
Location: Berlin

Re: Using ffmpeg to record what comes from the web browser

Post#16 by Kulle » 06 Feb 2019, 14:35

Hi Donald,
The last step (In Volume Control: click the device and select Monitor of ...) costs time.
It is better, everything on the command line:

Code: Select all

ffmpeg -f pulse -i alsa_output.pci-0000_00_1b.0.analog-stereo.monitor -c:a libmp3lame output.mkv
I found that here:
https://ask.fedoraproject.org/en/questi ... mmandline/
PS
I had already used ffplay, but I did not know the many options yet.
Many Thanks

donald
Full of knowledge
Full of knowledge
Posts: 2061
Joined: 17 Jun 2013, 13:17
Distribution: Porteus 3.2.2 XFCE 32bit
Location: Germany

Re: Using ffmpeg to record what comes from the web browser

Post#17 by donald » 06 Feb 2019, 22:25

The last step ...... costs time.
Kulle, the settings in the pulseaudio mixer (record tab) only have to be made once.
It stays that way, you do not have to do it again and again..

The record tab is empty until you actually record something.
The "Monitor of..." setting is retained.

EDIT
You could add some quality/bitrate options if you encode to mp3 format.
( output.mp3 not mkv )
https://trac.ffmpeg.org/wiki/Encode/MP3

or even better, record as wav format and convert it to mp3 later.
Use lame; see lame --help and lame --longhelp
Lame offers more options to get "better" sounding mp3 files.

Example:

Code: Select all

lame -m s -b 256 --strictly-enforce-ISO -q 2 ./music.wav music.mp3

raja
Shogun
Shogun
Posts: 434
Joined: 02 May 2017, 09:51
Distribution: v3.2.2-32 and Porteus-Artix-64
Location: Chennai,India

Re: Using ffmpeg to record what comes from the web browser

Post#18 by raja » 11 Feb 2019, 17:53

This is a bit cumbersome procedure to make clean audio/video capture, which does not require much editing. Audio streams can be recorded using Audacious (Porteus 4.0)or VLC as they have , "Record" function. Straight forward and easy, if the Players work as intended. Both work for me.

For Video capture, Simple screen recorder, is the best, easy and simple. In Porteus 4.0, I tested by activating dependencies separately, and Screen Recorder works fine, using installed FFMPEG and Pulse Audio server. I didn't merge and forgot to untick "save session" during shut down. All those separate modules kept in a directory get activated on boot. No issues on that.

But, after merging and building a single module I, tested in Neko's Cinnamon. It does its job ,but Video frames are jumping, audio is perfect. Any suggestions?

Tried in old Porteus 4.0rc4. Pulse audio server not working. Jack and Alsa too fail.

jss or others who have a developer setup, may try to compile a "SSR" module,using his qt5 and current ffmpeg and current libraries installed in Porteus 4.0.
Linux Kernel-4.4.272 -32 bit; Linux Kernel-5.4.185 - 64 bit

Kulle
Warlord
Warlord
Posts: 591
Joined: 28 Jan 2017, 10:39
Distribution: v4.0 64bit Xfce
Location: Berlin

Re: Using ffmpeg to record what comes from the web browser

Post#19 by Kulle » 14 Feb 2019, 16:41

Hi raja,
The Natural-Reader can speak:
https://www.naturalreaders.com/online/

If I want to record such spoken text (for example, as an mp3 file),
then I have to use the cumbersome procedure discussed above.
I tried: Audacious and VLC are not working in this case

User avatar
francois
Contributor
Contributor
Posts: 6433
Joined: 28 Dec 2010, 14:25
Distribution: xfce plank porteus nemesis
Location: Le printemps, le printemps, le printemps... ... l'hiver s'essoufle.

Re: Using ffmpeg to record what comes from the web browser

Post#20 by francois » 27 Feb 2019, 03:37

@donald:
Just reread the thread. Your suggestion of using youtube-dl
youtube-dl github
and as I have found by browsing on the subject youtube-dl-gui
https://github.com/MrS0m30n3/youtube-dl-gui
is quite interesting.

Would you have a ffmpeg syntax to download 360 videos or google-VR videos?

An encoding tool:
https://headjack.io/blog/best-encoding- ... vr-videos/

But I am looking for downloading tool. :(
Prendre son temps, profiter de celui qui passe.

donald
Full of knowledge
Full of knowledge
Posts: 2061
Joined: 17 Jun 2013, 13:17
Distribution: Porteus 3.2.2 XFCE 32bit
Location: Germany

Re: Using ffmpeg to record what comes from the web browser

Post#21 by donald » 27 Feb 2019, 08:49

@francois
--> youtube-dl-gui <--
Hmmm...this tool is written in python..
You need Python and wxpython to make it run with stock porteus 4
( I did only test if it runs, not if it does its job )
However, these 2 modules sum up to 30 MB -- much to much to just run a Gui
for a tool (youtube-dl) which work fine in a terminal.(imo)
(The basic syntax is not too complicated)

EDIT
Ooops....I forgot that you need python to run youtube-dl -- so wxpython
adds "only" 13 MB.

--> 360 videos or google-VR videos <--
Please post a link to such a video so I can test if youtube-dl is able
to download it.

User avatar
francois
Contributor
Contributor
Posts: 6433
Joined: 28 Dec 2010, 14:25
Distribution: xfce plank porteus nemesis
Location: Le printemps, le printemps, le printemps... ... l'hiver s'essoufle.

Re: Using ffmpeg to record what comes from the web browser

Post#22 by francois » 28 Feb 2019, 18:33

Finally, I have tried the youtube-dl command line software, easy to install under nemesis. According to:
https://medium.com/@egowrap/how-to-down ... 2165cf9f31

Code: Select all

youtube-dl -f 266+22 https://www.youtube.com/***whatever-the-link-to-the-video-of-interest***
There might be better ways of doing it, but I am not sure. I will have to test the result. It seems that vlc 3.x or linux 360° video player from GoPro, will run such files. I have not achieved to install eithere. Or simply, I will test it on my moto G z-2 phone, which I will do as soon as I get the time.

Surfing in Tahiti under the wave:
https://www.youtube.com/watch?v=MKWWhf8 ... dex=8&t=0s
Prendre son temps, profiter de celui qui passe.

User avatar
francois
Contributor
Contributor
Posts: 6433
Joined: 28 Dec 2010, 14:25
Distribution: xfce plank porteus nemesis
Location: Le printemps, le printemps, le printemps... ... l'hiver s'essoufle.

Re: Using ffmpeg to record what comes from the web browser

Post#23 by francois » 06 Mar 2019, 03:14

Some works other not:

Code: Select all

[fl@fl-pc ~]$ youtube-dl -f 266+22 https://www.youtube.com/watch?v=VrlVvTbsl1A&list=PLLwK9lVCH0HHyo4RKpWUZ4HuReUDmB3D2&index=5
[1] 11530
[2] 11531
[fl@fl-pc ~]$ [youtube] VrlVvTbsl1A: Downloading webpage
[youtube] VrlVvTbsl1A: Downloading video info webpage
ERROR: requested format not available
Prendre son temps, profiter de celui qui passe.

donald
Full of knowledge
Full of knowledge
Posts: 2061
Joined: 17 Jun 2013, 13:17
Distribution: Porteus 3.2.2 XFCE 32bit
Location: Germany

Re: Using ffmpeg to record what comes from the web browser

Post#24 by donald » 06 Mar 2019, 05:12

ERROR: requested format not available
use youtube-dl -F
to get an overview of which formats are available.
also youtube-dl -F --no-playlist can be useful if the video is buried in a playlist.

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Re: Using ffmpeg to record what comes from the web browser

Post#25 by Rava » 06 Mar 2019, 12:06

francois wrote:
06 Mar 2019, 03:14
Some works other not:
Have you tried https://9xbuddy.app on the ones that did not work?
Interestingly enough there are some YouTube videos that claim I need to be logged in to watch but I can download all these via 9xbuddy.
But you have to choose the "alternate" Link. For some reason the original 9xbuddy Link for YouTube is broken and only downloads 96kb and not e.g. 55 MB for the Video Clip. ..

E.g. choose "Alternate - 720p" instead of "High 720p" or "Original 720p".

HTH.
Cheers!
Yours Rava

User avatar
francois
Contributor
Contributor
Posts: 6433
Joined: 28 Dec 2010, 14:25
Distribution: xfce plank porteus nemesis
Location: Le printemps, le printemps, le printemps... ... l'hiver s'essoufle.

Using ffmpeg to record what comes from the web browser

Post#26 by francois » 13 Mar 2019, 00:59

@donald and rava:
Are we talking about 360 o videos or google vr videos or regular ones?

Thanks.
Prendre son temps, profiter de celui qui passe.

donald
Full of knowledge
Full of knowledge
Posts: 2061
Joined: 17 Jun 2013, 13:17
Distribution: Porteus 3.2.2 XFCE 32bit
Location: Germany

Using ffmpeg to record what comes from the web browser

Post#27 by donald » 13 Mar 2019, 08:01

I am talking about this post by you:
francois wrote:
06 Mar 2019, 03:14
Some works other not:

Code: Select all

[fl@fl-pc ~]$ youtube-dl -f 266+22 https://www.youtube.com/watch?v=VrlVvTbsl1A&list=PLLwK9lVCH0HHyo4RKpWUZ4HuReUDmB3D2&index=5
[1] 11530
[2] 11531
[fl@fl-pc ~]$ [youtube] VrlVvTbsl1A: Downloading webpage
[youtube] VrlVvTbsl1A: Downloading video info webpage
ERROR: requested format not available
You wanted to combine 2 files (format code 266+22).
and youtube-dl tells you that (one of) the requested format is not available.
These format codes are not standarized, each site can use its own.
To find out which formats are available use youtube-dl -F
Example - your video:

Code: Select all

guest@porteus:~/Downloads$ youtube-dl -F https://www.youtube.com/watch?v=VrlVvTbsl1A&list=PLLwK9lVCH0HHyo4RKpWUZ4HuReUDmB3D2&index=5
[1] 1561
[2] 1562
[2]+  Done                    list=PLLwK9lVCH0HHyo4RKpWUZ4HuReUDmB3D2
guest@porteus:~/Downloads$ [youtube] VrlVvTbsl1A: Downloading webpage
[youtube] VrlVvTbsl1A: Downloading video info webpage
[info] Available formats for VrlVvTbsl1A:
format code  extension  resolution note
249          webm       audio only DASH audio   52k , opus @ 50k, 1.48MiB
250          webm       audio only DASH audio   71k , opus @ 70k, 1.87MiB
140          m4a        audio only DASH audio  128k , m4a_dash container, mp4a.40.2@128k, 3.87MiB
171          webm       audio only DASH audio  129k , vorbis@128k, 3.63MiB
251          webm       audio only DASH audio  138k , opus @160k, 3.76MiB
278          webm       256x144    144s  101k , webm container, vp9, 30fps, video only, 2.95MiB
160          mp4        256x144    144s  115k , avc1.4d400c, 30fps, video only, 3.39MiB
242          webm       424x240    240s  229k , vp9, 30fps, video only, 6.75MiB
133          mp4        424x240    240s  250k , avc1.4d4015, 30fps, video only, 7.43MiB
243          webm       640x360    360s  426k , vp9, 30fps, video only, 12.47MiB
134          mp4        640x360    360s  644k , avc1.4d401e, 30fps, video only, 19.01MiB
244          webm       852x480    480s  778k , vp9, 30fps, video only, 22.91MiB
135          mp4        852x480    480s 1172k , avc1.4d401f, 30fps, video only, 35.20MiB
247          webm       1280x720   720s 1546k , vp9, 30fps, video only, 45.78MiB
136          mp4        1280x720   720s 2344k , avc1.4d401f, 30fps, video only, 69.94MiB
248          webm       1920x1080  1080s 2713k , vp9, 30fps, video only, 80.32MiB
137          mp4        1920x1080  1080s 4481k , avc1.640028, 30fps, video only, 129.05MiB
271          webm       2560x1280  1440s 7959k , vp9, 30fps, video only, 237.84MiB
264          mp4        2560x1280  1440s 9291k , avc1.640032, 30fps, video only, 259.01MiB
18           mp4        640x360    medium , avc1.42001E, mp4a.40.2@ 96k, 21.35MiB
43           webm       640x360    medium , vp8.0, vorbis@128k, 27.06MiB
22           mp4        1280x720   hd720 , avc1.64001F, mp4a.40.2@192k (best)

[1]+  Done                    youtube-dl -F https://www.youtube.com/watch?v=VrlVvTbsl1A
guest@porteus:~/Downloads$ 
No format code 266 - select something else and adjust your command accordingly.

btw
I downloaded the 22-format, which does not have the highest resolution, but contains sound.
VLC > 3.x.x (I don't remember the exact version) did play this video
with panoramic view.

User avatar
francois
Contributor
Contributor
Posts: 6433
Joined: 28 Dec 2010, 14:25
Distribution: xfce plank porteus nemesis
Location: Le printemps, le printemps, le printemps... ... l'hiver s'essoufle.

Using ffmpeg to record what comes from the web browser

Post#28 by francois » 15 Mar 2019, 00:03

Great! I will look at it this weekend. This is français to me (a comparison to the absurd, I should have written chineese, but I did not want to be racist).

Thanks so much.
Prendre son temps, profiter de celui qui passe.

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Using ffmpeg to record what comes from the web browser

Post#29 by Rava » 23 Sep 2022, 03:49

donald wrote:
09 Jan 2018, 09:19
How to get the exact size and coordinates of a specific window I want to capture:
My approach is doing a screenshot of the whole desktop and opening that screenshot in mtpaint, and using "make selection" to create a rectangle selection. mtpaint then tells me in the bottom right area of its status bar the X/Y offset and the width/height of the selection.
See my edited screenshot as example:
Image
This means the rectangle selection is 318x156 with an X offset of 1148 pixels and a Y offset of 775 pixels.

Added in 7 minutes 11 seconds:
francois wrote:
15 Mar 2019, 00:03
This is français to me (a comparison to the absurd, I should have written chineese, but I did not want to be racist).
In German we have the non-racist saying of "Ich verstehe nur Bahnhof" - literally translated "I only understand train station" - it refers to the older grand halls of main train stations with enormous echo where an announcement via PA was often hard to understand.

Added in 7 minutes 28 seconds:
donald wrote:
09 Jan 2018, 09:19
ffmpeg -f alsa -ac 2 -i pulse -f x11grab -r 25 -s 1360x768 -i :0.0 -vcodec libx264 -preset ultrafast output.mkv
How does one define the running time of the recording?
Would pressing Ctrl+C save the recorded video or would Ctrl+C discard the recording?
EDIT
Ctrl+C will save the recorded video okay.


Added in 38 minutes 26 seconds:
See also here about using this approach and my issues with the sound:
Desktop screen recorder *with* *sound* (Post by Rava #90154)
Rava wrote:
23 Sep 2022, 01:58
beep is a script that plays a short notification sound.
I used this:

Code: Select all

sleep 10;beep;ffmpeg -f alsa -ac 2 -i pulse -f x11grab -r 25 -s 1088x608 -i :0.0+409,254 -vcodec libx264 -preset ultrafast L+B_2022-09-22.mkv
While it did work, the sound is faint and noisy. When I do the recording without anything of sound or music played on my PC there is still the same background noise, similar to as if the ffmpeg would record the PCs fan or such, or the faint sound of a server running (not that I have one in my home, the recorded background noise just reminded me of that).
Is there a way to better the sound quality? E.g. make it less faint and omit the background noise?
Cheers!
Yours Rava

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Using ffmpeg to record what comes from the web browser

Post#30 by Rava » 24 Sep 2022, 03:56

Just as heads up.

In the other thread M. Eerie had the brilliant tip for me so I share it here for folks looking to download similar blob videos.
M. Eerie wrote:
23 Sep 2022, 08:33
Rava wrote:
22 Sep 2022, 09:34
Or does anyone know a method to download blob:https:// streams?
Assuming this is what you want to achieve:
This answer has worked for me so far.

Once you get the .m3u8 it's just a matter of yt-dlp <link>
My answer included a short HOWTO taken from the link he provided:
Rava wrote:
23 Sep 2022, 16:05
M. Eerie wrote:
23 Sep 2022, 08:33
Assuming this is what you want to achieve:
This answer has worked for me so far.
Indeed it is. :Rose: :friends:

Just a small repeat of how it's done.
Open the console with F12
Reload the page where the video is, maybe start the video when it is not started by itself.
Go in the console to "network" and look for m3u8
The corresponding URL to that m3u8 appears on the right side of the console. Copy that URL.
I choose the 1st URL that had m3u8 in it and gave that to yt-dlp and it worked.

[…]
For the rest of the post go to the other thread if you are interested: Desktop screen recorder *with* *sound*
Cheers!
Yours Rava

Post Reply