LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-03-2019, 03:13 PM   #1
kaza
Member
 
Registered: Apr 2010
Distribution: FC17
Posts: 343

Rep: Reputation: 2
ffmpeg desktop grab: audio stutters after few minutes (fc29+KDE)


Hello!

I attempted to grab desktop video+audio using ffmpeg, just like I used to do
long ago (in 2017, since then I updated to fc29, don't remember under what OS
it succeded, maybe fc26).

The problem I'm encountering now: the video is OK, the audio starts OK then, after few minutes
it starts to stutter, then becomes shifted by a VERY LARGE ammount relative to the video then,
I think, it again stutters and shifts more (with different audio encoders it's slightly different)
and finally the the audio ends much earlier than video.

The command I used:

ffmpeg -thread_queue_size 512 -f x11grab -s 1906x1038 -r 25 -i :0.0+14,130 -thread_queue_size 512 -f pulse -ac 2 -i alsa_output.pci-0000_00_14.2.analog-stereo.monitor -acodec pcm_s16le -vcodec libx264 -preset ultrafast sample.avi

and the stuttering started after 9 minutes.

With another audio encoder:

ffmpeg -thread_queue_size 512 -f x11grab -s 1906x1038 -r 25 -i :0.0+14,130 -thread_queue_size 512 -f pulse -ac 2 -i alsa_output.pci-0000_00_14.2.analog-stereo.monitor -acodec ac3 -vcodec libx264 -preset ultrafast sample.avi

the stuttering occured after 5.5 minutes.

With the command:

ffmpeg -f x11grab -s 1906x1038 -r 25 -i :0.0+14,130 -f pulse -ac 2 -i alsa_output.pci-0000_00_14.2.analog-stereo.monitor -acodec libmp3lame -vcodec libx264 -preset ultrafast sample.mkv

the audio stops after 2 minutes.

An attempt to use "-f alsa -i hw:0" instead of "-f pulse" resulted in a "silent movie"
and also, I noticed that the files

/proc/asound/cards
/proc/asound/devices

are empty.

Checking for alsa devices of ffmpeg:

Code:
ffmpeg -devices | grep alsa
DE alsa            ALSA audio output
The alsa-related packages:

Code:
<root localhost.localdomain>.../root>rpm -qa | grep alsa
alsa-lib-1.1.8-1.fc29.i686
qemu-audio-alsa-3.0.0-4.fc29.x86_64
alsa-utils-1.1.8-2.fc29.x86_64
alsa-plugins-pulseaudio-1.1.8-1.fc29.x86_64
wine-alsa-4.4-1.fc29.x86_64
alsamixergui-0.9.0-0.27.rc2.fc29.x86_64
alsa-ucm-1.1.8-1.fc29.noarch
alsa-lib-1.1.8-1.fc29.x86_64
wine-alsa-4.4-1.fc29.i686

<root localhost.localdomain>.../root>rpm -ql alsa-lib-1.1.8-1.fc29.i686  | grep libasound
/lib/libasound.so.2
/lib/libasound.so.2.0.0
And I thought that just writng down the command which worked in 2017 would continue to work...

I "googled" and searched LQ for "ffmpeg" but didn't find anything relevant and RECENT - old
solutions might not work now. Does anyone have an idea why in FC29+KDE the audio grab no longer works
the same as it used to?

TIA,
kaza.
 
Old 05-04-2019, 08:55 AM   #2
kaza
Member
 
Registered: Apr 2010
Distribution: FC17
Posts: 343

Original Poster
Rep: Reputation: 2
Small correction: I erroneously thought that

/proc/asound/cards
/proc/asound/devices

are empty because I did "ls -l" on them and saw size of zero
and when I attempted to open then with an editor I saw nothing.

But when I did "more" I saw that they actually hold content:

Code:
<localhost>.../temp>more /proc/asound/cards
 0 [SB             ]: HDA-Intel - HDA ATI SB
                      HDA ATI SB at 0xfe2f4000 irq 16
 1 [HDMI           ]: HDA-Intel - HDA ATI HDMI
                      HDA ATI HDMI at 0xfe3ec000 irq 26
 2 [SAA7134        ]: SAA7134 - SAA7134
                      saa7134[0] at 0xfebffc00 irq 21
<localhost>.../temp>more /proc/asound/devices
  1:        : sequencer
  2: [ 1- 3]: digital audio playback
  3: [ 1- 0]: hardware dependent
  4: [ 1]   : control
  5: [ 0- 0]: digital audio playback
  6: [ 0- 0]: digital audio capture
  7: [ 0- 1]: digital audio playback
  8: [ 0- 2]: digital audio playback
  9: [ 0- 2]: digital audio capture
 10: [ 0- 0]: hardware dependent
 11: [ 0]   : control
 12: [ 2- 0]: digital audio capture
 13: [ 2]   : control
 33:        : timer
Still can't figure out why using "-f pulse" audio stutters after few minutes and using "-f alsa -i hw:0" (or hw:0,0) results in silence...

TIA,
kaza.
 
Old 05-06-2019, 12:37 AM   #3
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by kaza View Post
Still can't figure out why using "-f pulse" audio stutters after few minutes and using "-f alsa -i hw:0" (or hw:0,0) results in silence...
with alsa it is extremely tricky if not impossible to record the sound that your system actually emanates.
why it's bumpy with pulse - my guess is there's a bottleneck somewhere, maybe pulse is transcoding the sound and then ffmpeg is trying to transcode it again, maybe ffmpeg is too busy transcoding-on-the-fly thevideo and gives up on the sound ... who knows.

maybe ffmpeg has a verbose flag (actually i know it has and it can be fine-tuned if you know what you're looking for) to get more output, maybe pulseaudio logs something too.

maybe you should start from scratch: make a web search for how to do what you want to do, make sure the results are current - maybe it's a slightly different command?
 
Old 05-06-2019, 04:07 PM   #4
kaza
Member
 
Registered: Apr 2010
Distribution: FC17
Posts: 343

Original Poster
Rep: Reputation: 2
Hi ondoho, thanks for the reply.

I'll stop attempts to use ALSA and will concentrate on "Pulse".
I used video output format of AVI as I thought it'll be less CPU-intensive
compared with MP4, although "-vcodec libx264" might add some CPU-load.

Now, after specifically searching for lowest CPU usage for ffmpeg
I found a suggested command:

ffmpeg -y -framerate 25 -video_size 1280x1024 -f x11grab -i :0.0 -c:v libx264rgb \
-crf 0 -preset ultrafast temp.mp4

I'll try using the libx264rgb instead of libx264.

Thanks,
kaza.
 
  


Reply



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
fc26 -> fc29 (KDE): how to decrease horizontal space between desktop icons? kaza Fedora 2 03-13-2019 12:51 PM
audio CD playback is constantly buffering/stutters (Mplayer) kiebitz 4MLinux 10 04-25-2018 07:52 AM
Sound problems in Kubuntu droped audio and stutters Paladin60 Ubuntu 5 04-17-2015 12:36 AM
Audio (Rhythmbox, Totem) fails after a few minutes. bagley Ubuntu 3 11-02-2010 05:02 PM
smplayer: video+audio stutters with pulseaudio, audio files play fine GamerX Linux - Desktop 1 02-06-2009 08:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:54 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