0

I am trying to work through a tutorial I found online that converts an RTSP URL to a HSL stream. Upon executing the command on ubuntu 20.04, I get the following error:

"[NULL @ 0x55985b9bab80] Unable to find a suitable output format for 'ffmpeg' ffmpeg: Invalid argument"

These were my commands:

ffmpeg -v info \
-i <RTSP URL> \
-c:v copy -c:a copy -bufsize 1835k -pix_fmt yuv420p \
-flags -global_header \
ffmpeg -hls_time 10 -hls_list_size 6 -hls_wrap 10 \
ffmpeg -start_number 1 Home/Documents/ffmpegsolution/video.m3u8

(The example said that I needed to provide my path to output, so I listed the directories that I wanted the file to go to - ffmpegsolution being the folder)

The tutorial I'm using is found on: https://www.thewebblinders.in/programming/article/rtsp-streaming-on-a-web-browser-6069

It essentially shows that you can convert an rtsp url to a HSL file and stream it using html templates, however I can't get passed the conversion stage.

Any help would be appreciated. My thinking is that maybe one of my formats like "m3u8" isn't recognised; however I'm not sure.

Thank you for your time,

Alvydas Juodikis
  • 163
  • 1
  • 3
  • 15
  • 1
    You are mixing 3 different commands. **1.** `ffmpeg -v info -i -c:v copy -c:a copy -bufsize 1835k -pix_fmt yuv420p -flags -global_header` **2.** `ffmpeg -hls_time 10 -hls_list_size 6 -hls_wrap 10` **3.** `ffmpeg -start_number 1 Home/Documents/ffmpegsolution/video.m3u8`. What is ``? Are you replacing it with a URL address? – Rotem Jun 03 '21 at 13:47
  • Yes I input my RTSP in this standard https://www.xsplit.com/support/broadcaster/troubleshooting/rtsp-url-formatting . The example I was following showed that they input the entire list of commands either seperately or linked with "\" and it handles the locating of the url, conversion and output. Tho I'm not sure why it's failing to find a suitable format. – Alvydas Juodikis Jun 04 '21 at 10:21
  • You can't just place ``\`` every where, and expect thing to work... Read the following [post](https://stackoverflow.com/questions/3871332/how-to-tell-bash-that-the-line-continues-on-the-next-line). – Rotem Jun 04 '21 at 10:41
  • Ok I see, thank you for your help. – Alvydas Juodikis Jun 04 '21 at 11:25
  • When running these 3 commands seperately I still get the exact same error. After the frist command I get a warning stating "At least one output file must be specified" After the 2nd I get "Output #0, hls, to 'Home/Documents/fmpegsolution/onvif.m3u8': Output file #0 does not contain any stream" – Alvydas Juodikis Jun 04 '21 at 11:33
  • I think that the backslashs are in place, but the ffmpeg at the beginning of each line should be removed (keep only the first ffmpeg). – Rotem Jun 04 '21 at 16:12
  • @Rotem When trying to use the backslashes and removing the ffmpeg on other lines (only having one), I found I'm getting a newer error. "Could not write header for output file #0 (incorrect codec parameters ?): No such file or directory" – Alvydas Juodikis Jun 07 '21 at 07:54

2 Answers2

0

Delete the string ffmpeg in lines 5 and 6.

You are attempting to execute ffmpeg 3 times (line 1, 5 and 6). That makes no sense and is not mentioned in the tutorial.

The first ffmpeg call does not have an output. This is what the error means.

(Your line breaks \ are correct by the way.)

drake7
  • 952
  • 7
  • 20
  • Thank you for your answer. When I remove the ffmpeg from lines 5 and 6, I get another error: "Could not write header for output file #0 (incorrect codec parameters ?): No such file or directory" I'm not sure how to specify the output as I thought that the final line did this (Home/Documents/ffmpegsolution/video.m3u8) I was under the impression that I was saving the converted stream into a file in my directories. – Alvydas Juodikis Jun 10 '21 at 07:18
  • I tried outputting to the root folder and my error changes to "Output file #0 does not contain any stream" Does it mean that it has converted but there is no stream? I have checked my rtsp on a VLC player and am able to view a stream, so not sure what this error means. – Alvydas Juodikis Jun 10 '21 at 07:48
  • Does your source contain audio at all? Remove `-c:a copy ` and test. – drake7 Jun 10 '21 at 08:44
  • No it doesn't, just a cctv video stream – Alvydas Juodikis Jun 10 '21 at 09:49
  • I'm currently getting another error if I run the entire command as a single command ( ffmpeg -v info \ -i rtsp url \ -c:v copy -bufsize 1835k -pix_fmt yuv420p \ -flags -global_header \ -hls_time 10 -hls_list_size 6 -hls_wrap 10 \ -start_number 1 root/var/www/html/video.m3u8 ) The new error: "Could not write header for output file #0 (incorrect codec parameters ?): Permission denied" – Alvydas Juodikis Jun 10 '21 at 10:04
  • change `-c:v copy` to `-c:v libx264 -preset ultrafast` – drake7 Jun 10 '21 at 10:08
  • I noticed that this error of permission denied occurs when I try to run the single command in my root directory. In my documents it just returns "No such file or directory" If I separate the command into two parts (the last line using ffmpeg) it then passes it through in the root directory, it asks for an output and then returns "Output does not contain stream" – Alvydas Juodikis Jun 10 '21 at 10:12
  • I've just changed copy to libx264... and the permission denied error has changed, the new error is "Could not write header for output file #0 (incorrect codec parameters ?): No such file or directory Error initializing output stream 0:0 --" – Alvydas Juodikis Jun 10 '21 at 10:14
  • This command "ffmpeg -v info \ -i rtsp url \ -c:v libx264 -preset ultrafast -bufsize 1835k -pix_fmt yuv420p \ -flags -global_header \ -hls_time 10 -hls_list_size 6 -hls_wrap 10 \ -start_number 1 root/var/www/html/video.m3u8" Returns an error of: "Could not write header for output file #0 (incorrect codec parameters ?): No such file or directory Error initializing output stream 0:0 --" – Alvydas Juodikis Jun 10 '21 at 10:58
  • In your shell, you have to `cd` into a directory where you have write permissions. For testing, simplify the output file. Don't use a path, write the file into the directory where you are. – drake7 Jun 10 '21 at 15:23
0

It turns out that the directory I needed to be in was through desktop and not in the Root Directory. I also needed to manually add the video file using "touch video.mu38" in the required directory. UDP still times out, but this doesn't generate a notable issue.

ffmpeg -v info
-i -c:v libx264 -preset ultrafast -bufsize 1835k -pix_fmt yuv420p
-flags -global_header -hls_time 10 -hls_list_size 6 -hls_wrap 10
-start_number 1 /path/to/output/video.mu38

Alvydas Juodikis
  • 163
  • 1
  • 3
  • 15