I need to get stdout of rtsp stream without formatting. May someone know how to do it?
This is what I get if try to ffmpeg manually from command line:
root#cl-som-imx6ul-sid: ffmpeg -rtsp_transport tcp -i rtsp://admin:pass#10.168.9.141/Streaming/channels/1/ -vcodec cpoy -acodec copy -
ffmpeg version 3.2.5-1~bpo8+1 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 4.9.2 (Debian 4.9.2-10)
configuration: --prefix=/usr --extra-version='1~bpo8+1' --toolchain=hardened --libdir=/usr/lib/arm-linux-gnueabihf --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --disable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57. 56.101
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
Input #0, rtsp, from
'rtsp://admin:pass#10.168.9.141/Streaming/channels/1/':
Metadata:
title : Media Presentation
Duration: N/A, start: 0.240000, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuv420p(progressive), 640x480, 25 fps, 25.08 tbr, 90k tbn, 50 tbc
[NULL # 0x5683bc30] Unable to find a suitable output format for 'pipe:'
pipe:: Invalid argument
NodeJS code sample
this.stream = child_process.spawn("ffmpeg", ["-rtsp_transport", "tcp", "-i", this.url, '-acodec', 'copy', '-vcodec', 'copy', '-'], {
detached: false
});
this.inputStreamStarted = true;
this.stream.stdout.on('data', function(data) {
return self.emit('mpeg1data', data);
});
this.stream.stderr.on('data', function(data) {
return self.emit('ffmpegError', data);
});
When outputting a pipe you are required to manually instruct ffmpeg what output format you want to use. You can do this with the -f option. Example:
ffmpeg -rtsp_transport tcp -i rtsp://admin:pass#10.168.9.141/Streaming/channels/1/ -c copy -f mpegts -
This does not perform any re-encoding because -c copy is being used.
Related
I'm using ffmpeg to convert audio from FLAC to AAC and I'd like to use the aac_mf encoder, which uses Microsoft Media Foundation. If I use the native AAC encoder built into ffmpeg it works with the following command:
ffmpeg -i input.flac -acodec aac -vn output.m4a
However, the following command gives an error:
> ffmpeg -i input.flac -acodec aac_mf -vn output.m4a
ffmpeg version 5.0.1-full_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 11.2.0 (Rev7, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
libpostproc 56. 3.100 / 56. 3.100
Input #0, flac, from '.\input.flac':
Duration: 00:04:09.17, start: 0.000000, bitrate: 833 kb/s
Stream #0:0: Audio: flac, 44100 Hz, stereo, s16
Stream mapping:
Stream #0:0 -> #0:0 (flac (native) -> aac (aac_mf))
Press [q] to stop, [?] for help
[aac_mf # 000001bad81c6400] MFT name: 'Microsoft AAC Audio Encoder MFT'
[ipod # 000001bad81fb640] track 0: codec frame size is not set
Output #0, ipod, to 'output.m4a':
Stream #0:0: Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, s16, 128 kb/s
Metadata:
encoder : Lavc59.18.100 aac_mf
[aac_mf # 000001bad81c6400] nb_samples (4096) != frame_size (0)
Audio encoding failed
Conversion failed!
This is a bug. For now, add -frame_size. Will be fixed in 5.1 and soon in git master.
ffmpeg -i input.flac -acodec aac -vn -frame_size 1024 output.m4a
I want to concatenate some mp4 videos but coundn't manage to solve the audio problems.
Here are sample videos, to be concatenated, in this order: 1, 2 and 3. A concat.txtis also supplied. 2.mp4 is a fragment of a larger video and was reencoded (not just cut).
None of my attempts worked. Most of them lead to gaps in the audio, some change the pitch of the voice. There's clearly a DTS issue I just don't know how to deal with.
Sometimes there are more than three videos to put together.
What I tried so far:
The most obvious: fmpeg -f concat -safe 0 -i concat.txt -c copy out.mp4. This complains a lot (non-monotonous DTS). Very poor result.
Re-encoding video and audio: ffmpeg -f concat -safe 0 -i concat.txt -c:v libx264 -c:a aac out.mp4. Same poor result in a time consuming task. Using copy to avoid re-encoding just audio or just video leads nowhere.
Running away from mp4: I converted all files to avi and to ts thinking that that could be an mp4 issue. Bad results with avi and slightly better results with ts. Nothing good, though.
I tried playing with -video_track_timescale. No success.
I actually don't care about re-encoding the video, since the original has not a great quality already. But the audio issue must be solved.
I also hope for a generic solution, since I have many videos to handle and I wish to use just a script. Adjusting parameters for every single case would be a burden.
Using ffmpeg version 4.3.3 and Debian 11.
$ ffmpeg -version
ffmpeg version 4.3.3-0+deb11u1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10 (Debian 10.2.1-6)
configuration: --prefix=/usr --extra-version=0+deb11u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Edit
Here are the ffprobe results for each input file:
$ for i in [123].mp4; do echo; echo "------------ $i"; ffprobe $i; done
------------ 1.mp4
ffprobe version 4.3.3-0+deb11u1 Copyright (c) 2007-2021 the FFmpeg developers
built with gcc 10 (Debian 10.2.1-6)
configuration: --prefix=/usr --extra-version=0+deb11u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.45.100
Duration: 00:00:09.00, start: 0.040000, bitrate: 8842 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 8669 kb/s, 25.11 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 167 kb/s (default)
Metadata:
handler_name : SoundHandler
------------ 2.mp4
ffprobe version 4.3.3-0+deb11u1 Copyright (c) 2007-2021 the FFmpeg developers
built with gcc 10 (Debian 10.2.1-6)
configuration: --prefix=/usr --extra-version=0+deb11u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '2.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.45.100
Duration: 00:07:24.45, start: 0.000000, bitrate: 219 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 81 kb/s, 25 fps, 30 tbr, 115200 tbn, 50 tbc (default)
Metadata:
handler_name : ISO Media file produced by Google Inc. Created on: 10/11/2020.
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 129 kb/s (default)
Metadata:
handler_name : ISO Media file produced by Google Inc. Created on: 10/11/2020.
------------ 3.mp4
ffprobe version 4.3.3-0+deb11u1 Copyright (c) 2007-2021 the FFmpeg developers
built with gcc 10 (Debian 10.2.1-6)
configuration: --prefix=/usr --extra-version=0+deb11u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '3.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.45.100
Duration: 00:00:18.58, start: 0.040000, bitrate: 314 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 213 kb/s, 25.05 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 96 kb/s (default)
Metadata:
handler_name : SoundHandler
I want to concatenate some MP3 files using the FFmpeg concatenation protocol.
Here is a successful try:
$ ffmpeg -loglevel panic -i "concat:audio/it/ci.mp3|audio/it/èsse.mp3|audio/it/cu.mp3|audio/it/u.mp3|audio/it/tre.mp3|audio/it/zero.mp3|audio/it/cinque.mp3|audio/it/quattro.mp3|audio/it/tre.mp3|audio/it/otto.mp3|audio/it/tre.mp3" -c copy audio/it/CSQU3054383.mp3 -y
$ ll audio/it/CSQU3054383.mp3
-rw-rw-r-- 1 giorgio 26K Nov 9 16:16 audio/it/CSQU3054383.mp3
So far, all is OK!
BTW, all (Mp3) files have the same codecs, so MP3 FFmpeg concatenation protocol runs as expected!
Now, I want to insert a pause file audio/it/PAUSE_2.mp3, between each previous files:
$ ffmpeg -loglevel panic -i "concat:audio/it/ci.mp3|audio/it/PAUSE_2.mp3|audio/it/èsse.mp3|audio/it/PAUSE_2.mp3|audio/it/cu.mp3|audio/it/PAUSE_2.mp3|audio/it/u.mp3|audio/it/PAUSE_2.mp3|audio/it/tre.mp3|audio/it/PAUSE_2.mp3|audio/it/zero.mp3|audio/it/PAUSE_2.mp3|audio/it/cinque.mp3|audio/it/PAUSE_2.mp3|audio/it/quattro.mp3|audio/it/PAUSE_2.mp3|audio/it/tre.mp3|audio/it/PAUSE_2.mp3|audio/it/otto.mp3|audio/it/PAUSE_2.mp3|audio/it/tre.mp3" -c copy audio/it/CSQU3054383.mp3 -y
$
This command run apparently without any error, but the output file (audio/it/CSQU3054383.mp3) is not generated at all.
**Question 1 (minor):
Why doesn't FFmpeg report any error and doesn't generate the expected output?**
In fact, I already experienced that FFmpeg, in some circumstances, fails without saying why :(
I suspect the problem happens because the file audio/it/PAUSE_2.mp3 doesn't have a constant bit rate (CBR), as other files, e.g.:
$ mediainfo audio/it/ci.mp3
General
Complete name : audio/it/ci.mp3
Format : MPEG Audio
File size : 2.06 KiB
Duration : 528 ms
Overall bit rate mode : Constant
Overall bit rate : 32.0 kb/s
Audio
Format : MPEG Audio
Format version : Version 2
Format profile : Layer 3
Duration : 528 ms
Bit rate mode : Constant
Bit rate : 32.0 kb/s
Channel(s) : 1 channel
Sampling rate : 24.0 kHz
Frame rate : 41.667 FPS (576 SPF)
Compression mode : Lossy
Stream size : 2.06 KiB (100%)
$ ffprobe audio/it/ci.mp3
ffprobe version 3.4.8-0ubuntu0.2 Copyright (c) 2007-2020 the FFmpeg developers
built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
[mp3 # 0x564491288080] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from 'audio/it/ci.mp3':
Duration: 00:00:00.53, start: 0.000000, bitrate: 32 kb/s
Stream #0:0: Audio: mp3, 24000 Hz, mono, s16p, 32 kb/s
Instead, the inserted pause file has a variable bit rate, as mediainfo states:
$ mediainfo audio/it/PAUSE_2.mp3
General
Complete name : audio/it/PAUSE_2.mp3
Format : MPEG Audio
File size : 8.29 KiB
Overall bit rate mode : Variable
Writing library : LAME3.100
Audio
Format : MPEG Audio
Format version : Version 2
Format profile : Layer 3
Bit rate mode : Variable
Channel(s) : 1 channel
Sampling rate : 24.0 kHz
Compression mode : Lossy
Stream size : 8.06 KiB (97%)
Writing library : LAME3.100
Here my Bash script I used to generate the pause:
$ cat com/pause
#!/bin/bash
# https://ffmpeg.org/ffmpeg-filters.html#toc-anullsrc
# https://ffmpeg.org/ffmpeg-utils.html#toc-Examples-1
if [ $# -eq 0 ]
then
echo
echo "create a pause, a silence audio file (MP3) of specified number of milliseconds"
echo
echo "usage: $0 <time duration (in seconds)> <directory path>"
echo
echo "example: $0 2"
echo "example: $0 0.5 tmp/"
echo
exit
fi
timeDuration=$1
directoryPath=$2
suffix=mp3
# https://trac.ffmpeg.org/wiki/Limiting%20the%20output%20bitrate
#https://trac.ffmpeg.org/wiki/Encode/MP3
bitrate=32k
samplingRate=24000
outputFile="${directoryPath}PAUSE_${timeDuration}.${suffix}"
#-b:a $bitrate -minrate $bitrate -maxrate $bitrate -bufsize $bitrate \
ffmpeg \
-f lavfi \
-i anullsrc=r=$samplingRate:cl=mono \
-t $timeDuration \
-b:a $bitrate -minrate $bitrate -maxrate $bitrate \
-codec:a libmp3lame \
$outputFile -y
echo
echo "created file: $outputFile"
echo
Unfortunately, the created file seems with a variable bit rate and not with a constant bit rate (CBR), as expected ( -b:a ... ):
$ com/pause 2
ffmpeg version 3.4.8-0ubuntu0.2 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Input #0, lavfi, from 'anullsrc=r=24000:cl=mono':
Duration: N/A, start: 0.000000, bitrate: 192 kb/s
Stream #0:0: Audio: pcm_u8, 24000 Hz, mono, u8, 192 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (pcm_u8 (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Output #0, mp3, to 'PAUSE_2.mp3':
Metadata:
TSSE : Lavf57.83.100
Stream #0:0: Audio: mp3 (libmp3lame), 24000 Hz, mono, s16p, 32 kb/s
Metadata:
encoder : Lavc57.107.100 libmp3lame
size= 8kB time=00:00:02.01 bitrate= 33.7kbits/s speed= 192x
video:0kB audio:8kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.870640%
created file: PAUSE_2.mp3
Question 2:
What's wrong in my Bash script (why doesn't it generate a CBR file?
How can I generate an silence pause file (silence of N milliseconds) with the exact settings of previous files?
I'm trying to convert a video.ppm to video.mp4.
I tried this :
avconv -r 1 -i Hole0.0001.mp4.ppm -r 24 Hole.mp4
avconv version 12.3, Copyright (c) 2000-2018 the Libav developers
built on Oct 2 2019 11:39:18 with gcc 8 (GCC)
Input #0, image2, from 'Hole0.0001.mp4.ppm':
Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
Stream #0:0: Video: ppm
rgb24, 1310x560
25 tbn
Stream mapping:
Stream #0:0 -> #0:0 (ppm (native) -> mpeg4 (native))
Press ctrl-c to stop encoding
Output #0, mp4, to 'Hole.mp4':
Metadata:
encoder : Lavf57.7.2
Stream #0:0: Video: mpeg4 [ [0][0][0] / 0x0020]
yuv420p, 1310x560, q=2-31, 200 kb/s
24 fps, 24 tbn
Metadata:
encoder : Lavc57.25.0 mpeg4
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
frame= 1 fps= 0 q=3.2 Lsize= 16kB time=10000000000.00 bitrate= 0.0kbits/s
video:15kB audio:0kB other streams:0kB global headers:0kB muxing overhead: 5.397969%
then when I check my video.mp4 it doesn't work. I mean the video start and stop immediately.
272M Hole0.0001.mp4.ppm
16K Hole.mp4
The output of display Hole0.0001.mp4.ppm gives me this :
as you can see i have 150 frames in the file Hole0.0001.mp4.ppm
(base) alexandre#alexandre-Latitude-E7270:~/Documents$ ffprobe Hole0.0001.mp4.ppm
ffprobe version 3.4.8-0ubuntu0.2 Copyright (c) 2007-2020 the FFmpeg developers
built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Hole0.0001.mp4.ppm: Invalid data found when processing input
(base) alexandre#alexandre-Latitude-E7270:~/Documents$ ffplay Hole0.0001.mp4.ppm
ffplay version 3.4.8-0ubuntu0.2 Copyright (c) 2003-2020 the FFmpeg developers
built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Hole0.0001.mp4.ppm: Invalid data found when processing inputf=0/0
When I use this command I get :
(base) alexandre#alexandre-Latitude-E7270:~/Documents$ display -verbose Hole0.0001.mp4.ppm
Hole0.0001.mp4.ppm[0] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.690u 0:00.699
Hole0.0001.mp4.ppm[1] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.680u 0:00.690
Hole0.0001.mp4.ppm[2] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.680u 0:00.690
Hole0.0001.mp4.ppm[3] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.670u 0:00.679
Hole0.0001.mp4.ppm[4] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.670u 0:00.679
Hole0.0001.mp4.ppm[5] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.670u 0:00.670
Hole0.0001.mp4.ppm[6] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.660u 0:00.670
Hole0.0001.mp4.ppm[7] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.650u 0:00.670
Hole0.0001.mp4.ppm[8] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.650u 0:00.660
Hole0.0001.mp4.ppm[9] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.650u 0:00.660
Hole0.0001.mp4.ppm[10] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.650u 0:00.650
Hole0.0001.mp4.ppm[11] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.640u 0:00.650
Hole0.0001.mp4.ppm[12] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.640u 0:00.650
Hole0.0001.mp4.ppm[13] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.630u 0:00.640
Hole0.0001.mp4.ppm[14] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.630u 0:00.640
Do you have any ideas ?
Thank you
I found this command which works but the quality of the video is terrible ..
avconv -r 10 -vcodec ppm -f image2pipe -i Hole0.0001.mp4.ppm -r 20 Hole.mp4
I am using fluent ffmpeg with ffmpeg v4.1.3 for HLS mukti bitrate streaming but I m not able to use -var_stream_map config it says option, not found but running this command outside fluent-ffmpeg works fine
Here is my code
const stream = ffmpeg(filePath);
stream.outputOptions([
'-preset slow',
'-g 48',
'-map 0:0',
'-q:a:0 64k',
'-q:a:1 128k',
'-var_stream_map a:0 a:1',
'-hls_time 6',
'-f hls',
'-hls_list_size 0',
'-master_pl_name /tmp/master.m3u8',
"-hls_segment_filename /tmp/v%v/fileSequence%d.t",
"/tmp/v%v/prog_index.m3u8"
])
.output('./master.m3u8')
.on('progress', function(progress) {
console.log('Processing: ' + progress.percent + '% done')
})
Here is the output
ffmpeg version 4.1.3-tessus https://evermeet.cx/ffmpeg/ Copyright (c) 2000-2019 the FFmpeg developers
built with Apple LLVM version 10.0.1 (clang-1001.0.46.3)
configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-version3 --pkg-config-flags=--static --disable-ffplay
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Unrecognized option 'var_stream_map a:0 a:1'.
Error splitting the argument list: Option not found
Can someone tell me how can I pass it correctly?
I also face the same problem and solve that by putting the 'var_stream_map' in another outputOption().
stream.outputOptions([
'-preset slow',
'-g 48',
'-map 0:v', '-map 0:v',
'-map 0:a', '-map 0:a',
'-q:a:0 64k',
'-q:a:1 128k',
'-hls_time 6',
'-f hls',
'-hls_list_size 0',
'-master_pl_name /tmp/master.m3u8',
"-hls_segment_filename /tmp/v%v/fileSequence%d.t",
"/tmp/v%v/prog_index.m3u8"
])
.outputOption('-var_stream_map', 'v:0,a:0 v:1,a:1')
.output('./master.m3u8')
.on('progress', function(progress) {
console.log('Processing: ' + progress.percent + '% done')
})
On command line it is recommended put the var_stream_map value between quotation marks.
'-var_stream_map', '"a:0 a:1"'
Also the -map parameter adds only one stream (stream 0:0). If you want to have two audio streams you must also add the -map parameter two times:
-map 0:0 -map 0:0
Here the same input stream 0:0 is added two times for the output processing.