ffmpeg streaming of a file to Wowza

Hello,

I am trying to stream pre-recorded video (MP4, x264) to Wowza, but it behaves strangely.

If I try RTSP method:

ffmpeg -re -i sample.mp4  -vcodec libx264  -vb 500000 -g 60 -vprofile main -acodec aac -ab 128000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f mpegts udp://127.0.0.1:10000?pkt_size=1316

It seems working because it shows bitrate, and so on. But if I try FLV:

# ffmpeg -re -i sample.mp4  -vcodec libx264  -vb 500000 -g 60 -vprofile main -acodec aac -ab 128000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -strict experimental -f flv rtmp://127.0.0.1/live/myStream        
ffmpeg version 0.8.9-6:0.8.9-1, Copyright (c) 2000-2013 the Libav developers
  built on Nov  3 2013 00:54:50 with gcc 4.7.2
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'sample.mp4':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf52.73.0
  Duration: 00:09:56.45, start: 0.000000, bitrate: 524 kb/s
    Stream #0.0(eng): Video: h264 (Constrained Baseline), yuv420p, 424x240, 420 kb/s, 24 fps, 24 tbr, 24 tbn, 48 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
    Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16, 99 kb/s
    Metadata:
      creation_time   : 1970-01-01 00:00:00

It hangs. I can see packets flowing but players don’t find myStream. Log on stream creation shows:

2014-01-04	13:21:58	CET	connect-pending	session	INFO	100	127.0.0.1	-	_defaultVHost_	live	_definst_	0.001	[any]1935	rtmp://127.0.0.1/live	127.0.0.1	rtmp	-	unknown	1819880169	3170	3073	-	-	-	-	-	-	-	--	-	-	-	-	rtmp://127.0.0.1/live	-
2014-01-04	13:21:58	CET	connect	session	INFO	200	127.0.0.1	-	_defaultVHost_	live	_definst_	0.002	[any]	1935rtmp://127.0.0.1/live	127.0.0.1	rtmp	-	unknown	1819880169	3170	3073	-	-	-	-	-	-	-	-	--	-	-	-	rtmp://127.0.0.1/live	-
2014-01-04	13:21:58	CET	create	stream	INFO	200	-	-	_defaultVHost_	live	_definst_	0.001	[any]	1935	rtmp://127.0.0.1/live	127.0.0.1	rtmp	-	unknown	1819880169	3289	3413	1	0	0	0	-	-	-	-	--	rtmp://127.0.0.1/live	rtmp://127.0.0.1/live	-	rtmp://127.0.0.1/live	-

To be honest I don’t care about method of streaming, altough I thought FLV would be best because we are

using flowplayer to watch it via RTMP. Am I right?\

Maybe I should click “receive stream” in Stream Manager and then stream? To be honest my only experience with

streaming is Adobe Media Encoder.

Thanks!

For the former ffmpeg command, you’ll need to start the stream in stream manager to ingest it. For the latter (flv/rtmp attempt), you should just be able to play it back. I don’t see the publish event in your logs

INFO stream publish myStream

Try the following command and see if it makes a difference:

ffmpeg -i sample.mp4 -vcodec libx264 -acodec aac -ar 48000 -strict experimental -f flv "rtmp://127.0.0.1:1935/live/myStream"

That is the recommended way to use FFmpeg, as an mpeg-ts encoder, then using .stream files and the StreamManager or /conf/StartUpStreams.xml to start pulling the stream.

Matt’s example works as well, and is using FFmpeg as an RTMP live encoder, so you don’t have to use StreamManager or .stream files to start the stream. It should be available for playback as soon as published. Make sure FFmpeg can reach Wowza. You should see a publish event in Wowza as soon as you start the stream with the RTMP publishing method.

Richard

Also, there is a server-side way to stream a file as a live stream. You don’t need FFmpeg or external encoder to do that. Take a look at this scheduler which makes that easy.

Richard

Hello,

First of all thank you for your reply and time. Unfortunately your command also does not work. But I can use following command with success:

ffmpeg -re -i /usr/local/WowzaMediaServer/content/sample.mp4  -vcodec copy -acodec copy -vbsf h264_mp4toannexb -strict experimental -f mpegts udp://1
27.0.0.1:10000?pkt_size=1316

But I had to create file .stream with udp://0.0.0.0:10000/ and start it. Maybe I have create such file for a RTMP stream also? If I look at tcpdump I can see some traffic:

# tcpdump -i lo host 127.0.0.1 and port 1935 -n -c 30 -vvv
tcpdump: listening on lo, link-type EN10MB (Ethernet), capture size 65535 bytes
17:30:00.647021 IP (tos 0x0, ttl 64, id 681, offset 0, flags [DF], proto TCP (6), length 60)
    127.0.0.1.46602 > 127.0.0.1.1935: Flags [S], cksum 0xfe30 (incorrect -> 0xeff3), seq 1907406206, win 32792, options [mss 16396,sackOK,TS val 49919959 ecr 0,nop,wscale 7], length 0
17:30:00.647039 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 60)
    127.0.0.1.1935 > 127.0.0.1.46602: Flags [S.], cksum 0xfe30 (incorrect -> 0xad30), seq 4236610426, ack 1907406207, win 32768, options [mss 16396,sackOK,TS val 49919959 ecr 49919959,nop,wscale 0], length 0
17:30:00.647050 IP (tos 0x0, ttl 64, id 682, offset 0, flags [DF], proto TCP (6), length 52)
    127.0.0.1.46602 > 127.0.0.1.1935: Flags [.], cksum 0xfe28 (incorrect -> 0x954d), seq 1, ack 1, win 257, options [nop,nop,TS val 49919959 ecr 49919959], length 0
17:30:00.647188 IP (tos 0x0, ttl 64, id 683, offset 0, flags [DF], proto TCP (6), length 1589)
    127.0.0.1.46602 > 127.0.0.1.1935: Flags [P.], cksum 0x042a (incorrect -> 0x4cea), seq 1:1538, ack 1, win 257, options [nop,nop,TS val 49919959 ecr 49919959], length 1537
17:30:00.647211 IP (tos 0x0, ttl 64, id 15532, offset 0, flags [DF], proto TCP (6), length 52)
    127.0.0.1.1935 > 127.0.0.1.46602: Flags [.], cksum 0xfe28 (incorrect -> 0xd62d), seq 1, ack 1538, win 47647, options [nop,nop,TS val 49919959 ecr 49919959], length 0
17:30:00.647898 IP (tos 0x0, ttl 64, id 15533, offset 0, flags [DF], proto TCP (6), length 3125)
    127.0.0.1.1935 > 127.0.0.1.46602: Flags [P.], cksum 0x0a2a (incorrect -> 0xae61), seq 1:3074, ack 1538, win 47647, options [nop,nop,TS val 49919960 ecr 49919959], length 3073

Thanks!

I know that solution with scheudler, but I was a little bit overwhelmed by it. I prefer ffmpeg and at :).

Thank you!