You are not logged in.

#1 2010-11-26 11:00:07

ChemBro
Member
Registered: 2008-10-22
Posts: 703

ffmpeg records video only, no audio

I'm trying to record my desktop (or single programs) with ffmpeg. The video quality is okay (would be better, if I had a better pc, I guess), but somehow, I cannot record any audio. I did it with

$ ffmpeg -s 1280x1024 -r 30 -f x11grab -i :0.0 -acodec libmp3lame -ab 128k -vcodec mpeg4 -sameq -y testtestaudio.mp4

or

$ ffmpeg -s 1280x1024 -r 30 -f x11grab -i :0.0 -acodec libfaac -ab 128k -vcodec mpeg4 -sameq -y testtestaudio.mp4

but I always get a result like that:

video:9956kB audio:0kB global headers:0kB muxing overhead 0.036333%

which means, that ffmpeg didn't record the audio output.

I don't know where to start to get the audio problem fixed. Has anyone a similiar problem or does someone know, why it does not record? Do you need any more information from me?

Offline

#2 2010-11-26 11:19:57

hume's doona
Member
Registered: 2009-12-11
Posts: 206

Re: ffmpeg records video only, no audio

I might be wrong, but I think you have to specify audio source like alsa or pulse. It's been a while since I did it though.

Offline

#3 2010-11-26 11:47:14

hume's doona
Member
Registered: 2009-12-11
Posts: 206

Re: ffmpeg records video only, no audio

yep, try with "-i pulse" or similar with the audio

Offline

#4 2010-11-26 11:48:25

Darksoul71
Member
Registered: 2010-04-12
Posts: 319

Re: ffmpeg records video only, no audio

I had the same issue when recording games within X11. No matter what I tried...I was unable to record sound. I found rec (from SOX) working nicely though.
I "solved" my issue by writting a simple shell script which first launches rec in the background, then starts ffmpeg for X11 recording and automatically muxes the streams afterwards. I can post the script this evening if you like.


My archlinux x86_64 host:
AMD E350 (2x1.6GHz) / 8GB DDR3 RAM / GeForce 9500GT (passive) / Arch running from 16GB USB Stick

Offline

#5 2010-11-26 12:02:13

hume's doona
Member
Registered: 2009-12-11
Posts: 206

Re: ffmpeg records video only, no audio

you could also try pure audio, assuming you have pulse

$ffmpeg -f alsa -ac 2 -i pulse test_pure_audio.mp3

adding output options i you want better quality

I think if you use pure alsa, it only records from mic, not internal sound [i vaguely remember that being why I installed pulse] maybe someone else can clear that up

Offline

#6 2010-11-26 12:40:15

ChemBro
Member
Registered: 2008-10-22
Posts: 703

Re: ffmpeg records video only, no audio

@Darksoul71: Thanks, I'll ask for it, if everything fails.

@hume's doona: You might be right with pulse. Alsa didn't record anything. I try it with pulse later (on an other system, because my "main" system has some problems with pulseaudio in general, might be, because KDE [4.5] doesn't like pulse).

Offline

#7 2010-11-26 13:38:46

Darksoul71
Member
Registered: 2010-04-12
Posts: 319

Re: ffmpeg records video only, no audio

ChemBro, feel free to send me an e-mail if nothing helps. I remember that even when using rec from SOX it was very important to use the right switch in the ALSA mixer. I guess it was something like recmix source ?

May be you simply need to enable a switch or crank up a certain mixer ?

I guess in the first place hume's doona is right: Try to record solely audio first before heading on with desktop recording.


My archlinux x86_64 host:
AMD E350 (2x1.6GHz) / 8GB DDR3 RAM / GeForce 9500GT (passive) / Arch running from 16GB USB Stick

Offline

#8 2010-11-27 12:24:37

ChemBro
Member
Registered: 2008-10-22
Posts: 703

Re: ffmpeg records video only, no audio

I tried to record audio only in Kubuntu, because they have PulseAudio enabled by default and I can't get PulseAudio working in my testing system (with KDE 4.6 --> no sound at all). I did  it with

ffmpeg -f alsa -ac 2 -i pulse -acodec libmp3lame -ab 128k sometestfile.mp3

No error message, but the resulting audio-file doesn't have any sound. :-/

I don't get PulseAudio and I don't get ffmpeg recording no sound.


I wish, there was an option the record programs with video and audio like glc does it with OpenGL/ALSA programs, besides the workaround from Darksoul71.

Offline

#9 2010-11-27 23:32:00

Darksoul71
Member
Registered: 2010-04-12
Posts: 319

Re: ffmpeg records video only, no audio

I already sended ChemBro my script via e-mail but it might be also interesting for someone of you:

# -V0 means verbosity level 0 for the rec command of SOX.
/usr/bin/rec /home/hb/t_game.wav -V0 &
/usr/bin/ffmpeg -f x11grab -y -r 15 -s 864x640  -i :0.0 -vcodec huffyuv /home/hb/t_game.avi
#/usr/bin/ffmpeg -f x11grab -y -r 15 -s 688x544  -i :0.0 -vcodec huffyuv /home/hb/t_game.avi
#/usr/bin/ffmpeg -f x11grab -y -r 15 -s 688x544  -i :0.0 -vcodec mjpeg /home/hb/t_game.avi
# Do a hard kill for rec after ffmpeg's X11 recording session has ended
killall /usr/bin/rec
/usr/bin/mencoder -ovc copy -oac copy -audiofile /home/hb/t_game.wav -o /home/hb/game.avi /home/hb/t_game.avi
rm /home/hb/t_game.avi
rm /home/hb/t_game.wav

You have of course to adjust the output path for audio and video. I couldn´t make rec really "silent" and you´ll see the volume meter being written to the console. Not nice but it works....:D


My archlinux x86_64 host:
AMD E350 (2x1.6GHz) / 8GB DDR3 RAM / GeForce 9500GT (passive) / Arch running from 16GB USB Stick

Offline

Board footer

Powered by FluxBB