[FFmpeg-user] Play video and simultaneously record audio

Gyan ffmpeg at gyani.pro
Sun Jan 19 07:34:48 EET 2020



On 19-01-2020 12:51 am, Michael Koch wrote:
>
>>>
>>>
>>> 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.
>>>
>>
>> 1) Ok, let's pipe it to ffplay then.
>>
>> 2) The audio and playback video are independent outputs. So, ffmpeg 
>> will have to be manually stopped.
>>
>>     ffmpeg -an -i test.mp4 -f dshow -channels 2 -i audio="Mikrofon 
>> (Realtek High Definiti" -y -map 1:a audio.wav -map 0:v -c copy -f 
>> mpegts - | ffplay -f mpegts -
>
> I did try the above example (with some changes) but it has another 
> problem: FFplay can't be stopped when the video has ended, and it uses 
> the full screen. Which means I can't see the console window and can't 
> close it. FFmpeg can only be stopped by the task manager.

Looks like your video resolution is equal to or greater than your 
display. Add `-vf scale=iw/2:-1` to resize it.
Add -autoexit to quit ffplay when it detects EOF.

>
> I found a better solution for the stop-and-go problem with sdl2. 
> Adding -audio_buffer_size 100 solves the problem:
>
> ffmpeg -re -i test.mp4 -f dshow -audio_buffer_size 100 -channels 2 -i 
> audio="Mikrofon (Realtek High Definiti" -y -map 1:a audio.wav -map 0:v 
> -f sdl2 -

Looks better for your needs, but this is dshow specific. Won't be 
applicable to other live audio sources.

Gyan


More information about the ffmpeg-user mailing list