Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffmpeg Invalid argment while running example.ts #170

Closed
axacheng opened this issue Nov 29, 2021 · 10 comments · Fixed by #171
Closed

ffmpeg Invalid argment while running example.ts #170

axacheng opened this issue Nov 29, 2021 · 10 comments · Fixed by #171
Assignees

Comments

@axacheng
Copy link

axacheng commented Nov 29, 2021

Hi boony

First of all, thanks you for developing this awesome node library, it'd be very useful for me and make my life easier to build a live streaming cache CDN. However, by some reason, I cannot make it work as I'm not sure the server side issue or ffmpeg decode issue. I got Unable to find a suitable output format for 'cam' this error mesg and node process got exited. I didn't see any 'cam' keyword in my code and your rtsp-video-recorder, so I assume it might be came from ffmpeg ?

Could you please verify it for me ?

Thank you so much.

axa@wordpress-1-vm:~/default/rtsp-video-recorder$ export SOURCE="rtsp://USERNAME:PASSWORD@finallyhome.tplinkdns.com:6666/stream2"
axa@wordpress-1-vm:~/default/rtsp-video-recorder$ export DESTINATION="."
axa@wordpress-1-vm:~/default/rtsp-video-recorder$ npm run example
npm WARN npm npm does not support Node.js v10.24.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/

> rtsp-video-recorder@2.0.1-alpha.6 example /home/axa/default/rtsp-video-recorder
> tsc -p tsconfig.example.json && node example/example.js

rtsp://USERNAME:PASSWORD@finallyhome.tplinkdns.com:6666/stream2
Mon Nov 29 2021 12:16:27 GMT+0000 (Coordinated Universal Time)
Event "start":  programmatically

Press "space" to start/stop recording, "ctrl + c" to stop a process.

Mon Nov 29 2021 12:16:28 GMT+0000 (Coordinated Universal Time)
Event "progress":  ffmpeg version 4.1.8-0+deb10u1 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version=0+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


Mon Nov 29 2021 12:16:28 GMT+0000 (Coordinated Universal Time)
Event "progress":    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


Mon Nov 29 2021 12:16:30 GMT+0000 (Coordinated Universal Time)
Event "progress":  Guessed Channel Layout for Input Stream #0.1 : mono


Mon Nov 29 2021 12:16:30 GMT+0000 (Coordinated Universal Time)
Event "progress":  Input #0, rtsp, from 'rtsp://USERNAME:PASSWORD@finallyhome.tplinkdns.com:6666/stream2':
  Metadata:
    title           : Session streamed by "TP-LINK RTSP Server"
    comment         : stream2


Mon Nov 29 2021 12:16:30 GMT+0000 (Coordinated Universal Time)
Event "progress":    Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 640x360, 15 fps, 29.75 tbr, 90k tbn, 30 tbc
    Stream #0:1: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s
[NULL @ 0x5628d4974d40] Unable to find a suitable output format for 'cam'
cam: Invalid argument


Mon Nov 29 2021 12:16:30 GMT+0000 (Coordinated Universal Time)
Event "stopped":  1 ffmpeg_exited

@boonya boonya self-assigned this Nov 30, 2021
@boonya
Copy link
Owner

boonya commented Nov 30, 2021

Hello, @axacheng
I am glad to see it's useful for other people )

So, as for your issue, I am not sure what can be the root cause of it. I didn't have a chance to find something similar so far. The most closer error message is:

09-23 09:29:41.525: E/Home(31343): [NULL @ 0x41f7f420] Unable to find a suitable output format for 'ffmpeg'
09-23 09:29:41.525: E/Home(31343): ffmpeg: Invalid argument

Just finger to the sky... Let's check whether your ffmpeg response the same if you query it directly.
Try:

ffmpeg \
    -rtsp_transport tcp \
    -i rtsp://USERNAME:PASSWORD@finallyhome.tplinkdns.com:6666/stream2 \
    -reset_timestamps 1 \
    -strftime 1 \
    -strftime_mkdir 1 \
    -hls_time 600 \
    -hls_list_size 0 \
    -hls_segment_filename %Y.%m.%d-%H.%M.%S.mp4 \
    ./playlist.m3u8

Also, I am not sure about your DESTINATION variable. Try to use absolute path instead of relative.

Let me know how is it going.

@boonya boonya added the question Further information is requested label Nov 30, 2021
@axacheng
Copy link
Author

axacheng commented Dec 1, 2021

Hello Boonya

Thank you for quick reply. I tried to run ffmpeg command from terminal and I got output file with current timestamp as well as playlist.m3u8 file. Everything just worked from ffmpeg command!

From my last thread, I used DESTINATION="." for environment variable but I just used absolute path now. DESTINATION="/home/axa/" , but still got same error - cam:Invalid argument. I don't know where to set cam argument and not sure what suitable output format meant from npm run example command output ~

Could you let me know what ffmpeg version you use and what nodejs version is ?

Thank you

@boonya
Copy link
Owner

boonya commented Dec 1, 2021

Interesting.
Actually I tried it with latest nodejs which is 16 currently, but couple of minutes ago I tried to run it under 10.24.0 (which I see from your logs) and it works as. expected.

@boonya
Copy link
Owner

boonya commented Dec 1, 2021

I have it tested on my Macbook Pro M1 where (nodejs 10.24 & nodejs 16.13) ffmpeg version installed:

ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 13.0.0 (clang-1300.0.29.3)
configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/4.4.1_3 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-avresample --enable-videotoolbox
libavutil      56. 70.100 / 56. 70.100
libavcodec     58.134.100 / 58.134.100
libavformat    58. 76.100 / 58. 76.100
libavdevice    58. 13.100 / 58. 13.100
libavfilter     7.110.100 /  7.110.100
libavresample   4.  0.  0 /  4.  0.  0
libswscale      5.  9.100 /  5.  9.100
libswresample   3.  9.100 /  3.  9.100
libpostproc    55.  9.100 / 55.  9.100

Also it works to me on a RaspberryPi B3+ (Ubuntu Server 20.04.3 LTS) with nodejs 16.13 & ffmpeg installed:

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/aarch64-linux-gnu --incdir=/usr/include/aarch64-linux-gnu --arch=arm64 --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-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

@axacheng
Copy link
Author

axacheng commented Dec 1, 2021

This is my screenshot ~ I use Google Cloud GCE

axa@wordpress-1-vm:~/default/rtsp-video-recorder$ cat /etc/debian_version
10.11
axa@wordpress-1-vm:~/default/rtsp-video-recorder$
axa@wordpress-1-vm:~/default/rtsp-video-recorder$ node -v
v10.24.0
axa@wordpress-1-vm:~/default/rtsp-video-recorder$ ffmpeg --version
ffmpeg version 4.1.8-0+deb10u1 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version=0+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
Unrecognized option '-version'.
Error splitting the argument list: Option not found
axa@wordpress-1-vm:~/default/rtsp-video-recorder$

@boonya
Copy link
Owner

boonya commented Dec 1, 2021

I have an idea!
Try to pass additional env variable TITLE with value which does not contain spaces and any special characters.
Lets see what we get

E.g.

export TITLE="test-cam"

Here is the "cam" word you may be experiencing this issue about.

@axacheng
Copy link
Author

axacheng commented Dec 1, 2021

144268291-1e7bb2fd-df12-4f42-80f5-dd972556dbd6

@boonya
Copy link
Owner

boonya commented Dec 1, 2021

Yep, I got the issue
image

So, temporary workaround is to assign you own TITLE with no spaces inside.

@axacheng
Copy link
Author

axacheng commented Dec 1, 2021

it's working now!

Stream #0:1: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s
Wed Dec 01 2021 16:13:37 GMT+0000 (Coordinated Universal Time)
Event "progress": Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (pcm_alaw (native) -> aac (native))
Press [q] to stop, [?] for help

Wed Dec 01 2021 16:13:37 GMT+0000 (Coordinated Universal Time)
Event "progress": [aac @ 0x555d7079c600] Too many bits 8832.000000 > 6144 per frame requested, clamping to max

Wed Dec 01 2021 16:13:37 GMT+0000 (Coordinated Universal Time)
Event "progress": [libx264 @ 0x555d70798e00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2

Wed Dec 01 2021 16:13:37 GMT+0000 (Coordinated Universal Time)
Event "progress": [libx264 @ 0x555d70798e00] profile High, level 2.2

Wed Dec 01 2021 16:13:37 GMT+0000 (Coordinated Universal Time)
Event "progress": [libx264 @ 0x555d70798e00] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - 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=3 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=15 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

Wed Dec 01 2021 16:13:37 GMT+0000 (Coordinated Universal Time)
Event "progress": [hls @ 0x555d707805c0] Opening 'test-cam-2021.12.01/16.13.37.mp4' for writing

Wed Dec 01 2021 16:13:37 GMT+0000 (Coordinated Universal Time)
Event "file_created": test-cam-2021.12.01/16.13.37.mp4

Wed Dec 01 2021 16:13:37 GMT+0000 (Coordinated Universal Time)
Event "progress": Output #0, hls, to './2021.12.01-16.13.34.m3u8':
Metadata:
comment : stream2
title : test-cam
encoder : Lavf58.20.100
Stream #0:0: Video: h264 (libx264), yuvj420p(pc), 640x360, q=-1--1, 15 fps, 90k tbn, 15 tbc
Metadata:
encoder : Lavc58.35.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: aac (LC), 8000 Hz, mono, fltp, 48 kb/s
Metadata:
encoder : Lavc58.35.100 aac

Wed Dec 01 2021 16:13:37 GMT+0000 (Coordinated Universal Time)
Event "started": { uri:
'rtsp://USERNAME:PASSWORD@finallyhome.tplinkdns.com:6666/stream2',
destination: '/home/axa/',
playlist: '2021.12.01-16.13.34.m3u8',
title: 'test-cam',
filePattern: 'test-cam-%Y.%m.%d/%H.%M.%S',
segmentTime: 600,
dirSizeThreshold: 524288000,
noAudio: false,
ffmpegBinary: 'ffmpeg' }

@boonya
Copy link
Owner

boonya commented Dec 1, 2021

Cool. "Thank you for flying with our airlines" )))

@axacheng axacheng closed this as completed Dec 1, 2021
@boonya boonya linked a pull request Dec 1, 2021 that will close this issue
@boonya boonya removed question Further information is requested work in progress labels Dec 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants