I've been currently trying to set up an encoding process from RTSP to HLS using FFmpeg, with success for most streams.
However, for streams/cameras with digest authentication, FFmpeg seems to fail with a classic 401 Unauthorized, as such:
ffmpeg -loglevel debug -i "rtsp://user:password#192.168.0.1/stream" /folder/output.m3u8
Giving:
ffmpeg version N-85750-ga75ef15 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 6.3.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
libavutil 55. 61.100 / 55. 61.100
libavcodec 57. 93.100 / 57. 93.100
libavformat 57. 72.101 / 57. 72.101
libavdevice 57. 7.100 / 57. 7.100
libavfilter 6. 88.100 / 6. 88.100
libswscale 4. 7.101 / 4. 7.101
libswresample 2. 8.100 / 2. 8.100
libpostproc 54. 6.100 / 54. 6.100
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-i' ... matched as input url with argument 'rtsp://username:password#192.168.0.1/stream'.
Reading option '/folder/output.m3u8' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input url rtsp://username:password#192.168.0.1/stream2.
Successfully parsed a group of options.
Opening an input file: rtsp://username:password#192.168.0.1/stream.
[tcp # 00000000025c3900] No default whitelist set
[rtsp # 00000000025c2560] method OPTIONS failed: 401 Unauthorized
[rtsp # 00000000025c2560] CSeq: 2
WWW-Authenticate: Digest realm="Use 'live' as User Name", nonce="2ae726f5557769220b780deb4f562226", algorithm=MD5, qop="auth"
rtsp://user:password#192.168.0.1/stream: Server returned 401 Unauthorized (authorization failed)
I've checked that the camera is accessible and the input URI works in VLC. The camera I'm trying to obtain the stream from is a Bosch one.
I've searched and searched over the Internet but I didn't find any concrete solution to this.
Any ideas?
maybe rtsp default port->554
ffmpeg -loglevel debug -i "rtsp://user:password#192.168.0.1/stream" /folder/output.m3u8
correct :
ffmpeg -loglevel debug -i "rtsp://user:password#192.168.0.1:554/stream" /folder/output.m3u8
Related
I'm generating thumbnails for a videos that are available from s3 and need to minimize traffic.
Frame is going to be from the first couple seconds of the video so the question: is there a way to get frame without passing the full file through network?
At the moment I'm passing video url to ffmpeg but seems like it downloads the whole file, not only first couple seconds.
ffmpeg -ss 0 -noaccurate_seek -i {srcPresignedUrl} -vframes 1 -q:v 2 {outputFileName}
I tried downloading first 10mb of the file and passing it, this works for some mp4 files, but fails on mov:
ffmpeg.exe -ss 0 -i source.mov -vframes 1 -q:v 2 thumb.jpg
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 10.2.1 (GCC) 20200726
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --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-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libgsm --enable-librav1e --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
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
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
[mov,mp4,m4a,3gp,3g2,mj2 # 0000017582ffff40] moov atom not found
source.mov: Invalid data found when processing input
That's true. Some mp4 files are streaming-ready, but often they are not. The trick is that the moov atom (in simple English, the table of contents of the video file) is normally prepared during the file encoding and attached to the end. There are different ways to move this information to the head of the stream (see Post processing in ffmpeg to move 'moov atom' in MP4 files (qt-faststart)), but this requires rebuilding the video.
I want to replace the audio stream in a Video-DVD. But I have problems with the replace of the audio stream.
The DVD-VOB have 3 streams.
Stream 0 is dvd_nav_packet.
Stream 1 is the video.
Stream 2 is the audio.
I also tryed to change the exportinformation for ffmepg with -map 0:d and -map 0:d:1. Also with and without from the codec Infos -f vob -target ntsc-dvd -vcodec copy -acodec copy. And update ffmpeag/use older versions. But I only get error messages.
ffmpeg is startet with a vb.net Programm which which decide which video need a new audio file.
Can somebody tell me what I do wrong?
ffmpeg.exe -i "F:\VIDEO_TS\VTS_01_1.VOB" -i "%CD%\tfpat.mp2" -map 0:0 -map 0:1 -map 1:0 -f vob -target ntsc-dvd -vcodec copy -acodec copy "C:\Users\Timo\AppData\Local\Microsoft\Windows\Burn\Burn\VIDEO_TS\VTS_01_1.VOB"
ffmpeg version N-88514-gd5995c531d Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 7.2.0 (GCC)
configuration: --disable-static --enable-shared --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 56. 0.100 / 56. 0.100
libavcodec 58. 1.100 / 58. 1.100
libavformat 58. 0.102 / 58. 0.102
libavdevice 58. 0.100 / 58. 0.100
libavfilter 7. 0.101 / 7. 0.101
libswscale 5. 0.101 / 5. 0.101
libswresample 3. 0.101 / 3. 0.101
libpostproc 55. 0.100 / 55. 0.100
Input #0, mpeg, from 'F:\VIDEO_TS\VTS_01_1.VOB':
Duration: 00:01:51.17, start: 0.300300, bitrate: 7273 kb/s
Stream #0:0[0x1bf]: Data: dvd_nav_packet
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, progressive), 720x480 [SAR 32:27 DAR 16:9], 6800 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
Stream #0:2[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 320 kb/s
[ac3 # 037ee700] Estimating duration from bitrate, this may be inaccurate
Input #1, ac3, from 'D:\SkyDrive\Projekte\AtmosFX_Syncro_Projekt\AtmosFX-Translator\AlteVersionen\Version 2\tfpat.mp2':
Duration: 00:01:51.26, start: 0.000000, bitrate: 320 kb/s
Stream #1:0: Audio: ac3, 48000 Hz, stereo, fltp, 320 kb/s
File 'C:\Users\Timo\AppData\Local\Microsoft\Windows\Burn\Burn\VIDEO_TS\VTS_01_1.VOB' already exists. Overwrite ? [y/N] y
[dvd # 037fbd20] Invalid media type data for output stream #0
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Stream #1:0 -> #0:2 (copy)
Last message repeated 1 times
FFmpeg will not copy over the existing navigation packet, so skip it.
ffmpeg.exe -i "F:\VIDEO_TS\VTS_01_1.VOB" -i "%CD%\tfpat.mp2" -map 0:v -map 1:a -f vob -target ntsc-dvd -vcodec copy -acodec copy "C:\Users\Timo\AppData\Local\Microsoft\Windows\Burn\Burn\VIDEO_TS\VTS_01_1.VOB"
Recently, I see this error very often. Does anyone know what the error is and how to fix ? Please check full ffmpeg output here ( I already update openssl latest version from yum )
ffmpeg version N-93715-gd0e4d04 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-36)
configuration: --prefix= ....
Input #0, mpegts, from '/tmp/4028813_video_0.ts':
Duration: 00:04:08.19, start: 1.410111, bitrate: 1504 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, progressive), 608x1080 [SAR 1:1 DAR 76:135], 30 fps, 30 tbr, 90k tbn, 60 tbc
Stream #0:1[0x101](eng): Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 121 kb/s
[ sh: 2019-05-06 9:39:46 ]
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
Output #0, flv, to 'rtmps://live-api-s.facebook.com:443/rtmp/289693778580218?s_bl=1&s_sw=0&s_vt=api-s&a=Abxj1aU9OTqh0RtS':
Metadata:
comment : gs4028813
encoder : Lavf58.27.103
Stream #0:0: Video: h264 (High) ([7][0][0][0] / 0x0007), yuv420p(tv, bt709, progressive), 608x1080 [SAR 1:1 DAR 76:135], q=2-31, 3000 kb/s, 30 fps, 30 tbr, 1k tbn, 30 tbc
Stream #0:1(eng): Audio: aac (LC) ([10][0][0][0] / 0x000A), 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc58.52.100 aac
[ sh: 2019-05-06 9:39:47 ]size= 169kB time=00:00:00.52 bitrate=2643.9kbits/s speed=1.03x
......
[ sh: 2019-05-06 9:40:10 ]size= 3386kB time=00:00:22.72 bitrate=1220.7kbits/s speed=0.999x
[ sh: 2019-05-06 9:40:11 ]size= 3842kB time=00:00:25.32 bitrate=1242.9kbits/s speed= 1x
[tls # 0x30ab3c0] error:00000000:lib(0):func(0):reason(0)82 bitrate=1247.3kbits/s speed= 1x
av_interleaved_write_frame(): Input/output error
[flv # 0x3030f80] Failed to update header with correct duration.
[flv # 0x3030f80] Failed to update header with correct filesize.
Error writing trailer of rtmps://live-api-s.facebook.com:443/rtmp/289693778580218?s_bl=1&s_sw=0&s_vt=api-s&a=Abxj1aU9OTqh0RtS: Input/output error
frame= 776 fps= 30 q=-1.0 Lsize= 3932kB time=00:00:25.82 bitrate=1247.3kbits/s speed= 1x
video:3530kB audio:406kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[tls # 0x30ab3c0] error:1409F07F:SSL routines:ssl3_write_pending:bad write retry
This error normally indicates a bug in the program calling OpenSSL. When an application using OpenSSL attempts to write application data to an SSL/TLS connection using the "SSL_write" function it may be unable to complete the write in one go (for example because the underlying network buffers are full). In this case a recoverable "retry" error occurs. The application is supposed to retry the write with exactly the same data as last time. If the calling application retries the write with different data then you get the "bad write retry" message (a fatal error). As to how to fix it that unfortunately depends on identifying the bug in the calling application and ensuring that retries are only ever performed with exactly the same data.
I am trying the following command, so that my webcam shows a video when i access it from network or android emulator.
I am using archlinux. I have installed v4l2loopback-dkms. and added the module to the kernel. then i launched
gst-launch-0.10 filesrc location=/home/simha/1.3gp ! decodebin2 ! ffmpegcolorspace ! videoscale ! ffmpegcolorspace ! v4l2sink device=/dev/video0
but no sucess.
Setting pipeline to PAUSED ...
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0: Device '/dev/video0' is not a output device.
Additional debug info:
v4l2_calls.c(528): gst_v4l2_open (): /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0:
Capabilities: 0x85200001
Setting pipeline to NULL ...
Freeing pipeline ...
Also tried:
ffmpeg -f x11grab -r 15 -s 1280x720 -i :0.0+0,0 -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0
but not working
ffmpeg version 2.8 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 5.2.0 (GCC)
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-shared --enable-version3 --enable-x11grab
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, x11grab, from ':0.0+0,0':
Duration: N/A, start: 1456374857.672770, bitrate: N/A
Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1280x720, 15 fps, 15 tbr, 1000k tbn, 15 tbc
[v4l2 # 0x55f5129180a0] ioctl(VIDIOC_G_FMT): Invalid argument
Output #0, v4l2, to '/dev/video0':
Metadata:
encoder : Lavf56.40.101
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720, q=2-31, 200 kb/s, 15 fps, 15 tbn, 15 tbc
Metadata:
encoder : Lavc56.60.100 rawvideo
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
You might be using the wrong driver for your webcam.
Use the lsusb command to identify your webcam. Then find out what driver you need to get it working. You can find out more information about this by reading the Webcam Arch Wiki Page
I am running this script to view cameras on network:
gst-launch udpsrc port=1234 ! "application/x-rtp, payload=127" ! rtph264depay ! ffdec_h264 ! xvimagesink sync=false
I am getting this error:
WARNING: erroneous pipeline: no element "ffdec_h264"
I am getting error with ffdec_h264. I have all the packages from g-streamer but I don't know which one I am missing.
when I run gst-inspect | grep 264
I get this output:
h264parse: legacyh264parse: H264Parse
x264: x264enc: x264enc
videoparsersbad: h264parse: H.264 parser
typefindfunctions: video/x-h264: h264, x264, 264
rtp: rtph264pay: RTP H264 payloader
rtp: rtph264depay: RTP H264 depayloader
Which shows I don't have this ffdec_h264
which package I am missing?
This might depend on your OS/distribution and GStreamer version.
Over here (Debian jessie, GStreamer 0.10.36) gst-inspect ffdec_h264 gives the following output:
Factory Details:
Long name: FFmpeg H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 decoder
Class: Codec/Decoder/Video
Description: FFmpeg h264 decoder
Author(s): Wim Taymans <wim.taymans#gmail.com>, Ronald Bultje <rbultje#ronald.bitfreak.net>, Edwar$
Rank: primary (256)
Plugin Details:
Name: ffmpeg
Description: All FFmpeg codecs and formats (system install)
Filename: /usr/lib/x86_64-linux-gnu/gstreamer-0.10/libgstffmpeg.so
Version: 0.10.13
License: GPL
Source module: gst-ffmpeg
Binary package: FFmpeg
Origin URL: http://ffmpeg.org/
So on my system, ffdec_h264 is in the gst-ffmpeg module (which was installed using apt-get install gstreamer0.10-ffmpeg).
You have to enter this command and have an idea what h264 decoder you have with gstreamer, in other words what Gstreamer is calling it.
gst-inspect | grep "h264"