When working with CDN configurations for video streaming, verifying RTMP URLs before deployment is crucial. The standard format rtmp://domain/path/streamname
requires specific tools for validation since browsers no longer support RTMP natively after Flash's deprecation.
FFmpeg remains the most reliable tool for RTMP verification. Here's how to test a stream:
ffmpeg -i "rtmp://example.fcod.llnwd.net/a1111/e11/test/example/file.flv" -vcodec copy -acodec copy -f flv -y /dev/null
This command attempts to read the stream without saving it. A successful connection will show metadata and continuous timestamp updates.
RTMPDump (rtmpdump
) provides detailed diagnostics:
rtmpdump -v -r "rtmp://example.fcod.llnwd.net/a1111/e11/test/example/file.flv" -o test.flv
Key parameters:
- -v
enables verbose output
- -r
specifies the RTMP URL
- -o
writes output (can be discarded)
For quick verification without command line tools, consider these approaches:
// JavaScript solution using HLS.js as fallback
if (isRTMPSupported()) {
// Native RTMP player implementation
} else {
// Convert to HLS using cloud function
const hls = new Hls();
hls.loadSource(convertRTMPtoHLS(rtmpUrl));
}
Here's a Python script to programmatically verify RTMP streams:
import subprocess
def verify_rtmp(rtmp_url):
try:
cmd = ['ffprobe', '-v', 'error', '-show_entries',
'format=duration', '-of', 'default=noprint_wrappers=1:nokey=1',
rtmp_url]
output = subprocess.run(cmd, capture_output=True, text=True, timeout=10)
return float(output.stdout) > 0
except:
return False
Case 1: Authentication required streams
rtmp://server/app/stream?token=SECURE_KEY
Test with rtmpdump --jtoken SECURE_KEY
Case 2: Multi-bitrate streams
Verify each variant:
rtmp://server/app/stream_240p
rtmp://server/app/stream_480p
When working with CDN-based RTMP streams like rtmp://example.fcod.llnwd.net/a1111/e11/test/example/file.flv
, developers need reliable methods to verify stream availability without requiring full player implementation. Here are several technical approaches:
The simplest way is using rtmpdump
(now called flvstreamer
):
rtmpdump -r "rtmp://example.fcod.llnwd.net/a1111/e11/test/example/file.flv" -o test.flv -V
Key parameters:
-r
: RTMP URL
-o
: Output file
-V
: Verbose output for debugging
FFmpeg provides more comprehensive stream analysis:
ffmpeg -i "rtmp://example.fcod.llnwd.net/a1111/e11/test/example/file.flv" -c copy -f null -
This command attempts to read the stream without saving it, providing valuable connection and stream metadata information.
For automated testing in your CDN setup workflow:
const NodeMediaServer = require('node-media-server');
const config = {
rtmp: {
port: 1935,
chunk_size: 60000,
gop_cache: true,
ping: 30,
ping_timeout: 60
}
};
const nms = new NodeMediaServer(config);
nms.run();
nms.on('preConnect', (id, args) => {
console.log('Attempting RTMP connection:', args);
});
nms.on('postConnect', (id, args) => {
console.log('RTMP connection established:', args);
});
While modern browsers don't support RTMP directly, you can test the HTTP fallback:
<video width="640" height="360" controls>
<source src="http://example.fcod.llnwd.net/a1111/e11/test/example/file.m3u8" type="application/x-mpegURL">
</video>
Python script using PyAV for continuous monitoring:
import av
import time
def check_rtmp_stream(url):
try:
container = av.open(url)
print(f"Stream metadata: {container.metadata}")
for packet in container.demux():
if packet.stream is not None:
print(f"Received packet from stream {packet.stream.index}")
break
return True
except Exception as e:
print(f"Stream check failed: {str(e)}")
return False
while True:
status = check_rtmp_stream("rtmp://example.fcod.llnwd.net/a1111/e11/test/example/file.flv")
print(f"{time.ctime()} - Stream status: {'OK' if status else 'FAILED'}")
time.sleep(300)
- Check connection establishment time
- Verify stream metadata matches expectations
- Monitor first frame arrival time
- Validate consistent packet delivery
- Test under various network conditions