Opened 7 years ago

Last modified 7 years ago

#5900 new defect

alsa/pulse grab cuts last 2 seconds of audio

Reported by: tsg1zzn Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords: pulseaudio
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
I have spent probably 10 hours trying to record the screen _losslessly_ in linux, and I simply cannot get it to work.

The commandline in the wiki for this is wrong, it does a lossy conversion rgb->yuv. Someone should note this and give a lossless option.

Currently I am pretty close, but the sound cuts 2 seconds before the end of the recorded file.

How to reproduce:

$ ffmpeg -thread_queue_size 2048 -f alsa -i pulse -f x11grab -s 1280x720 -i :0 -acodec libvorbis -ab 256k  -vcodec libx264rgb -r 30 -pix_fmt rgb24 "file $(date --rfc-3339=seconds).mkv" -report

^C

ffprobe shows the video stream and audio stream durations resp. like this:
DURATION : 00:00:07.103000000
DURATION : 00:00:05.399000000

Attached: ffmpeg -report
Attached: ffprobe output

Attachments (3)

ffmpeg_sound_cuts2seconds-20161020-130849.log (85.0 KB ) - added by tsg1zzn 7 years ago.
ffmpeg with -report, sound cuts last 2 seconds
ffprobe_sound_cut_2seconds_before_end.txt (3.6 KB ) - added by tsg1zzn 7 years ago.
ffmpeg-20161024-200442_custom_compile_no_output.log (361.3 KB ) - added by tsg1zzn 7 years ago.

Download all attachments as: .zip

Change History (10)

by tsg1zzn, 7 years ago

ffmpeg with -report, sound cuts last 2 seconds

comment:1 by Carl Eugen Hoyos, 7 years ago

Keywords: pulse added; screencast sound removed

Please test current FFmpeg git head.

comment:2 by Carl Eugen Hoyos, 7 years ago

Keywords: pulseaudio added; pulse removed

comment:3 by tsg1zzn, 7 years ago

I already tested with the git statically compiled version from https://johnvansickle.com/ffmpeg/. Apparently it does not support alsa input. using -f oss -i /dev/dsp gave unusable sound that was barely recognizable.

I don't feel like it's my job to recompile ffmpeg to test this, when a developer already has head installed and can verify the problem in literally 30 seconds.

comment:4 by tsg1zzn, 7 years ago

I spent an hour recompiling ffmpeg, and it wouldn't even produce a working file. There's just a complete inability to grab frames:
frame= 2 fps=0.5 q=-1.0 Lsize= 269kB time=00:00:00.03 bitrate=64907.3kbits/s dup=0 drop=119 speed=0.00835x

When I try to play the file:
GStreamer backend error
No valid frames decoded before end of stream

in reply to:  4 comment:5 by Carl Eugen Hoyos, 7 years ago

Replying to tsg1zzn:

I spent an hour recompiling ffmpeg, and it wouldn't even produce a working file.

FFmpeg is supposed to compile out-of-the-box on several major and a few very uncommon operating systems. On x86, you have to download and install a recent binary of yasm or nasm but this should never take significant time. Downloading FFmpeg can take a few minutes, compilation can take a very long time on slow hardware but you don't have to watch it;-)
What did you try / what failed now / command line and complete, uncut console output missing?

comment:6 by tsg1zzn, 7 years ago

I had to compile it three times, because features (x264 encoding, x11grab and audio input / encoding) were missing. And haunt down the correct libraries based on the error messages (the most difficult being "missing Xlib", which mean to install libx11-dev if I remember correctly).

Also, x11grab says it's deprecated. Maybe that's why it doesn't work?

I have accomplished the recording satisfactory by using avconv and yuv444p format and an updated x264 library. It seems players can't display rgb pixel formats anyway.

comment:7 by tsg1zzn, 7 years ago

A log was attached with the result from running the custom ffmpeg.

ffmpeg -report -thread_queue_size 2048 -f alsa -i pulse -f x11grab -s 1280x720 -i :0 -acodec libvorbis -ab 256k  -vcodec libx264rgb -r 30 -pix_fmt rgb24 "$@ $(date --rfc-3339=seconds).mkv"
Note: See TracTickets for help on using tickets.