Opened 3 months ago

Closed 2 months ago

Last modified 2 months ago

#11134 closed defect (fixed)

zmq url lacks prefix: [out#0/* @ 0x*] Error opening output zmq:tcp://127.0.0.1:5555: Invalid argument

Reported by: iconoclasthero Owned by:
Priority: important Component: avformat
Version: git-master Keywords: zmq regression
Cc: iconoclasthero, nanake Blocked By:
Blocking: 7.1 Reproduced by developer: no
Analyzed by developer: no

Description (last modified by iconoclasthero)

zmq streaming not working. ffmpeg compiled with --enable-libzmq.
the fifo it's trying to pull from works to output an encoded file.
no observed discrepancy between the documentation and the general use of the commands below.

Summary of the bug:
How to reproduce:

$ ffmpeg -y -nostdin -f s16le -ar 48000 -ac 2 -i /tmp/mpd.fifo -f mpegts zmq:tcp://127.0.0.1:5555
ffmpeg version N-116515-gd527d23872 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 14 (Ubuntu 14.1.0-5ubuntu1)
  configuration: --bindir=/usr/local/bin --prefix=/cache/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/cache/ffmpeg_build/include --extra-ldflags=-L/cache/ffmpeg_build/lib --extra-libs='-lpthread -lm' --ld=g++ --enable-gpl --enable-gnutls --enable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-libpulse --enable-libzmq
  libavutil      59. 31.100 / 59. 31.100
  libavcodec     61. 11.100 / 61. 11.100
  libavformat    61.  5.101 / 61.  5.101
  libavdevice    61.  2.100 / 61.  2.100
  libavfilter    10.  2.102 / 10.  2.102
  libswscale      8.  2.100 /  8.  2.100
  libswresample   5.  2.100 /  5.  2.100
  libpostproc    58.  2.100 / 58.  2.100
[aist#0:0/pcm_s16le @ 0x59859674ad80] Guessed Channel Layout: stereo
Input #0, s16le, from '/tmp/mpd.fifo':
  Duration: N/A, bitrate: 1536 kb/s
  Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[zmq @ 0x5985967552c0] URL tcp://127.0.0.1:5555 lacks prefix
[out#0/mpegts @ 0x59859674af00] Error opening output zmq:tcp://127.0.0.1:5555: Invalid argument
Error opening output file zmq:tcp://127.0.0.1:5555.
Error opening output files: Invalid argument

$ ffmpeg -y -nostdin -f s16le -ar 48000 -ac 2 -i /tmp/mpd.fifo -f nut -c:a libopus -b:a 128k zmq:tcp://127.0.0.1:5555
ffmpeg version N-116515-gd527d23872 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 14 (Ubuntu 14.1.0-5ubuntu1)
  configuration: --bindir=/usr/local/bin --prefix=/cache/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/cache/ffmpeg_build/include --extra-ldflags=-L/cache/ffmpeg_build/lib --extra-libs='-lpthread -lm' --ld=g++ --enable-gpl --enable-gnutls --enable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-libpulse --enable-libzmq
  libavutil      59. 31.100 / 59. 31.100
  libavcodec     61. 11.100 / 61. 11.100
  libavformat    61.  5.101 / 61.  5.101
  libavdevice    61.  2.100 / 61.  2.100
  libavfilter    10.  2.102 / 10.  2.102
  libswscale      8.  2.100 /  8.  2.100
  libswresample   5.  2.100 /  5.  2.100
  libpostproc    58.  2.100 / 58.  2.100
[aist#0:0/pcm_s16le @ 0x5c7cab802e00] Guessed Channel Layout: stereo
Input #0, s16le, from '/tmp/mpd.fifo':
  Duration: N/A, bitrate: 1536 kb/s
  Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[zmq @ 0x5c7cab807680] URL tcp://127.0.0.1:5555 lacks prefix
[out#0/nut @ 0x5c7cab802fc0] Error opening output zmq:tcp://127.0.0.1:5555: Invalid argument
Error opening output file zmq:tcp://127.0.0.1:5555.
Error opening output files: Invalid argument

$ ffmpeg -f s16le -ar 48000 -ac 2 -i /tmp/mpd.fifo -f mpegts -c:a libopus zmq:tcp://127.0.0.1:5555
ffmpeg version N-116515-gd527d23872 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 14 (Ubuntu 14.1.0-5ubuntu1)
  configuration: --bindir=/usr/local/bin --prefix=/cache/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/cache/ffmpeg_build/include --extra-ldflags=-L/cache/ffmpeg_build/lib --extra-libs='-lpthread -lm' --ld=g++ --enable-gpl --enable-gnutls --enable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-libpulse --enable-libzmq
  libavutil      59. 31.100 / 59. 31.100
  libavcodec     61. 11.100 / 61. 11.100
  libavformat    61.  5.101 / 61.  5.101
  libavdevice    61.  2.100 / 61.  2.100
  libavfilter    10.  2.102 / 10.  2.102
  libswscale      8.  2.100 /  8.  2.100
  libswresample   5.  2.100 /  5.  2.100
  libpostproc    58.  2.100 / 58.  2.100
[aist#0:0/pcm_s16le @ 0x5cc5bf825d80] Guessed Channel Layout: stereo
Input #0, s16le, from '/tmp/mpd.fifo':
  Duration: N/A, bitrate: 1536 kb/s
  Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[zmq @ 0x5cc5bf829680] URL tcp://127.0.0.1:5555 lacks prefix
[out#0/mpegts @ 0x5cc5bf825f00] Error opening output zmq:tcp://127.0.0.1:5555: Invalid argument
Error opening output file zmq:tcp://127.0.0.1:5555.
Error opening output files: Invalid argument

$ ffmpeg -f s16le -ar 48000 -ac 2 -i /tmp/mpd.fifo -f webm -c:a libopus output.webm
ffmpeg version N-116515-gd527d23872 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 14 (Ubuntu 14.1.0-5ubuntu1)
  configuration: --bindir=/usr/local/bin --prefix=/cache/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/cache/ffmpeg_build/include --extra-ldflags=-L/cache/ffmpeg_build/lib --extra-libs='-lpthread -lm' --ld=g++ --enable-gpl --enable-gnutls --enable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-libpulse --enable-libzmq
  libavutil      59. 31.100 / 59. 31.100
  libavcodec     61. 11.100 / 61. 11.100
  libavformat    61.  5.101 / 61.  5.101
  libavdevice    61.  2.100 / 61.  2.100
  libavfilter    10.  2.102 / 10.  2.102
  libswscale      8.  2.100 /  8.  2.100
  libswresample   5.  2.100 /  5.  2.100
  libpostproc    58.  2.100 / 58.  2.100
[aist#0:0/pcm_s16le @ 0x59dc60f39d80] Guessed Channel Layout: stereo
Input #0, s16le, from '/tmp/mpd.fifo':
  Duration: N/A, bitrate: 1536 kb/s
  Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_s16le (native) -> opus (libopus))
Press [q] to stop, [?] for help
[libopus @ 0x59dc60e6a140] No bit rate set. Defaulting to 96000 bps.
Output #0, webm, to 'output.webm':
  Metadata:
    encoder         : Lavf61.5.101
  Stream #0:0: Audio: opus, 48000 Hz, stereo, s16, 96 kb/s
      Metadata:
        encoder         : Lavc61.11.100 libopus
[out#0/webm @ 0x59dc60f39f00] video:0KiB audio:535KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 2.809126%
size=     550KiB time=00:00:41.72 bitrate= 108.0kbits/s speed=1.11x    
Exiting normally, received signal 2.

$ ffmpeg -f s16le -ar 48000 -ac 2 -i /tmp/mpd.fifo -f webm -c:a libopus zmq:tcp://127.0.0.1:5555
ffmpeg version N-116515-gd527d23872 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 14 (Ubuntu 14.1.0-5ubuntu1)
  configuration: --bindir=/usr/local/bin --prefix=/cache/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/cache/ffmpeg_build/include --extra-ldflags=-L/cache/ffmpeg_build/lib --extra-libs='-lpthread -lm' --ld=g++ --enable-gpl --enable-gnutls --enable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-libpulse --enable-libzmq
  libavutil      59. 31.100 / 59. 31.100
  libavcodec     61. 11.100 / 61. 11.100
  libavformat    61.  5.101 / 61.  5.101
  libavdevice    61.  2.100 / 61.  2.100
  libavfilter    10.  2.102 / 10.  2.102
  libswscale      8.  2.100 /  8.  2.100
  libswresample   5.  2.100 /  5.  2.100
  libpostproc    58.  2.100 / 58.  2.100
[aist#0:0/pcm_s16le @ 0x5bcd76aeed80] Guessed Channel Layout: stereo
Input #0, s16le, from '/tmp/mpd.fifo':
  Duration: N/A, bitrate: 1536 kb/s
  Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[zmq @ 0x5bcd76af2640] URL tcp://127.0.0.1:5555 lacks prefix
[out#0/webm @ 0x5bcd76aeef00] Error opening output zmq:tcp://127.0.0.1:5555: Invalid argument
Error opening output file zmq:tcp://127.0.0.1:5555.
Error opening output files: Invalid argument

$ ffmpeg -f s16le -ar 48000 -ac 2 -i /tmp/mpd.fifo -f nut -c:a libopus zmq:tcp://127.0.0.1:5555
ffmpeg version N-116515-gd527d23872 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 14 (Ubuntu 14.1.0-5ubuntu1)
  configuration: --bindir=/usr/local/bin --prefix=/cache/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/cache/ffmpeg_build/include --extra-ldflags=-L/cache/ffmpeg_build/lib --extra-libs='-lpthread -lm' --ld=g++ --enable-gpl --enable-gnutls --enable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-libpulse --enable-libzmq
  libavutil      59. 31.100 / 59. 31.100
  libavcodec     61. 11.100 / 61. 11.100
  libavformat    61.  5.101 / 61.  5.101
  libavdevice    61.  2.100 / 61.  2.100
  libavfilter    10.  2.102 / 10.  2.102
  libswscale      8.  2.100 /  8.  2.100
  libswresample   5.  2.100 /  5.  2.100
  libpostproc    58.  2.100 / 58.  2.100
[aist#0:0/pcm_s16le @ 0x5dc04e7a2d80] Guessed Channel Layout: stereo
Input #0, s16le, from '/tmp/mpd.fifo':
  Duration: N/A, bitrate: 1536 kb/s
  Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[zmq @ 0x5dc04e7a7580] URL tcp://127.0.0.1:5555 lacks prefix
[out#0/nut @ 0x5dc04e7a2f00] Error opening output zmq:tcp://127.0.0.1:5555: Invalid argument
Error opening output file zmq:tcp://127.0.0.1:5555.
Error opening output files: Invalid argument

$ ffmpeg -f s16le -ar 48000 -ac 2 -i /tmp/mpd.fifo -f mpegts -c:a libopus zmq:tcp://127.0.0.1:5555
ffmpeg version N-116515-gd527d23872 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 14 (Ubuntu 14.1.0-5ubuntu1)
  configuration: --bindir=/usr/local/bin --prefix=/cache/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/cache/ffmpeg_build/include --extra-ldflags=-L/cache/ffmpeg_build/lib --extra-libs='-lpthread -lm' --ld=g++ --enable-gpl --enable-gnutls --enable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-libpulse --enable-libzmq
  libavutil      59. 31.100 / 59. 31.100
  libavcodec     61. 11.100 / 61. 11.100
  libavformat    61.  5.101 / 61.  5.101
  libavdevice    61.  2.100 / 61.  2.100
  libavfilter    10.  2.102 / 10.  2.102
  libswscale      8.  2.100 /  8.  2.100
  libswresample   5.  2.100 /  5.  2.100
  libpostproc    58.  2.100 / 58.  2.100
[aist#0:0/pcm_s16le @ 0x58b7489edd80] Guessed Channel Layout: stereo
Input #0, s16le, from '/tmp/mpd.fifo':
  Duration: N/A, bitrate: 1536 kb/s
  Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[zmq @ 0x58b7489f1680] URL tcp://127.0.0.1:5555 lacks prefix
[out#0/mpegts @ 0x58b7489edf00] Error opening output zmq:tcp://127.0.0.1:5555: Invalid argument
Error opening output file zmq:tcp://127.0.0.1:5555.
Error opening output files: Invalid argument

$ ffmpeg -f s16le -ar 48000 -ac 2 -i /tmp/mpd.fifo -f mpegts -c:a libmp3lame zmq:tcp://127.0.0.1:5555
ffmpeg version N-116515-gd527d23872 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 14 (Ubuntu 14.1.0-5ubuntu1)
  configuration: --bindir=/usr/local/bin --prefix=/cache/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/cache/ffmpeg_build/include --extra-ldflags=-L/cache/ffmpeg_build/lib --extra-libs='-lpthread -lm' --ld=g++ --enable-gpl --enable-gnutls --enable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-libpulse --enable-libzmq
  libavutil      59. 31.100 / 59. 31.100
  libavcodec     61. 11.100 / 61. 11.100
  libavformat    61.  5.101 / 61.  5.101
  libavdevice    61.  2.100 / 61.  2.100
  libavfilter    10.  2.102 / 10.  2.102
  libswscale      8.  2.100 /  8.  2.100
  libswresample   5.  2.100 /  5.  2.100
  libpostproc    58.  2.100 / 58.  2.100
[aist#0:0/pcm_s16le @ 0x644f50028d80] Guessed Channel Layout: stereo
Input #0, s16le, from '/tmp/mpd.fifo':
  Duration: N/A, bitrate: 1536 kb/s
  Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[zmq @ 0x644f5002c680] URL tcp://127.0.0.1:5555 lacks prefix
[out#0/mpegts @ 0x644f50028f00] Error opening output zmq:tcp://127.0.0.1:5555: Invalid argument
Error opening output file zmq:tcp://127.0.0.1:5555.
Error opening output files: Invalid argument

mpd fifo output:

audio_output {
    type                    "fifo"
    name                    "mpd.fifo"
    path                    "/tmp/mpd.fifo"
    format                  "48000:16:2"
}

and if I'm not using the zmq streaming protocol:

$ ffmpeg -f s16le -ar 48000 -ac 2 -i /tmp/mpd.fifo -c:a libopus output.opus

produces output.opus which vlc can play.

https://www.ffmpeg.org/ffmpeg-protocols.html#zmq

3.45 zmq
ZeroMQ asynchronous messaging using the libzmq library.

This library supports unicast streaming to multiple clients without
relying on an external server.

The required syntax for streaming or connecting to a stream is:

zmq:tcp://ip-address:port
Example: Create a localhost stream on port 5555:

ffmpeg -re -i input -f mpegts zmq:tcp://127.0.0.1:5555
Multiple clients may connect to the stream using:

ffplay zmq:tcp://127.0.0.1:5555
Streaming to multiple clients is implemented using a ZeroMQ Pub-Sub
pattern. The server side binds to a port and publishes data. Clients
connect to the server (via IP address/port) and subscribe to the
stream. The order in which the server and client start generally does not matter.

ffmpeg must be compiled with the –enable-libzmq option to support this protocol.

Options can be set on the ffmpeg/ffplay command line. The following
options are supported:

pkt_size
Forces the maximum packet size for sending/receiving data. The default value is 131,072 bytes. On the server side, this sets the maximum size of sent packets via ZeroMQ. On the clients, it sets an internal buffer size for receiving packets. Note that pkt_size on the clients should be equal to or greater than pkt_size on the server. Otherwise the received message may be truncated causing decoding errors.

It doesn't seem to be specifically related to the fifo as the input:

$ ffmpeg -i /library/music/Grateful\ Dead/Grateful\ Dead\ --\ American\ Beauty\ \(1970\)/Grateful\ Dead\ --\ 01-01\ -\ Box\ of\ Rain.flac -f mpegts -c:a libmp3lame zmq:tcp://127.0.0.1:5555
ffmpeg version N-116515-gd527d23872 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 14 (Ubuntu 14.1.0-5ubuntu1)
  configuration: --bindir=/usr/local/bin --prefix=/cache/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/cache/ffmpeg_build/include --extra-ldflags=-L/cache/ffmpeg_build/lib --extra-libs='-lpthread -lm' --ld=g++ --enable-gpl --enable-gnutls --enable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-libpulse --enable-libzmq
  libavutil      59. 31.100 / 59. 31.100
  libavcodec     61. 11.100 / 61. 11.100
  libavformat    61.  5.101 / 61.  5.101
  libavdevice    61.  2.100 / 61.  2.100
  libavfilter    10.  2.102 / 10.  2.102
  libswscale      8.  2.100 /  8.  2.100
  libswresample   5.  2.100 /  5.  2.100
  libpostproc    58.  2.100 / 58.  2.100
Input #0, flac, from '/library/music/Grateful Dead/Grateful Dead -- American Beauty (1970)/Grateful Dead -- 01-01 - Box of Rain.flac':
  Metadata:

⋮

  Duration: 00:05:18.92, start: 0.000000, bitrate: 5972 kb/s
  Stream #0:0: Audio: flac, 192000 Hz, stereo, s32 (24 bit)
      Side data:
        replaygain: track gain - -4.760000, track peak - 0.000023, album gain - -4.180000, album peak - 0.000023, 
  Stream #0:1: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 500x500 [SAR 1:1 DAR 1:1], 90k tbr, 90k tbn (attached pic)
      Metadata:
        comment         : Cover (front)
[zmq @ 0x5927538f5040] URL tcp://127.0.0.1:5555 lacks prefix
[out#0/mpegts @ 0x59275388eac0] Error opening output zmq:tcp://127.0.0.1:5555: Invalid argument
Error opening output file zmq:tcp://127.0.0.1:5555.
Error opening output files: Invalid argument

Change History (10)

comment:1 by iconoclasthero, 3 months ago

Description: modified (diff)

comment:2 by iconoclasthero, 3 months ago

Description: modified (diff)

comment:3 by iconoclasthero, 3 months ago

Summary: [out#0/* @ 0x*] Error opening output zmq:tcp://127.0.0.1:5555: Invalid argumentzmq url lacks prefix: [out#0/* @ 0x*] Error opening output zmq:tcp://127.0.0.1:5555: Invalid argument

comment:4 by nanake, 3 months ago

Cc: nanake added

I'm not sure if this is a bug or feature. that example command https://www.ffmpeg.org/ffmpeg-protocols.html#zmq works again if i reverted 0263b6a48caaff839e4c28df15b299b89c7da92d.

comment:5 by wout, 3 months ago

It appears the check in 0263b6a48caaff839e4c28df15b299b89c7da92d is wrong.
Unfortunately, this commit was cherry-picked in all latest releases.

I think it should be:

if (!av_strstart(uri, "zmq:", &uri)) {
    av_log(h, AV_LOG_ERROR, "URL %s lacks prefix\n", uri);
    return AVERROR(EINVAL);
}

comment:6 by Marton Balint, 3 months ago

Blocking: 7.1
Component: undeterminedavformat
Keywords: regression added
Priority: normalimportant
Status: newopen

in reply to:  6 ; comment:7 by MasterQuestionable, 2 months ago

͏    Sorry for the Off-Topic.
͏    But is posting to the mail list really the proper way to make commits in FFmpeg..?

͏    I'm unfamiliar with the project's committing style.
͏    And haven't yet learned.

͏    Preferably continued on:
͏    https://github.com/MasterInQuestion/talk/discussions/categories/FFmpeg

comment:8 by Marton Balint, 2 months ago

Resolution: fixed
Status: openclosed

in reply to:  7 comment:9 by iconoclasthero, 2 months ago

Replying to MasterQuestionable:

͏    Sorry for the Off-Topic.
͏    But is posting to the mail list really the proper way to make commits in FFmpeg..?

͏    I'm unfamiliar with the project's committing style.
͏    And haven't yet learned.

͏    Preferably continued on:
͏    https://github.com/MasterInQuestion/talk/discussions/categories/FFmpeg

Log into https://trac.ffmpeg.org/ticket/11134 and you'll see that they've been entered on the ticket. If you don't want the emails, don't sign up for them?

comment:10 by iconoclasthero, 2 months ago

Working, thanks.

Note: See TracTickets for help on using tickets.