I have a problem on connect to a rtsp camera using ffplay.
The camera is under a router that permits only the TCP protocol.
I can watch the camera using ffplay only if I am in the same network of the camera.
So, when I am out, using this command line
ffplay rtsp://address:554/onvif1
or this
ffplay -rtsp_transport tcp rtsp://address:554/onvif1
I cannot watch the camera.
This is the output of ffplay (the latest).
[rtsp # 059ee680] Nonmatching transport in server reply 0B f=0/0
rtsp://address:554:/onvif1: Invalid data found when processing input
Trying with VLC and I can watch the camera without any problem, both when I am in the same network or when I am out. The VLC output says that VLC uses TCP.
Has someone got a suggestion?
Sure, as you can see below vlc works without any problem.
FFMpeg works only with a local camera but not with a remote camera. Forcing tcp as rtsp protocol seems to have no effect.
try to capture a remote camera (doesn't work)
denis#tomcat:~/Scaricati/ffmpeg-git-20181227-amd64-static$ **./ffmpeg -v verbose -i rtsp://address:554/onvif1 a.avi**
ffmpeg version N-47834-gb5e0a0fe3a-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
libavutil 56. 25.100 / 56. 25.100
libavcodec 58. 42.104 / 58. 42.104
libavformat 58. 25.100 / 58. 25.100
libavdevice 58. 6.101 / 58. 6.101
libavfilter 7. 46.101 / 7. 46.101
libswscale 5. 4.100 / 5. 4.100
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
[tcp # 0x5f86700] Starting connection attempt to address port 554
try to capture a remote camera forcing tcp (doesn't work)
denis#tomcat:~/Scaricati/ffmpeg-git-20181227-amd64-static$ **./ffmpeg -v verbose -rtsp_transport tcp -i rtsp://address:554/onvif1 a.avi**
ffmpeg version N-47834-gb5e0a0fe3a-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
libavutil 56. 25.100 / 56. 25.100
libavcodec 58. 42.104 / 58. 42.104
libavformat 58. 25.100 / 58. 25.100
libavdevice 58. 6.101 / 58. 6.101
libavfilter 7. 46.101 / 7. 46.101
libswscale 5. 4.100 / 5. 4.100
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
[tcp # 0x5515740] Starting connection attempt to address port 554
Using vlc (works)
denis#tomcat:~/Scaricati/ffmpeg-git-20181227-amd64-static$ **vlc -v**
VLC media player 3.0.3 Vetinari (revision 3.0.3-1-0-gc2bb759264)
[000056417a4461a0] main libvlc: Esecuzione di vlc con l'interfaccia predefinita. Usa 'cvlc' per utilizzare vlc senza interfaccia.
[000056417a4da540] main playlist: playlist is empty
[00007fcd00000eb0] live555 demux warning: no data received in 10s. Switching to TCP
[00007fcd0000b2d0] main decoder error: buffer deadlock prevented
[000056417a505bf0] pulse audio output warning: starting late (-591 us)
[000056417a505bf0] main audio output warning: playback way too early (-260338): playing silence
[000056417a505bf0] main audio output warning: playback too late (67682): up-sampling
[000056417a505bf0] main audio output warning: playback too early (-60916): down-sampling
[000056417a505bf0] main audio output warning: playback way too early (-191284): playing silence
[000056417a505bf0] main audio output warning: playback way too late (252312): flushing buffers
[000056417a505bf0] pulse audio output warning: starting late (-5953 us)
[000056417a505bf0] main audio output warning: playback way too early (-701316): playing silence
[000056417a505bf0] main audio output warning: playback way too early (-332484): playing silence
[000056417a505bf0] main audio output warning: playback too late (125861): up-sampling
[000056417a505bf0] main audio output warning: playback way too late (297954): flushing buffers
[000056417a505bf0] main audio output warning: playback way too early (-993047): playing silence
[00007fcd0000b2d0] avcodec decoder warning: thread type 1: disabling hardware acceleration
[000056417a505bf0] main audio output warning: playback too late (107083): up-sampling
[000056417a505bf0] main audio output warning: playback way too late (235778): flushing buffers
[00007fcce0001cc0] egl_x11 gl error: cannot select OpenGL API
[000056417a505bf0] main audio output warning: playback way too early (-657714): playing silence
[000056417a505bf0] main audio output warning: playback way too late (238668): flushing buffers
[00007fccf8160b40] main video output warning: picture is too late to be displayed (missing 691 ms)
[00007fccf8160b40] main video output warning: picture is too late to be displayed (missing 491 ms)
[00007fccf8160b40] main video output warning: picture is too late to be displayed (missing 290 ms)
[00007fccf8160b40] main video output warning: picture is too late to be displayed (missing 89 ms)
[000056417a505bf0] main audio output warning: playback way too early (-652182): playing silence
[000056417a505bf0] main audio output warning: playback too late (72927): up-sampling
[000056417a505bf0] main audio output warning: playback too late (98876): up-sampling
[000056417a4da540] main playlist: end of playlist, exiting
Related
I've been through many stackoverflow pages and forums trying to find the answer I want.
I created a virtual microphone and I'm trying to pipe to it some wav sounds created using FFMPEG.
When I want to pipe a keyboard noise I pipe the sound to my virtual sound capture device like this:
ffmpeg -fflags +discardcorrupt -i <Keyboard sound Path> -f s16le -ar 44100 -ac 1 - > /tmp/gapFakeMic
And when I want to pipe some synthetized voice sound using Espeak to my virtual microphone, I do this:
espeak -vbrazil-mbrola-4 <some random text> --stdout | ffmpeg -fflags +discardcorrupt -i pipe:0 -f s16le -ar 44100 -ac 1 - > /tmp/gapFakeMic
The problem is my capture device doesn't record the sound like a normal recorder that still records even when there's no sound being transmited to it. So I'm trying to append the silence to the wav which is being created while my application is running. Always when I try to send the silence to buffer, FFMPEG returns the following response:
[NULL # 0x5579f7921a00] Unable to find a suitable output format for 'pipe:'
FFMPEG is a powerful tool but its documentation lacks to be useful for newbies like me. So, I'd appreciate if anyone could answer this or at least give me any direction or some resource where I could find a way of achieving this.
EDIT:
Here's how I'm producing the silence to my virtual microphone:
ffmpeg -f lavfi -i anullsrc=channel_layout=mono:sample_rate=44100 -t <Time in seconds> - > /tmp/gapFakeMic
Here's the full log:
ffmpeg version 4.1.6-1~deb10u1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --prefix=/usr --extra-version='1~deb10u1' --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-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --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-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --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-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
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
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Input #0, lavfi, from 'anullsrc=channel_layout=mono:sample_rate=44100':
Duration: N/A, start: 0.000000, bitrate: 352 kb/s
Stream #0:0: Audio: pcm_u8, 44100 Hz, mono, u8, 352 kb/s
[NULL # 0x560516626f40] Unable to find a suitable output format for 'pipe:'
pipe:: Invalid argument
EDIT 2:
After Gyan provided a solution in the comments the error above doesn't show anymore but my result audio is being broken and doesn't come out as expected. Now the command that generates and appends the silent audio is like this:
ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -t <Time in seconds> -f s16le - > /tmp/gapFakeMic
Edit 3:
I've made some changes to the command I'm using to pipe silence to the virtual mic. I think the pipe is breaking because of some incompatibility in audio formats. I hope I can find a solution in the next few days. After every little change I realize some improvements. Now I can hear the silence between the keys sounds but it isn't recording all the audios I'm passing to it. Here's how the command is now:
ffmpeg -f lavfi -i anullsrc=channel_layout=mono:sample_rate=44100 -t <Time in seconds> -f s16le -ar 44100 -ac 1 - > /home/icaroerasmo/gapFakeMic`
I also realized that when I pipe the sound to a pipe file created inside my home folder the audio quality improves.
Edit 4:
After all this struggle it's clear now that the named pipe is breaking in the second time it's called. I've already googled how to flush a named pipe but I didn't find anything that worked.
I am new to streaming and am trying to figure out how to transcode streams via ffmpeg.
I have a few raw rtp uncompressed streams where some are on address 239.x.x.x and others are on 169.x.x.x.
I want to setup an RTSP server to grab those streams and transcode them into H264 and stream them out to a new address and port.
I have tried some ffmpeg commands but I keep getting errors about having to compile ffmpeg with pthreads.
I have no idea how to do that so does anyone know what commands I can use that will work with the current windows version of ffmpeg?
For now, I am just trying to save the stream to a file to see if that works. Command I am using is:
ffmpeg -i rtp://224.1.1.10:6972 transcoded test.mp4
and the return I get in the command line is
ffmpeg version 4.1.3 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 8.3.1 (GCC) 20190414
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-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 --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
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
[udp # 000002cb292abf40] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[udp # 000002cb292bc200] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
rtp://224.1.1.10:6972: Immediate exit requested
Exiting normally, received signal 2.
Try TCP instead of UDP. If your server outputs TCP you can try adding the input option(s) -rtsp_flags prefer_tcp and/or -rtsp_transport tcp (place them before -i).
Or use a build of ffmpeg that supports pthreads.
I am trying to convert a video that have multiple video streams and one audio stream from mxf format to mp4 format and getting an error. How can i solve this problem? Thank you.
E:\video>ffmpeg -loglevel error -y -i E:\video\19_12_2018\Files\MEDIA\media_data.mxf -map 0 -c:v h264_nvenc -acodec copy nvidia_output.mp4
[h264_nvenc # 0000020b30c86e80] OpenEncodeSessionEx failed: out of memory (10)
[h264_nvenc # 0000020b30c86e80] No NVENC capable devices found
Error initializing output stream 0:2 -- Error while opening encoder for output stream #0:2 - maybe incorrect parameters such as bit_rate, rate, width or height
[h264_nvenc # 00000204c1e37040] OpenEncodeSessionEx failed: out of memory (10)
[h264_nvenc # 00000204c1e37040] No NVENC capable devices found
[h264_nvenc # 00000204c1e37040] Nvenc unloaded
[jpeg2000 # 00000204c2d90080] End mismatch 1
Last message repeated 1 times
Error initializing output stream 0:2 -- Error while opening encoder for output stream #0:2 - maybe incorrect parameters such as bit_rate, rate, width or height
My FFPROBE output
E:\video>ffmpeg ffprobe
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 8.2.1 (GCC) 20181017
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig
--enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype
--enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb
--enable-libopenjpeg --enable-libopus --enable-libshine --enable-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
--enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa
--enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf
--enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec
--enable-dxva2 --enable-avisynth
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
The error you're seeing is expected, if you're using a consumer-grade NVIDIA GPU wherein the maximum simultaneous NVENC session limit of 2 is enforced at the firmware and driver level. See the NVIDIA GPU Matrix for more information on this.
There are two ways you can overcome this limitation:
1. Explicitly select the video stream(s) you desire to encode, via -map options, such that only two video streams are encoded at any given time per session. The example below explicitly selects the first and second video stream only:
E:\video>ffmpeg -loglevel error -y -i E:\video\19_12_2018\Files\MEDIA\media_data.mxf -map 0:v:0 -map 0:v:1 -map:0:a -c:v h264_nvenc -acodec copy nvidia_output.mp4
It would be awesome if you'd provide the ffprobe output for the input file you're working with, and that way, we can suggest what to do with the other video streams. An alternative to such would be falling back to a software-based encoder (such as x264) if so needed.
2. Override the aforementioned NVENC session count limit above: This will require you to patch the NVIDIA driver, as documented in this repository. Instructions for Linux are also available here.
I've been using FFMPEG on Windows to:
Convert iTunes M4A files to MP3s (with a bit rate of 128k); and
Create 30 sec sample MP3s of the above MP3s (same bit rate).
When I run FFMEG on a Windows 7 64 bit machine, the size of the MP3s (both for 1. & 2.) is in line with the rough calculation of:
(Audio length in seconds) X (Bit rate)
For example, a 4 minute audio yields an approx. 3.7MB MP3 file; a 30 second sample MP3 is approx. 470KB.
However when I run the same FFMPEG binary (copied from the Windows 7 machine) on a Windows 10 64 bit machine, all of the MP3s (both for 1. and for 2.) are inflated by approx 5MB. I'm using the same batch file on both machines to execute FFMEG with the required parameters, so pretty confident the difference is not down to user error.
My questions are:
Why is there this apparent 5MB overhead on Windows 10? and more importantly;
What can I do to remove this?
The large file size is a problem as the sample MP3s are to be put on a website for people to listen to a snippet of the song, and the webpage with multiple tags takes a long time to load completely (several minutes).
Here is the version and lib info:
ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 7.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libshine --enable-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 --enable-libvidstab --enable-libvorbis --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx
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
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
And here are the command lines I'm using:
ffmpeg -i input.m4a -id3v2_version 3 -b:a 128k -output.mp3
ffmpeg -i input.m4a -ss 30 -t 30 -af "afade=in:st=30:d=5,afade=out:st=55:d=5" -id3v2_version 3 -b:a 128k -output.mp3
Used the FFMPEG switch -vn to remove the video stream from the output, and that dramatically reduced the size of the MP3s (down to what was expected).
Turns out there was a difference between the FFMPEG parameters being used on each machine. On one machine the "sample" MP3 was starting from the beginning of the track (-ss 0) and this was the one with the album cover art PNG embedded in the video stream). The other machine's parameters was starting the "sample" from 30 seconds in (-ss 30) and this was not include the album cover art.
Interesting difference - not sure if it's deliberate - but that explains what was happening.
In the provided example I was trying to transcode a 4K h264 source to a 1080p h264 output using Nvidia's Hardware acceleration.
Relevant information:
ffmpeg version git-2017-12-25-613f789 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 7.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-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 --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-amf --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx
libavutil 56. 7.100 / 56. 7.100
libavcodec 58. 9.100 / 58. 9.100
libavformat 58. 3.100 / 58. 3.100
libavdevice 58. 0.100 / 58. 0.100
libavfilter 7. 7.100 / 7. 7.100
libswscale 5. 0.101 / 5. 0.101
libswresample 3. 0.101 / 3. 0.101
libpostproc 55. 0.100 / 55. 0.100
Command used:
ffmpeg -c:v h264_cuvid -i "4K_input.mp4" -c:v h264_nvenc -preset slow -s 1920x1080 -c:a copy output.mkv
Relevant PC Specs:
GPU: (Gigabyte) GeForce GTX 1070 Ti
CPU: Intel Core i7 7700K
Memory: 8GB DDR4 2400MHz Single Channel.
SSD: Crucial CT525MX3
While the Nvidia Desktop recording has absolutely no issues to record live h264 video in up to 50Mbps bitrates, this encoding at below 2600kbps was extremely slow utilizing barely 35% GPU.
I was unable to utilize 100% of the GPU on any video parameters.
This is why I could use some advice concerning how to identify a (suspected) bottleneck.
"GPU" transcoding does not work that way. There are fixed function circuits dedicated to h264 encoding on Nvidia GPUs that are not part of the vector unit pool. This is why you specify h264_nvenc (nvenc is Nvidia specific) and not a generic gpu encoder.
TLDR, you won't reach 100% GPU because its not really using the GPU. Its using a separate component that comes with your GPU.