0

I'm using ffmpeg to transcode RTMP from my own RTMP server into HLS ready H.264. At the moment, I'm executing a command of the following form

ffmpeg -i rtmp://<ip>:<port> <options for 480p> <options for 720p30> <options for 720p60> <options for 1080p>

This is causing me to attempt to transcode lower resolutions to higher resolutions.

The RTMP server I'm using is nginx with RTMP module

Is there a way I can determine the source resolution, so that I only transcode into resolutions smaller than the source one?

toastedDeli
  • 570
  • 5
  • 28
  • 1
    Not in a single step. You need to probe the stream, then set the ffmpeg options based on the result. – szatmary Mar 12 '19 at 14:39
  • 1
    this might be helpful for you. https://superuser.com/questions/841235/how-do-i-use-ffmpeg-to-get-the-video-resolution – Vencat Mar 12 '19 at 17:37

1 Answers1

0

Thanks to @szatmary's comment I have found the following solution:

I can use the command line tool ffprobe to get information about a stream. Here is the documentation

It says here that

If a url is specified in input, ffprobe will try to open and probe the url content. If the url cannot be opened or recognized as a multimedia file, a positive exit code is returned.

ffprobe can be configured to use different writers and writing options so that it can return results in a range of formats.

toastedDeli
  • 570
  • 5
  • 28