I'm trying to record video from my ip camera stream with ffmpeg in command line
fmpeg -rtsp_transport tcp \
> -i rtsp://192.168.0.250/stream1 \
> -c copy \
> -map 0 \
> -f segment \
> -segment_time 60 \
> -segment_format mp4 \
> "/home/video/stream-0d.mp4"
and got the next output:
ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
configuration: --prefix=/usr --extra-version=1ubuntu0.1 --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-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, rtsp, from 'rtsp://192.168.0.250/stream1':
Metadata:
title : Session streamed by "nessyMediaServer"
comment : h264
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 2048x1536 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1: Data: none
[segment @ 0x559e20000980] Opening '/home/video/stream-0000000000.mp4' for writing
[mp4 @ 0x559e1fffc180] Could not find tag for codec none in stream #1, codec not currently supported in container
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)
Last message repeated 1 times
Tried some different options like -c:v libx265
or -c:v libx264
but it does not works the output is a little different. But the main error is the same:
Could not find tag for codec none in stream #1, codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
UPD: Tried the next command:
ffmpeg -rtsp_transport tcp \
-i rtsp://192.168.0.250/stream1 \
-c copy \
-map 0 \
-f segment \
-segment_time 60 \
-segment_format avi \
"/home/video/stream-0d.avi"
It started to record video but with errors:
fmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
configuration: --prefix=/usr --extra-version=1ubuntu0.1 --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-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, rtsp, from 'rtsp://192.168.0.250/stream1':
Metadata:
title : Session streamed by "nessyMediaServer"
comment : h265
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: hevc (Main), yuvj420p(pc, bt709), 2048x1536 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 90k tbn, 25 tbc
Stream #0:1: Data: none
[segment @ 0x562200721d80] Opening '/home/evgeniy/video/stream-0000000000.avi' for writing
Output #0, segment, to '/home/video/stream-0d.avi':
Metadata:
title : Session streamed by "nessyMediaServer"
comment : h265
encoder : Lavf58.29.100
Stream #0:0: Video: hevc (Main), yuvj420p(pc, bt709), 2048x1536 [SAR 1:1 DAR 4:3], q=2-31, 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream #0:1: Data: none
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[segment @ 0x562200721d80] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[segment @ 0x562200721d80] Non-monotonous DTS in output stream 0:0; previous: 202, current: 202; changing to 203. This may result in incorrect timestamps in the output file.
...
[segment @ 0x562200721d80] Non-monotonous DTS in output stream 0:0; previous: 748, current: 748; changing to 749. This may result in incorrect timestamps in the output file.
[segment @ 0x562200721d80] Opening '/home/video/stream-0000000001.avi' for writing
[avi @ 0x56220077d800] Too large number of skipped frames 5417887 > 6000001x
av_interleaved_write_frame(): Invalid argument
[avi @ 0x56220077d800] Too large number of skipped frames 5407879 > 60000
frame= 1505 fps= 25 q=-1.0 Lsize=N/A time=00:01:00.24 bitrate=N/A speed=1.01x
video:5314kB audio:0kB subtitle:0kB other streams:359kB global headers:0kB muxing overhead: unknown
Conversion failed!
CodePudding user response:
Stream #0:1 is unknown data, but the MP4 muxer does not know what to do with that.
- Map only the video by changing
-map 0
to-map 0:v
. - Or keep
-map 0
and omit the data stream by adding-map -0:d
.
See FFmpeg Wiki: Map.