[FFmpeg-user] Play video and simultaneously record audio

Michael Koch astroelectronic at t-online.de
Thu Jan 16 18:51:47 EET 2020


Hello Gyan,

>
>> can FFmpeg or FFplay be used for playing a video (without audio) and 
>> exactly simultaneously record an audio file? I mean for making sound 
>> effects for the video. If this isn't possible, is there any other 
>> free software that can do it?
>
> Basic syntax would be,
>
>     ffmpeg -re -i videofile -f audiodevice -i audiourl  -map 1:a 
> audioout.wav -map 0:v -f sdl2 -
>

My first test, this works fine:

ffmpeg -re -i test.mp4 -f sdl2 -

Question: Is there any documentation for -f sdl2 ?


My second test:
ffmpeg -re -i test.mp4 -f dshow -channels 2 -i audio="Mikrofon (Realtek 
High Definiti" -y -map 1:a audio.wav -map 0:v -f sdl2 -

This command line has two problems:
1. The video doesn't play continuously, it's stop-and-go. May be my 
notebook has not enough computing power? Any ideas how to avoid this 
problem?
2. FFmpeg doesn't stop when the end of the video has been reached. The 
audio file gets longer than the video. I did already try to add the 
-shortest option, but it didn't solve the problem.

Here is the console output:

C:\Users\mKoch\Desktop>c://ffmpeg/ffmpeg -re -i test.mp4 -f dshow 
-channels 2 -i
  audio="Mikrofon (Realtek High Definiti" -y -map 1:a audio.wav -map 0:v 
-f sdl2
-
ffmpeg version git-2020-01-15-0dc0837 Copyright (c) 2000-2020 the FFmpeg 
develop
ers
   built with gcc 9.2.1 (GCC) 20200111
   configuration: --enable-gpl --enable-version3 --enable-sdl2 
--enable-fontconfi
g --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d 
--enable-libb
luray --enable-libfreetype --enable-libmp3lame 
--enable-libopencore-amrnb --enab
le-libopencore-amrwb --enable-libopenjpeg --enable-libopus 
--enable-libshine --e
nable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame 
--enable
-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 
--enable-libx265 -
-enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib 
--enable-gmp --enab
le-libvidstab --enable-libvorbis --enable-libvo-amrwbenc 
--enable-libmysofa --en
able-libspeex --enable-libxvid --enable-libaom --enable-libmfx 
--enable-ffnvcode
c --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec 
--enable-dxva2 -
-enable-avisynth --enable-libopenmpt --enable-amf
   libavutil      56. 38.100 / 56. 38.100
   libavcodec     58. 65.103 / 58. 65.103
   libavformat    58. 35.102 / 58. 35.102
   libavdevice    58.  9.103 / 58.  9.103
   libavfilter     7. 71.100 /  7. 71.100
   libswscale      5.  6.100 /  5.  6.100
   libswresample   3.  6.100 /  3.  6.100
   libpostproc    55.  6.100 / 55.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2mp41
     encoder         : Lavf58.25.100
   Duration: 00:00:06.57, start: 0.000000, bitrate: 12218 kb/s
     Stream #0:0(eng): Video: mpeg4 (Simple Profile) (mp4v / 
0x7634706D), yuv420p
, 1920x1080 [SAR 1:1 DAR 16:9], 12216 kb/s, 30 fps, 30 tbr, 15360 tbn, 
30 tbc (d
efault)
     Metadata:
       handler_name    : VideoHandler
       timecode        : 07:34:52:21
     Stream #0:1(eng): Data: none (tmcd / 0x64636D74), 0 kb/s
     Metadata:
       handler_name    : TimeCodeHandler
       timecode        : 07:34:52:21
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, dshow, from 'audio=Mikrofon (Realtek High Definiti':
   Duration: N/A, start: 31251.109000, bitrate: 1411 kb/s
     Stream #1:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
Stream mapping:
   Stream #1:0 -> #0:0 (pcm_s16le (native) -> pcm_s16le (native))
   Stream #0:0 -> #1:0 (mpeg4 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Output #0, wav, to 'audio.wav':
   Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2mp41
     ISFT            : Lavf58.35.102
     Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 
stereo, s16
, 1411 kb/s
     Metadata:
       encoder         : Lavc58.65.103 pcm_s16le
Output #1, sdl,sdl2, to 'pipe:':
   Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2mp41
     encoder         : Lavf58.35.102
     Stream #1:0(eng): Video: rawvideo (I420 / 0x30323449), yuv420p, 
1920x1080 [S
AR 1:1 DAR 16:9], q=2-31, 746496 kb/s, 30 fps, 30 tbn, 30 tbc (default)
     Metadata:
       handler_name    : VideoHandler
       timecode        : 07:34:52:21
       encoder         : Lavc58.65.103 rawvideo
frame=    1 fps=0.0 q=-0.0 size=     172kB time=00:00:01.01 
bitrate=1396.5kbits/
frame=   17 fps= 17 q=-0.0 size=     256kB time=00:00:01.51 
bitrate=1387.0kbits/
frame=   32 fps= 21 q=-0.0 size=     256kB time=00:00:01.51 
bitrate=1387.0kbits/
frame=   47 fps= 23 q=-0.0 size=     256kB time=00:00:02.53 bitrate= 
828.3kbits/
frame=   62 fps= 24 q=-0.0 size=     256kB time=00:00:02.53 bitrate= 
828.3kbits/
frame=   77 fps= 25 q=-0.0 size=     512kB time=00:00:03.55 
bitrate=1180.5kbits/
frame=   93 fps= 26 q=-0.0 size=     512kB time=00:00:04.05 
bitrate=1035.6kbits/
frame=  108 fps= 27 q=-0.0 size=     512kB time=00:00:04.05 
bitrate=1035.6kbits/
frame=  123 fps= 27 q=-0.0 size=     768kB time=00:00:04.55 
bitrate=1382.1kbits/
frame=  138 fps= 27 q=-0.0 size=     768kB time=00:00:05.06 
bitrate=1242.6kbits/
frame=  153 fps= 28 q=-0.0 size=     768kB time=00:00:05.56 
bitrate=1130.7kbits/
frame=  168 fps= 28 q=-0.0 size=    1024kB time=00:00:06.06 
bitrate=1383.8kbits/
frame=  184 fps= 28 q=-0.0 size=    1024kB time=00:00:06.58 
bitrate=1274.3kbits/
frame=  197 fps= 28 q=-0.0 size=    1024kB time=00:00:07.09 
bitrate=1182.5kbits/
frame=  197 fps= 26 q=-0.0 size=    1280kB time=00:00:07.60 
bitrate=1379.0kbits/
frame=  197 fps= 24 q=-0.0 size=    1280kB time=00:00:08.13 
bitrate=1289.4kbits/
frame=  197 fps= 23 q=-0.0 size=    1280kB time=00:00:08.63 
bitrate=1214.6kbits/
frame=  197 fps= 22 q=-0.0 size=    1536kB time=00:00:09.13 
bitrate=1377.9kbits/
frame=  197 fps= 21 q=-0.0 size=    1536kB time=00:00:09.63 
bitrate=1306.1kbits/
frame=  197 fps= 20 q=-0.0 size=    1536kB time=00:00:10.13 
bitrate=1241.8kbits/
frame=  197 fps= 19 q=-0.0 size=    1792kB time=00:00:10.63 
bitrate=1381.0kbits/
frame=  197 fps= 18 q=-0.0 size=    1792kB time=00:00:11.13 
bitrate=1318.6kbits/
frame=  197 fps= 17 q=-0.0 size=    1792kB time=00:00:11.63 
bitrate=1261.9kbits/
frame=  197 fps= 16 q=-0.0 size=    2048kB time=00:00:12.13 
bitrate=1382.7kbits/
frame=  197 fps= 16 q=-0.0 size=    2048kB time=00:00:12.63 
bitrate=1328.0kbits/
frame=  197 fps= 15 q=-0.0 size=    2048kB time=00:00:13.13 
bitrate=1277.6kbits/
frame=  197 fps= 15 q=-0.0 size=    2304kB time=00:00:13.63 
bitrate=1384.6kbits/
frame=  197 fps= 14 q=-0.0 size=    2304kB time=00:00:14.13 
bitrate=1335.6kbits/
frame=  197 fps= 14 q=-0.0 size=    2304kB time=00:00:14.63 
bitrate=1289.9kbits/
frame=  197 fps= 13 q=-0.0 size=    2560kB time=00:00:15.13 
bitrate=1386.0kbits/
frame=  197 fps= 13 q=-0.0 size=    2560kB time=00:00:15.63 
bitrate=1341.5kbits/
frame=  197 fps= 12 q=-0.0 size=    2560kB time=00:00:16.13 
bitrate=1299.9kbits/
frame=  197 fps= 12 q=-0.0 size=    2816kB time=00:00:16.63 
bitrate=1387.0kbits/
frame=  197 fps= 12 q=-0.0 size=    2816kB time=00:00:17.13 
bitrate=1346.6kbits/
frame=  197 fps= 11 q=-0.0 size=    2816kB time=00:00:17.63 
bitrate=1308.3kbits/
frame=  197 fps= 11 q=-0.0 size=    3072kB time=00:00:18.13 
bitrate=1387.8kbits/
frame=  197 fps= 11 q=-0.0 size=    3072kB time=00:00:18.63 
bitrate=1350.7kbits/
frame=  197 fps= 10 q=-0.0 size=    3072kB time=00:00:19.13 
bitrate=1315.4kbits/
frame=  197 fps= 10 q=-0.0 size=    3328kB time=00:00:19.63 
bitrate=1388.6kbits/
frame=  197 fps=9.8 q=-0.0 size=    3328kB time=00:00:20.13 
bitrate=1354.2kbits/
frame=  197 fps=9.6 q=-0.0 size=    3328kB time=00:00:20.63 
bitrate=1321.3kbits/
frame=  197 fps=9.3 q=-0.0 size=    3584kB time=00:00:21.13 
bitrate=1389.4kbits/
frame=  197 fps=9.1 q=-0.0 size=    3584kB time=00:00:21.63 
bitrate=1357.4kbits/
frame=  197 fps=8.9 q=-0.0 size=    3584kB time=00:00:22.13 
bitrate=1326.5kbits/
frame=  197 fps=8.7 q=-0.0 size=    3840kB time=00:00:22.63 
bitrate=1389.9kbits/
frame=  197 fps=8.5 q=-0.0 size=    3840kB time=00:00:23.13 
bitrate=1359.8kbits/
frame=  197 fps=8.3 q=-0.0 Lsize=    4048kB time=00:00:23.63 
bitrate=1403.2kbits
/s speed=   1x
video:598388kB audio:4048kB subtitle:0kB other streams:0kB global 
headers:0kB mu
xing overhead: unknown
Exiting normally, received signal 2.



More information about the ffmpeg-user mailing list