No sound when capture screen - audio

To capture my pc screen with following ffmpeg command.
ffmpeg -f pulse -ac 2 -i default -f x11grab -r 30 -s 1920x1080 -i :0.0 -acodec pcm_s16le -vcodec libx264 -preset ultrafast -threads 0 -y /tmp/output.mkv
The output displayed on my console when to execute the above command.
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, pulse, from 'default':
Duration: N/A, start: 1515543051.106987, bitrate: 1536 kb/s
Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[x11grab # 0x564bda5b8520] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #1, x11grab, from ':0.0':
Duration: N/A, start: 1515543052.415508, bitrate: N/A
Stream #1:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1920x1080, 30 fps, 1000k tbr, 1000k tbn, 1000k tbc
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 # 0x564bda5c1560] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 LZCNT
[libx264 # 0x564bda5c1560] profile High 4:4:4 Predictive, level 4.0, 4:4:4 8-bit
[libx264 # 0x564bda5c1560] 264 - core 148 r2748 97eaef2 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=6 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
Output #0, matroska, to '/tmp/output.mkv':
Metadata:
encoder : Lavf57.56.101
Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv444p, 1920x1080, q=-1--1, 30 fps, 1k tbn, 30 tbc
Metadata:
encoder : Lavc57.64.101 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16, 1536 kb/s
Metadata:
encoder : Lavc57.64.101 pcm_s16le
Stream mapping:
Stream #1:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Stream #0:0 -> #0:1 (pcm_s16le (native) -> pcm_s16le (native))
Playing a music when to make the screenshot,i can hear the music playing lound.
It's strange that vedio came out perfectly without sound when to play the captured /tmp/output.mkv.
Open my volume control with pavucontrol.
Nothing in recording window, maybe the blank recording window result in no souond when to capture screen!
How to fix it ?

Solved.
ffmpeg -f pulse -ac 2 -i default -f x11grab -r 30 -s 1920x1080 -i :0.0 -acodec pcm_s16le -vcodec libx264 -preset ultrafast -threads 0 -y /tmp/test.avi
To change output file format from test.mkv as test.avi .

Related

ffmpeg says "No JPEG data found in image" when reading image paths from Linux pipe

I'm trying to convert a set of pictures into a video, and I want to read the file paths of the pictures from the pipe. The command I would like to run looks like this:
find dir/*.JPG | sort | ffmpeg -f image2pipe -r 1 -vcodec mjpeg -s 6000x4000 -pix_fmt yuvj422p -i - -vcodec libx264 -s 1080x720 -r 20 -pix_fmt yuv420p out.mkv
But I keep obtaining the No JPEG data found in image error. Here is the full log:
Input #0, image2pipe, from 'pipe:':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj422p(bt470bg/unknown/unknown), 6000x4000, 1 fps, 1 tbr, 1 tbn, 1 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
[mjpeg # 0x558e98cd7300] No JPEG data found in image
Error while decoding stream #0:0: Invalid data found when processing input
[swscaler # 0x558e98ce9440] deprecated pixel format used, make sure you did set range correctly
[libx264 # 0x558e98cdaac0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 # 0x558e98cdaac0] profile High, level 3.1, 4:2:0, 8-bit
[libx264 # 0x558e98cdaac0] 264 - core 161 r3039 544c61f - H.264/MPEG-4 AVC codec - Copyleft
2003-2021 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=20 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to 'out.mkv':
Metadata:
encoder : Lavf58.76.100
Stream #0:0: Video: h264 (H264 / 0x34363248), yuv420p, 1080x720, q=2-31, 20 fps, 1k tbn
Metadata:
encoder : Lavc58.134.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame= 0 fps=0.0 q=0.0 Lsize= 1kB time=00:00:00.00 bitrate=N/A speed= 0x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!
The pictures are in the following format (with mediainfo) and the filenames are in the form DSC_1234.JPG:
Format : JPEG
Video
Format : JPEG
Width : 6 000 pixels
Height : 4 000 pixels
Display aspect ratio : 3:2
Color space : YUV
Chroma subsampling : 4:2:2
Bit depth : 8 bits
Compression mode : Lossy
Also, I would like to avoid using a solution without piping the paths (with -f image2 -i DSC_%04d.JPG for example). Do you have any idea what's happening?
Your command is passing the names of the files to the pipe, but the content of the files is needed, please adjust your command like this:
find dir/ -iname '*.jpg' | xargs cat | ffmpeg -f image2pipe -r 1 -vcodec mjpeg -s 6000x4000 -pix_fmt yuvj422p -i - -vcodec libx264 -s 1080x720 -r 20 -pix_fmt yuv420p out.mkv

ffmpeg concat of multiple files audio out of sync

I am trying to concatenate multiple files together using ffmpeg concatenate demuxer. However final video is out of sync.
First parts are coming from static image which are converted to 5-seconds video in the following way:
ffmpeg -r 30 -i 1.png -vf loop=loop=150:size=1:start=0 -pix_fmt yuv420p -c:v libx264 -preset superfast -tune stillimage loop.mp4
Then I add silent audio stream:
ffmpeg -i loop.mp4 -f lavfi -i anullsrc -map 0:v -map 1:a -ar 44100 -ac 2 -c:v copy -c:a aac -shortest silent.mp4
ffrobe for the silent.mp4:
ffprobe -v quiet -show_entries stream=start_time,duration silent.mp4
[STREAM]
start_time=0.000000
duration=5.733333
[/STREAM]
[STREAM]
start_time=0.000000
duration=5.665011
[/STREAM]
Which already shows that audio and video streams have different duration.
Then I prepare concat input file, last line is the video with same dimension and framerate, also it has existing audio stream (44.1kHz, stereo)
file silent.mp4
file silent.mp4
... (multiple lines, say 10)
file silent.mp4
file video.mp4
To make sure that inputs have same parameters:
ffmpeg -i silent.mp4 -i video.mp4
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'silent.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:00:05.03, start: 0.000000, bitrate: 32 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 19 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:00:43.03, start: 0.000000, bitrate: 1622 kb/s
Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 1484 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
Now, after concatenation final video is out of sync with audio (audio stream of the last part starts before static part is finished)
ffmpeg -f concat -i concat.txt -c copy result.mp4 (no warnings)
I have tried to pad audio stream with silence in both loop.mp4 and video.mp4, but it did not help - it randomly modifies duration and start time of both video and audio streams and audio is again out of sync after concat.
Also, I am not able to increase the duration of static part (so that number of entries in concat.txt can be decreased) because each static part can be different - this is just an example.

exclude specific streams (e.g. teletext) from ffmpeg conversion

I want to convert several video files (captured from television) to another format, but I want to remove some specific streams. For example, this is one of my input files:
$ ffprobe -hide_banner -i 'Easy Rider.ts' 2>&1|grep Stream
Stream #0:0[0x4f6]: Unknown: none ([5][0][0][0] / 0x0005)
Stream #0:1[0x4fc]: Unknown: none ([12][0][0][0] / 0x000C)
Stream #0:2[0x13f7]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 100 tbc
Stream #0:3[0x13f8](deu): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, fltp, 192 kb/s
Stream #0:4[0x13f9](fra): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, fltp, 192 kb/s
Stream #0:5[0x13fa](deu): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
Stream #0:6[0x13fb](deu): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006) (hearing impaired)
Stream #0:7[0x13fc](mul): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, fltp, 192 kb/s
Stream #0:8[0x13fd](mis): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, fltp, 192 kb/s (visual impaired) (descriptions)
Stream #0:9[0x13fe](fra): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
Stream #0:10[0x13ff](deu): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
From this file, I want to keep
Stream #2 (h264 video)
Stream #3 (mp2 audio in german)
Stream #10 (dvb_subtitle in german)
In other words, I want to exclude from conversion
all streams of unknown type
all audio streams other than german
all streams for visual impaired or hearing impaired
all dvb_teletext streams
Of cause, I can do some awk scripting to construct a command like
$ ffmpeg -hide_banner -ignore_unknown -i 'Easy Rider.ts' -map 0:2 -map 0:3 -map 0:10 -vcodec copy -acodec copy -scodec copy xx.ts
But I am searching for a solution using ffmpeg's mapping facilities.
I already found Mapping streams by language in FFmpeg, which led me to
$ ffmpeg -hide_banner -ignore_unknown -i 'Easy Rider.ts' -map 0:v -map 0:m:language:deu -vcodec copy -acodec copy -scodec copy xx.ts
This command creates a file, which still has subtitles for hearing impaired and the dvb_teletext in it
$ ffprobe -hide_banner -i xx.ts 2>&1|grep Stream
Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 100 tbc
Stream #0:1[0x101](deu): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, fltp, 192 kb/s
Stream #0:2[0x102](deu): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006), 492x250
Stream #0:3[0x103](deu): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006) (hearing impaired)
Stream #0:4[0x104](deu): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
Up to now, I did not find a way to exclude those streams from the output. Any idea?

FFMPEG: Converting from raw audio to audio/mp4 (audio is being converted with slow speed)

If I convert from mp3 to mp4 directly everything works perfectly. But if I try to convert from raw pcm, the audio speed is slowed down.
I've tried the following (this works):
ffmpeg -i mp3/1.mp3 -strict -2 final.mp4
This doesn't work as expected:
ffmpeg -f s16le -i final.raw -strict -2 -r 26 final.mp4
With the following output:
Input #0, s16le, from 'final.raw':
Duration: 00:08:37.38, bitrate: 705 kb/s
Stream #0:0: Audio: pcm_s16le, 44100 Hz, 1 channels, s16, 705 kb/s
File 'final.mp4' already exists. Overwrite ? [y/N] y
Output #0, mp4, to 'final.mp4':
Metadata:
encoder : Lavf56.40.101
Stream #0:0: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, mono, fltp, 128 kb/s
Metadata:
encoder : Lavc56.60.100 aac
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
size= 8273kB time=00:08:37.38 bitrate= 131.0kbits/s
video:0kB audio:8185kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.073808%
I've tried to set parameters like:
ffmpeg -ar 44100 -f s16le -i final.raw -strict -2 -r 26 final.mp4
With no luck.
In order to get the PCM from mp3 I'm using nodejs lame decoder:
var decoder = new lame.Decoder({
channels: 2,
bitDepth: 16,
sampleRate: 44100,
bitRate: 128,
outSampleRate: 44100, // 22050
mode: lame.STEREO
});

Merging multichannel audio tracks from Mumble with ffmpeg

We record talks through Mumble and because Mumble has a nitfy multichannel feature I'd figured we could get subtitles from YouTube by uploading each track to YouTube separately with for file in *; do ffmpeg -loop 1 -r 2 -i "$img" -i "$file" -vf scale=-1:380 -c:v libx264 -preset slow -tune stillimage -crf 18 -c:a copy -shortest -pix_fmt yuv420p -threads 0 "$file".mkv; done I then can prepend with a eg. a sed shell script a nickname for each speaker in the automatic captions i.e. subtitles from YouTube. Works like a charm.
But merging those tracks with ffmpeg gets tricky. I use ffmpeg -i input1.ogg -input2.ogg -i input3.ogg -i input4.ogg -input5.ogg -filter_complex "[0:a][1:a][2:a][3:a][4:a] amerge=inputs=5[aout]" -map "[aout]" -ac 2 output.ogg
Somehow ffmpeg shortens the resulting audio track and I don't yet have an idea why. I tried using the longest first and last since including silent tracks made even a shorter mixdown. Here are the warnings:
[Parsed_amerge_0 # 0x7f8b29f02d20] No channel layout for input 1
[Parsed_amerge_0 # 0x7f8b29f02d20] Input channel layouts overlap: output layout will be determined by the number of distinct input channels
But it says
[Parsed_amerge_0 # 0x7f8b29f02d20] No channel layout for input 1
even when I change the order of inputs.
Allthough according to Mumble's documentation the tracks should be equal length VLC media info shows different track times. However the tracks are not out of sync just cut off at the end.
I also have no idea why ffmpeg mentions FLAC, all the files are vorbis.
ffmpeg -i Mumble-2017-09-09-16-33-18-149.210.187.155-chrisaiki2.ogg -i Mumble-2017-09-09-16-33-18-149.210.187.155-Recorder.ogg -i Mumble-2017-09-09-16-33-18-149.210.187.155-steempowerpics.ogg -i Mumble-2017-09-09-16-33-18-149.210.187.155-Taconator.ogg -i Mumble-2017-09-09-16-33-18-149.210.187.155-fuzzynewest.ogg -filter_complex "[0:a][1:a][2:a][3:a][4:a] amerge=inputs=5[aout]" -map "[aout]" -ac 2 output5.ogg
ffmpeg version 2.8.4 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 7.0.2 (clang-700.1.81)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.8.4 --enable-shared -- enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable- avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable- libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-vda
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
Input #0, ogg, from 'Mumble-2017-09-09-16-33-18-149.210.187.155- chrisaiki2.ogg':
Duration: 00:40:01.19, start: 0.000000, bitrate: 17 kb/s
Stream #0:0: Audio: vorbis, 48000 Hz, mono, fltp, 86 kb/s
Metadata:
ENCODER : libsndfile
TITLE : chrisaiki2
Input #1, ogg, from 'Mumble-2017-09-09-16-33-18-149.210.187.155-Recorder.ogg':
Duration: 00:33:57.88, start: 0.000000, bitrate: 1 kb/s
Stream #1:0: Audio: vorbis, 48000 Hz, mono, fltp, 86 kb/s
Metadata:
ENCODER : libsndfile
TITLE : Recorder
Input #2, ogg, from 'Mumble-2017-09-09-16-33-18-149.210.187.155-steempowerpics.ogg':
Duration: 00:33:53.93, start: 0.000000, bitrate: 1 kb/s
Stream #2:0: Audio: vorbis, 48000 Hz, mono, fltp, 86 kb/s
Metadata:
ENCODER : libsndfile
TITLE : steempowerpics
Input #3, ogg, from 'Mumble-2017-09-09-16-33-18-149.210.187.155-Taconator.ogg':
Duration: 00:35:36.37, start: 0.000000, bitrate: 6 kb/s
Stream #3:0: Audio: vorbis, 48000 Hz, mono, fltp, 86 kb/s
Metadata:
ENCODER : libsndfile
TITLE : Taconator
Input #4, ogg, from 'Mumble-2017-09-09-16-33-18-149.210.187.155-fuzzynewest.ogg':
Duration: 00:41:53.23, start: 0.000000, bitrate: 30 kb/s
Stream #4:0: Audio: vorbis, 48000 Hz, mono, fltp, 86 kb/s
Metadata:
ENCODER : libsndfile
TITLE : fuzzynewest
File 'output5.ogg' already exists. Overwrite ? [y/N] y
[Parsed_amerge_0 # 0x7f8b29f02d20] No channel layout for input 1
[Parsed_amerge_0 # 0x7f8b29f02d20] Input channel layouts overlap: output layout will be determined by the number of distinct input channels
[flac # 0x7f8b2b005600] encoding as 24 bits-per-sample
Output #0, ogg, to 'output5.ogg':
Metadata:
encoder : Lavf56.40.101
Stream #0:0: Audio: flac, 48000 Hz, stereo, s32 (24 bit), 128 kb/s (default)
Metadata:
encoder : Lavc56.60.100 flac
Stream mapping:
Stream #0:0 (vorbis) -> amerge:in0
Stream #1:0 (vorbis) -> amerge:in1
Stream #2:0 (vorbis) -> amerge:in2
Stream #3:0 (vorbis) -> amerge:in3
Stream #4:0 (vorbis) -> amerge:in4
amerge -> Stream #0:0 (flac)
Press [q] to stop, [?] for help
size= 100900kB time=00:33:53.94 bitrate= 406.4kbits/s
video:0kB audio:100441kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.457024%
Mumble multichannel talk on reddit
The amerge documentation states:
If inputs do not have the same duration, the output will stop with the
shortest.
amix may be a better filter for this case.
I used amix in the end like this:
ffmpeg -i input1.ogg -i input2.ogg -i input3.ogg -i inout4.ogg -i input5.ogg -filter_complex "[0:a][1:a][2:a][3:a][4:a] amix=inputs=5:duration=longest[aout]" -map "[aout]" -ac 2 -c:a libvorbis -b:a 128k output.ogg
ffmpeg didn't recognize libvorbis so I had to reinstall with brew first: brew reinstall ffmpeg --with-libvorbis
I then used ffmpeg -loop 1 -r 2 -i "$img" -i "$snd" -vf scale=-1:380 -c:v libx264 -preset slow -tune stillimage -crf 18 -c:a copy -shortest -pix_fmt yuv420p -threads 0 output.mkv to upload the mixed audio tracks to YouTube.
I had merged the subtitles which were generated with YouTube as well and I just added those to the resulting video. Works like a charm.

Resources