Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#4436 closed defect (fixed)

There is no reliable way to do screen-casting with audio.

Reported by: Adam Kurkiewicz Owned by:
Priority: minor Component: wiki
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+100,200 -f alsa -ac 2 -i pulse output.flv

No longer works, contrary to what's claimed on the wiki:
https://trac.ffmpeg.org/wiki/Capture/Desktop.

I would edit the tip on the wiki to:

ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+0,0 -f alsa -ac 2 -i pulse -acodec aac -strict experimental output.flv

which works, but also assumes running an experimental codec, which I'd imagine would work unreliably. Furthermore, I was unable to identify any other pair of audio and video encoders that would work together. For example, the following line:

ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+0,0 -f alsa -ac 2 -i pulse -acodec copy output.mpeg

Results in seemingly OK capture:

ffmpeg version N-71312-ga66dcfe Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.8.3 (GCC) 20140911 (Red Hat 4.8.3-7)
  configuration: 
  libavutil      54. 22.100 / 54. 22.100
  libavcodec     56. 34.100 / 56. 34.100
  libavformat    56. 29.100 / 56. 29.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 13.101 /  5. 13.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
Input #0, x11grab, from ':0.0+0,0':
  Duration: N/A, start: 1428354986.424817, bitrate: N/A
    Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1024x768, 25 fps, 25 tbr, 1000k tbn, 25 tbc
Guessed Channel Layout for  Input Stream #1.0 : stereo
Input #1, alsa, from 'pulse':
  Duration: N/A, start: 1428354986.452261, bitrate: 1536 kb/s
    Stream #1:0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
File 'output.mpeg' already exists. Overwrite ? [y/N] y
[mpeg @ 0x26276e0] VBV buffer size not set, using default size of 130KB
If you want the mpeg file to be compliant to some specification
Like DVD, VCD or others, make sure you set the correct buffer size
Output #0, mpeg, to 'output.mpeg':
  Metadata:
    encoder         : Lavf56.29.100
    Stream #0:0: Video: mpeg1video, yuv420p, 1024x768, q=2-31, 200 kb/s, 25 fps, 90k tbn, 25 tbc
    Metadata:
      encoder         : Lavc56.34.100 mpeg1video
    Stream #0:1: Audio: pcm_s16le, 48000 Hz, stereo, 1536 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg1video (native))
  Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
[alsa @ 0x26019c0] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
[x11grab @ 0x25fb040] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
Past duration 0.628014 too large
Past duration 0.650642 too large     876kB time=00:00:01.72 bitrate=4172.2kbits/s dup=31 drop=8    
Past duration 0.888618 too large
Past duration 0.906075 too large
Past duration 0.956093 too large
frame=  132 fps= 31 q=31.0 Lsize=    2134kB time=00:00:05.24 bitrate=3336.2kbits/s dup=31 drop=29    
video:1154kB audio:963kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.820092%

However, inspection with ffplay produces a corrupted audio (loud squeak at the beginning and silence thereafter).

ffplay version N-71312-ga66dcfe Copyright (c) 2003-2015 the FFmpeg developers
  built with gcc 4.8.3 (GCC) 20140911 (Red Hat 4.8.3-7)
  configuration: 
  libavutil      54. 22.100 / 54. 22.100
  libavcodec     56. 34.100 / 56. 34.100
  libavformat    56. 29.100 / 56. 29.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 13.101 /  5. 13.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
[mp2 @ 0x7f499c007da0] Header missingB vq=    0KB sq=    0B f=0/0   
    Last message repeated 82 times
Input #0, mpeg, from 'output.mpeg':
  Duration: 00:00:05.16, start: 0.540000, bitrate: 3386 kb/s
    Stream #0:0[0x1e0]: Video: mpeg1video, yuv420p(tv), 1024x768 [SAR 1:1 DAR 4:3], 104857 kb/s, 25 fps, 25 tbr, 90k tbn, 25 tbc
    Stream #0:1[0x1c0]: Audio: mp2, 32000 Hz, mono, s16p, 64 kb/s
[mp2 @ 0x7f499c007da0] Header missing
[mp2 @ 0x7f499c007da0] Header missingB vq=  568KB sq=    0B f=0/0   
    Last message repeated 245 times
   5.14 A-V: -0.002 fd=  58 aq=    0KB vq=   57KB sq=    0B f=0/0   
[picrin@localhost presentation]$ FFmpeg/ffplay output.mpeg 
ffplay version N-71312-ga66dcfe Copyright (c) 2003-2015 the FFmpeg developers
  built with gcc 4.8.3 (GCC) 20140911 (Red Hat 4.8.3-7)
  configuration: 
  libavutil      54. 22.100 / 54. 22.100
  libavcodec     56. 34.100 / 56. 34.100
  libavformat    56. 29.100 / 56. 29.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 13.101 /  5. 13.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
[mp2 @ 0x7fe9f8007da0] Header missingB vq=    0KB sq=    0B f=0/0   
    Last message repeated 82 times
Input #0, mpeg, from 'output.mpeg':
  Duration: 00:00:05.16, start: 0.540000, bitrate: 3386 kb/s
    Stream #0:0[0x1e0]: Video: mpeg1video, yuv420p(tv), 1024x768 [SAR 1:1 DAR 4:3], 104857 kb/s, 25 fps, 25 tbr, 90k tbn, 25 tbc
    Stream #0:1[0x1c0]: Audio: mp2, 32000 Hz, mono, s16p, 64 kb/s
[mp2 @ 0x7fe9f8007da0] Header missingB vq=  568KB sq=    0B f=0/0   
    Last message repeated 246 times
   4.84 A-V: -0.023 fd=  58 aq=    0KB vq=   59KB sq=    0B f=0/0   

The key to the actual bug might be a line in the output, which appears repetitively:

[mp2 @ 0x7f499c007da0] Header missing

In order to resolve this bug, can a developer/ anybody with better understanding of ffmpeg than me do the following:

1) fix the wiki with a reliable solution for screen-casting WITH audio, which will work without an experimental codec.
2) fix the -acodec copy not to mess up the audio headers, or whatever is actually broken.

I am running against very recent revision from master: a66dcfeedc68c080965cf78e1e0694967acef5af.

ffmpeg was built with default configuration as produced by ./configure on Fedora 20.

More detail available on stack overflow:
http://stackoverflow.com/questions/29478548/screen-capture-with-audio-in-ffmpeg

Change History (3)

comment:1 by llogan, 9 years ago

Component: undeterminedwiki
Keywords: screen-casting acodec copy removed
Priority: normalminor

This is a messy bug report. The examples in the wiki you referred to were generic and meant to be modified. They were made less generic and more user friendly shortly after your report. So that issue is fixed.

Your second issue results from you attempting to mux PCM into MPEG PS. Does anything support this combination? It appears that ffmpeg allows muxing but creates a file it can't demux/decode. You could argue that ffmpeg should not allow this (or should properly demux its own output in this case); however, this should be its own bug report if there isn't one already.

comment:2 by llogan, 9 years ago

Resolution: fixed
Status: newclosed

comment:3 by Adam Kurkiewicz, 9 years ago

hi llogan,

Let me start by saying that I tried my best not to fill a messy bug report. I've thought the report through thoroughly and I tried a couple of things before deciding that there was a bug. I've also given all the details I could have thought of that could be important.

I'm unable to check that the new solution on the wiki works (I no longer have ffmpeg installed), but I suggest you try it to make sure it does -- the wiki should give solutions that work, and even better, explain how to modify them for one's use-case.

I suggest that if you think this is a decoding bug, rather than encoding bug, you reopen the bug and reassign it to a different component,

picrin

Note: See TracTickets for help on using tickets.