LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 06-18-2012, 04:19 PM   #1
lord_didger
Member
 
Registered: Jun 2005
Location: Poland
Distribution: Debian
Posts: 106

Rep: Reputation: 15
ffmpeg can't record desktop + sound


Sound in linux is obscure to me. I try to record my desktop + sound from applications running. So far I found I should use something like this
Code:
ffmpeg -f x11grab -s "1920x1080" -r "24" -i :0.0+0,0 -f alsa -ac 2 -i hw:0 -acodec libmp3lame -ab 64 -threads 8 -qscale 5 -b 1024 -ar 44100 -f flv test.out
looks like it records all I need
Code:
ffmpeg version 0.8.3-6:0.8.3-1, Copyright (c) 2000-2012 the Libav developers
  built on Jun  9 2012 13:36:42 with gcc 4.7.0
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
[x11grab @ 0x2474320] device: :0.0+0,0 -> display: :0.0 x: 0 y: 0 width: 1920 height: 1080
[x11grab @ 0x2474320] shared memory extension  found
[x11grab @ 0x2474320] Estimating duration from bitrate, this may be inaccurate
Input #0, x11grab, from ':0.0+0,0':
  Duration: N/A, start: 1340053863.559315, bitrate: 1592524 kb/s
    Stream #0.0: Video: rawvideo, bgra, 1920x1080, 1592524 kb/s, 24 tbr, 1000k tbn, 24 tbc
[alsa @ 0x24873a0] Estimating duration from bitrate, this may be inaccurate
Input #1, alsa, from 'hw:0':
  Duration: N/A, start: 3868.378728, bitrate: N/A
    Stream #1.0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
File 'test.out' already exists. Overwrite ? [y/N] y
Incompatible pixel format 'bgra' for codec 'flv', auto-selecting format 'yuv420p'
[buffer @ 0x2497600] w:1920 h:1080 pixfmt:bgra
[avsink @ 0x24977a0] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'out'
[scale @ 0x249b260] w:1920 h:1080 fmt:bgra -> w:1920 h:1080 fmt:yuv420p flags:0x4
Output #0, flv, to 'test.out':
  Metadata:
    encoder         : Lavf53.21.0
    Stream #0.0: Video: flv, yuv420p, 1920x1080, q=2-31, 1 kb/s, 1k tbn, 24 tbc
    Stream #0.1: Audio: libmp3lame, 44100 Hz, 2 channels, s16, 1 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #1.0 -> #0.1
Press ctrl-c to stop encoding
[alsa @ 0x24873a0] ALSA buffer xrun.
^Cframe=   94 fps= 24 q=5.0 Lsize=    3930kB time=3.87 bitrate=8328.4kbits/s dup=0 drop=9    
video:3911kB audio:15kB global headers:0kB muxing overhead 0.104241%
Received signal 2: terminating.
but in the end there is no sound in the output. I have pulse installed to test if it helps ('-i pulse'); no succeed. I have no loopbacks set cause I don't know if I need one and how to do that.

Any hint'd be appreciated
 
Old 06-18-2012, 09:30 PM   #2
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,137
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
Code:
-f alsa -ac 2 -i hw:0
Are sure that's the correct alsa device?
Have you checked to see if your sound card has capturing output disabled in the hardware? Some sound devices like Intels and Nvidias have that disabled. You can get around it by jumping a cable from output to line in.

Code:
-ab 64
That should be 64k.

Code:
-qscale 5 -b 1024
You are doing q scale and then specifying a fixed bitrate. Either qscale 5 or -b 1024k

Code:
Stream #0.0: Video: flv, yuv420p, 1920x1080, q=2-31, 1 kb/s, 1k tbn, 24 tbc
    Stream #0.1: Audio: libmp3lame, 44100 Hz, 2 channels, s16, 1 kb/s
1kb/s might not be enough to hear anything.
 
Old 06-19-2012, 04:10 AM   #3
lord_didger
Member
 
Registered: Jun 2005
Location: Poland
Distribution: Debian
Posts: 106

Original Poster
Rep: Reputation: 15
Quote:
Are sure that's the correct alsa device?
I believe yes.
Code:
$ cat /proc/asound/cards 
 0 [Intel          ]: HDA-Intel - HDA Intel
                      HDA Intel at 0xf7ff8000 irq 50
 1 [NVidia         ]: HDA-Intel - HDA NVidia
                      HDA NVidia at 0xfbe7c000 irq 17
$ cat /proc/asound/pcm 
00-00: VT1828S Analog : VT1828S Analog : playback 1 : capture 2
00-01: VT1828S Digital : VT1828S Digital : playback 1 : capture 1
00-02: VT1828S HP : VT1828S HP : playback 1
01-03: HDMI 0 : HDMI 0 : playback 1
01-07: HDMI 0 : HDMI 0 : playback 1
01-08: HDMI 0 : HDMI 0 : playback 1
01-09: HDMI 0 : HDMI 0 : playback 1
I followed your suggestions concerning -ab -qscale. Presence of -qscale seems have no impact on sound. I added 'k' to -ab and -b and sound is better.

Although sound is present, it is low quality (bassless) and very silent. It look like I didn't hear the sound yesterday cause I worked with my headphones.

To record I use now
Code:
$ ffmpeg -f x11grab -s 1920x1080 -r 24 -i :0.0+0,0 -f alsa -ac 2 -i hw:0 -acodec libmp3lame -ab 192k -threads 8 -b 4096k -ar 44100 -f flv test.out
ffmpeg version 0.8.3-6:0.8.3-1, Copyright (c) 2000-2012 the Libav developers
  built on Jun  9 2012 13:36:42 with gcc 4.7.0
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
[x11grab @ 0x2641320] device: :0.0+0,0 -> display: :0.0 x: 0 y: 0 width: 1920 height: 1080
[x11grab @ 0x2641320] shared memory extension  found
[x11grab @ 0x2641320] Estimating duration from bitrate, this may be inaccurate
Input #0, x11grab, from ':0.0+0,0':
  Duration: N/A, start: 1340096864.961893, bitrate: 1592524 kb/s
    Stream #0.0: Video: rawvideo, bgra, 1920x1080, 1592524 kb/s, 24 tbr, 1000k tbn, 24 tbc
[alsa @ 0x26543a0] Estimating duration from bitrate, this may be inaccurate
Input #1, alsa, from 'hw:0':
  Duration: N/A, start: 4518.767438, bitrate: N/A
    Stream #1.0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
Incompatible pixel format 'bgra' for codec 'flv', auto-selecting format 'yuv420p'
[buffer @ 0x2664600] w:1920 h:1080 pixfmt:bgra
[avsink @ 0x26647a0] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'out'
[scale @ 0x266a540] w:1920 h:1080 fmt:bgra -> w:1920 h:1080 fmt:yuv420p flags:0x4
Output #0, flv, to 'test.out':
  Metadata:
    encoder         : Lavf53.21.0
    Stream #0.0: Video: flv, yuv420p, 1920x1080, q=2-31, 4096 kb/s, 1k tbn, 24 tbc
    Stream #0.1: Audio: libmp3lame, 44100 Hz, 2 channels, s16, 4096 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #1.0 -> #0.1
Press ctrl-c to stop encoding
^Cframe=  375 fps= 24 q=31.0 Lsize=    8995kB time=15.73 bitrate=4685.6kbits/s dup=0 drop=1    
video:8365kB audio:614kB global headers:0kB muxing overhead 0.173481%
Received signal 2: terminating.
What can I do to improve the sound?
 
Old 06-19-2012, 04:21 AM   #4
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 647

Rep: Reputation: 189Reputation: 189
I would record in an uncompressed format first, then reencode compressing video+audio.
You can try ffv1 as uncompressed video codec and pcm_s16le as uncompressed audio codec using avi as container.
After the recording finishes, you can recompress everything using your favorite formats.

Last edited by 414N; 06-19-2012 at 04:23 AM.
 
Old 06-19-2012, 05:19 AM   #5
lord_didger
Member
 
Registered: Jun 2005
Location: Poland
Distribution: Debian
Posts: 106

Original Poster
Rep: Reputation: 15
FUCK!!! I realized why now there is any sound at all and yesterday there wasn't. My microphone within headphones recorded the audio!!!

In fact recording audio from my desktop doesn't work. The problem remains. What shell I do?
 
  


Reply

Tags
ffmpeg



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using FFmpeg to record from TV Card - Video is OK but no audio linux-freak Linux - General 1 01-07-2012 12:55 PM
recording desktop with ffmpeg tchino Linux - Newbie 6 04-29-2011 03:41 PM
how to record with ffmpeg evaristegalois Linux - Software 1 09-07-2006 06:58 PM
Xandros delux 2.0 When I try to run Sound server Control ,Media Player & Sound Record Jesta Linux - Distributions 0 05-15-2004 09:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 10:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration