[FFmpeg-user] webm video encoded with ffmpeg and streamed with ffserver doesn't play correctly in Firefox
jbennett at incomsystems.biz
jbennett at incomsystems.biz
Tue Aug 27 20:23:31 CEST 2013
Hello all, I'm attempting to use ffmpeg to transcode live video to
webm and stream it to ffserver, and then embed the stream as html5 video
on a web site. I'm using ffmpeg 1.2.2 on my local desktop to encode, and
ffserver 1.2.1 on the server machine to stream to clients.
I'm 99% of
the way there. Audio and video encode properly, and the video plays
correctly in Chrome and Konqueror. The strange bit is that Firefox
refuses to play my stream. It displays a single frame, but when the play
button is pressed, it seems to buffer forever, and never start playing.
There is a known firefox problem with ffmpeg encoded webm that I am
probably hitting. A negative timestamp at the beginning of a file will
cause firefox to download the entire file before playing
(https://bugzilla.mozilla.org/show_bug.cgi?id=873775 [1]). As this is a
live stream, there is no end of file to find.
I have tried
-avoid_negative_ts 1 in the ffmpeg command, but it doesn't seem to make
a difference.
When I use wget on the raw live stream, then use mkvinfo
-s on the captured file, I get this output:
Track 1: audio, codec ID:
A_VORBIS, mkvmerge/mkvextract track ID: 0, language: und, channels: 1,
sampling freq: 22050
Track 2: video, codec ID: V_VP8,
mkvmerge/mkvextract track ID: 1, language: und, default duration:
33.367ms (29.970 frames/fields per second for a video track), pixel
width: 720, pixel height: 480
I frame, track 2, timecode 1377625424004
(382673:43:44.004), size 625, adler 0x92f0bc34
I frame, track 1,
timecode 1377625424011 (382673:43:44.011), size 83, adler 0xc43223a0
I
frame, track 1, timecode 1377625424034 (382673:43:44.034), size 89,
adler 0xf79f2981
P frame, track 2, timecode 1377625424038
(382673:43:44.038), size 51, adler 0x69cd1076
I frame, track 1, timecode
1377625424057 (382673:43:44.057), size 83, adler 0xb4742955
P frame,
track 2, timecode 1377625424071 (382673:43:44.071), size 51, adler
0x69cd1076
I frame, track 1, timecode 1377625424080 (382673:43:44.080),
size 85, adler 0xfda824be
I frame, track 1, timecode 1377625424103
(382673:43:44.103), size 78, adler 0xaaa52481
P frame, track 2, timecode
1377625424104 (382673:43:44.104), size 56, adler 0x8bd710d7
I frame,
track 1, timecode 1377625424127 (382673:43:44.127), size 97, adler
0x70f92be1
P frame, track 2, timecode 1377625424138 (382673:43:44.138),
size 54, adler 0x6a881093
I frame, track 1, timecode 1377625424150
(382673:43:44.150), size 88, adler 0x79042ccc
P frame, track 2, timecode
1377625424171 (382673:43:44.171), size 54, adler 0x6b84106d
I frame,
track 1, timecode 1377625424173 (382673:43:44.173), size 85, adler
0x3a4a26e7
I frame, track 1, timecode 1377625424196 (382673:43:44.196),
size 93, adler 0x4be32b07
P frame, track 2, timecode 1377625424204
(382673:43:44.204), size 55, adler 0x7c11102b
I frame, track 1, timecode
1377625424220 (382673:43:44.220), size 80, adler 0xc9b6224a
P frame,
track 2, timecode 1377625424238 (382673:43:44.238), size 51, adler
0x97d71273
I frame, track 1, timecode 1377625424243 (382673:43:44.243),
size 94, adler 0x34a22ce5
I frame, track 1, timecode 1377625424266
(382673:43:44.266), size 53, adler 0xf4dd1d7c
P frame, track 2, timecode
1377625424271 (382673:43:44.271), size 55, adler 0x7d9d10c8
I frame,
track 1, timecode 1377625424283 (382673:43:44.283), size 71, adler
0x4ec422d1
I frame, track 1, timecode 1377625424295 (382673:43:44.295),
size 79, adler 0xa6dc243f
P frame, track 2, timecode 1377625424305
(382673:43:44.305), size 51, adler 0x6ccd1086
I frame, track 1, timecode
1377625424307 (382673:43:44.307), size 80, adler 0x4d6426d8
I frame,
track 1, timecode 1377625424318 (382673:43:44.318), size 96, adler
0xaa062ec6
I frame, track 1, timecode 1377625424336 (382673:43:44.336),
size 92, adler 0xfc632ecc
P frame, track 2, timecode 1377625424338
(382673:43:44.338), size 56, adler 0x90b51136
I frame, track 1, timecode
1377625424359 (382673:43:44.359), size 90, adler 0xd1d52a36
P frame,
track 2, timecode 1377625424371 (382673:43:44.371), size 51, adler
0x6dbd108b
I frame, track 1, timecode 1377625424382 (382673:43:44.382),
size 89, adler 0xf4362e1a
I frame, track 2, timecode 1377625424405
(382673:43:44.405), size 624, adler 0xddb4e297
I frame, track 1,
timecode 1377625424405 (382673:43:44.405), size 85, adler 0x20681d9a
I
frame, track 1, timecode 1377625424428 (382673:43:44.428), size 78,
adler 0xcae9267c
P frame, track 2, timecode 1377625424438
(382673:43:44.438), size 51, adler 0x69cd1076
I frame, track 1, timecode
1377625424452 (382673:43:44.452), size 93, adler 0xc6362f19
P frame,
track 2, timecode 1377625424471 (382673:43:44.471), size 51, adler
0x69cd1076
I frame, track 1, timecode 1377625424475 (382673:43:44.475),
size 83, adler 0xd80025d4
Obviously not ideal. Main question is what
needs to change so that Firefox will play the live stream? I'll include
my conf files and outputs.
My html code is simply:
<video
src="http://myServerIp:8090/test.webm" type="video/webm" controls>
Your
browser does not support the <code>video</code> element.
</video>
Port
8090
BindAddress 0.0.0.0
MaxHTTPConnections 30
MaxClients
20
#MaxBandwidth 2000
#CustomLog -
<Feed feed1.ffm>
File
/tmp/feed1.ffm
FileMaxSize 1000K
ACL allow myDesktopIp
</Feed>
<Stream
test.webm> # Output stream URL definition
Feed feed1.ffm # Feed from
which to receive video
Format webm
# Audio settings
AudioCodec
vorbis
AudioBitRate 32 # Audio bitrate#
# Video settings
VideoCodec
libvpx
VideoSize 720x480 # Video resolution
AVOptionVideo flags
+global_header # Parameters passed to encoder
# (same as ffmpeg
command-line parameters)
AVOptionVideo cpu-used 0
AVOptionVideo qmin
10
AVOptionVideo qmax 42
AVOptionVideo quality good
AVOptionAudio
flags +global_header
PreRoll 15
StartSendOnKey
VideoBitRate 250 #
Video bitrate
</Stream>
ffmpeg -v debug -f v4l2 -tvstd ntsc -i
/dev/video0 -vsync 2 -f pulse -i default -avoid_negative_ts 1
http://serverip:8090/feed1.ffm
ffmpeg version 1.2.2 Copyright (c)
2000-2013 the FFmpeg developers
built on Aug 4 2013 08:24:19 with gcc
4.8.1 (GCC) 20130603 (Red Hat 4.8.1-1)
configuration: --prefix=/usr
--bindir=/usr/bin --datadir=/usr/share/ffmpeg
--incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man
--arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2
-fexceptions -fstack-protector --param=ssp-buffer-size=4
-grecord-gcc-switches -m64 -mtune=generic' --enable-bzlib
--disable-crystalhd --enable-frei0r --enable-gnutls --enable-libass
--enable-libcelt --enable-libdc1394 --disable-indev=jack
--enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal
--enable-libopencv --enable-libopenjpeg --enable-libopus
--enable-libpulse --enable-libschroedinger --enable-libspeex
--enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx
--enable-libx264 --enable-libxvid --enable-x11grab --enable-avfilter
--enable-postproc --enable-pthreads --disable-static --enable-shared
--enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64
--enable-runtime-cpudetect
libavutil 52. 18.100 / 52. 18.100
libavcodec 54. 92.100 / 54. 92.100
libavformat 54. 63.104 / 54. 63.104
libavdevice 54. 3.103 / 54. 3.103
libavfilter 3. 42.103 / 3. 42.103
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
Splitting the commandline.
Reading
option '-v' ... matched as option 'v' (set libav* logging level) with
argument 'debug'.
Reading option '-f' ... matched as option 'f' (force
format) with argument 'v4l2'.
Reading option '-tvstd' ... matched as
option 'tvstd' (deprecated, use -standard) with argument 'ntsc'.
Reading option '-i' ... matched as input file with argument
'/dev/video0'.
Reading option '-vsync' ... matched as option 'vsync'
(video sync method) with argument '2'.
Reading option '-f' ... matched
as option 'f' (force format) with argument 'pulse'.
Reading option '-i'
... matched as input file with argument 'default'.
Reading option
'-avoid_negative_ts' ... matched as AVOption 'avoid_negative_ts' with
argument '1'.
Reading option 'http://serverip:8090/feed1.ffm' ...
matched as output file.
Finished splitting the commandline.
Parsing a
group of options: global .
Applying option v (set libav* logging level)
with argument debug.
Applying option tvstd (deprecated, use -standard)
with argument ntsc.
This option is deprecated, use -standard.
Applying
option vsync (video sync method) with argument 2.
Successfully parsed a
group of options.
Parsing a group of options: input file /dev/video0.
Applying option f (force format) with argument v4l2.
Successfully
parsed a group of options.
Opening an input file: /dev/video0.
[video4linux2,v4l2 @ 0x25abba0] fd:3 capabilities:85020011
[video4linux2,v4l2 @ 0x25abba0] Selecting input_channel: 0
[video4linux2,v4l2 @ 0x25abba0] input_channel: 0, input_name: S-Video
[video4linux2,v4l2 @ 0x25abba0] Querying the device for the current
frame size
[video4linux2,v4l2 @ 0x25abba0] Setting frame size to
720x480
[video4linux2,v4l2 @ 0x25abba0] The V4L2 driver is using the
interlaced mode
[video4linux2,v4l2 @ 0x25abba0] Current standard: NTSC,
id: 45056, frameperiod: 1001/30000
[video4linux2,v4l2 @ 0x25abba0] All
info found
[video4linux2,v4l2 @ 0x25abba0] Estimating duration from
bitrate, this may be inaccurate
Input #0, video4linux2,v4l2, from
'/dev/video0':
Duration: N/A, start: 54423.623015, bitrate: 124291
kb/s
Stream #0:0, 1, 1/1000000: Video: rawvideo (I420 / 0x30323449),
yuv420p, 720x480, 1/1000000, 124291 kb/s, 29.97 fps, 29.97 tbr, 1000k
tbn, 1000k tbc
Successfully opened the file.
Parsing a group of options:
input file default.
Applying option f (force format) with argument
pulse.
Successfully parsed a group of options.
Opening an input file:
default.
[pulse @ 0x25ad560] All info found
[pulse @ 0x25ad560]
Estimating duration from bitrate, this may be inaccurate
Guessed Channel
Layout for Input Stream #1.0 : stereo
Input #1, pulse, from 'default':
Duration: N/A, start: 0.633504, bitrate: 1536 kb/s
Stream #1:0, 1,
1/1000000: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536
kb/s
Successfully opened the file.
Parsing a group of options: output
file http:/serverip:8090/feed1.ffm.
Successfully parsed a group of
options.
Opening an output file: http://serverip:8090/feed1.ffm.
[ffm
@ 0x25c1ea0] Format ffm probed with size=2048 and score=101
[AVIOContext @ 0x25c00a0] Statistics: 4096 bytes read, 0 seeks
Successfully opened the file.
[abuffer @ 0x25c75e0] Setting entry with
key 'time_base' to value '1/48000'
[abuffer @ 0x25c75e0] Setting entry
with key 'sample_rate' to value '48000'
[abuffer @ 0x25c75e0] Setting
entry with key 'sample_fmt' to value 's16'
[abuffer @ 0x25c75e0]
Setting entry with key 'channel_layout' to value '0x3'
[graph 0 input
from stream 1:0 @ 0x25ab740] tb:1/48000 samplefmt:s16 samplerate:48000
chlayout:0x3
[aformat @ 0x25c6020] Setting entry with key 'sample_fmts'
to value 'fltp'
[aformat @ 0x25c6020] Setting entry with key
'sample_rates' to value '22050'
[aformat @ 0x25c6020] Setting entry
with key 'channel_layouts' to value '0x4'
[audio format for output
stream 0:0 @ 0x25c5f20] auto-inserting filter 'auto-inserted resampler
0' between the filter 'Parsed_anull_0' and the filter 'audio format for
output stream 0:0'
0.500000 0.500000
[auto-inserted resampler 0 @
0x25c5560] ch:2 chl:stereo fmt:s16 r:48000Hz -> ch:1 chl:mono fmt:fltp
r:22050Hz
[buffer @ 0x25c5ae0] Setting entry with key 'video_size' to
value '720x480'
[buffer @ 0x25c5ae0] Setting entry with key 'pix_fmt'
to value '0'
[buffer @ 0x25c5ae0] Setting entry with key 'time_base' to
value '1/1000000'
[buffer @ 0x25c5ae0] Setting entry with key
'pixel_aspect' to value '0/1'
[buffer @ 0x25c5ae0] Setting entry with
key 'sws_param' to value 'flags=2'
[buffer @ 0x25c5ae0] Setting entry
with key 'frame_rate' to value '30000/1001'
[graph 1 input from stream
0:0 @ 0x25c51e0] w:720 h:480 pixfmt:yuv420p tb:1/1000000 fr:30000/1001
sar:0/1 sws_param:flags=2
[scale @ 0x25c5b80] Setting 'w' to value
'720'
[scale @ 0x25c5b80] Setting 'h' to value '480'
[scale @
0x25c5b80] Setting 'flags' to value '0x4'
[scaler for output stream 0:1
@ 0x25c6cc0] w:720 h:480 flags:'0x4' interl:0
[scaler for output stream
0:1 @ 0x25c6cc0] w:720 h:480 fmt:yuv420p sar:0/1 -> w:720 h:480
fmt:yuv420p sar:0/1 flags:0x4
[libvpx @ 0x25c93a0] v1.2.0
[libvpx @
0x25c93a0] --target=x86_64-linux-gcc --enable-pic --disable-install-srcs
--enable-shared --prefix=/usr --libdir=/usr/lib64
[libvpx @ 0x25c93a0]
vpx_codec_enc_cfg
[libvpx @ 0x25c93a0] generic settings
g_usage: 0
g_threads: 0
g_profile: 0
g_w: 320
g_h: 240
g_timebase: {1/30}
g_error_resilient: 0
g_pass: 0
g_lag_in_frames: 0
[libvpx @
0x25c93a0] rate control settings
rc_dropframe_thresh: 0
rc_resize_allowed: 0
rc_resize_up_thresh: 60
rc_resize_down_thresh:
30
rc_end_usage: 0
rc_twopass_stats_in: (nil)(0)
rc_target_bitrate: 256
[libvpx @ 0x25c93a0] quantizer settings
rc_min_quantizer: 4
rc_max_quantizer: 63
[libvpx @ 0x25c93a0] bitrate
tolerance
rc_undershoot_pct: 100
rc_overshoot_pct: 100
[libvpx @
0x25c93a0] decoder buffer model
rc_buf_sz: 6000
rc_buf_initial_sz:
4000
rc_buf_optimal_sz: 5000
[libvpx @ 0x25c93a0] 2 pass rate control
settings
rc_2pass_vbr_bias_pct: 50
rc_2pass_vbr_minsection_pct: 0
rc_2pass_vbr_maxsection_pct: 400
[libvpx @ 0x25c93a0] keyframing
settings
kf_mode: 1
kf_min_dist: 0
kf_max_dist: 128
[libvpx @
0x25c93a0]
[libvpx @ 0x25c93a0] vpx_codec_enc_cfg
[libvpx @ 0x25c93a0]
generic settings
g_usage: 0
g_threads: 0
g_profile: 0
g_w: 720
g_h: 480
g_timebase: {1001/30000}
g_error_resilient: 0
g_pass: 0
g_lag_in_frames: 25
[libvpx @ 0x25c93a0] rate control settings
rc_dropframe_thresh: 0
rc_resize_allowed: 0
rc_resize_up_thresh: 60
rc_resize_down_thresh: 30
rc_end_usage: 0
rc_twopass_stats_in:
(nil)(0)
rc_target_bitrate: 250
[libvpx @ 0x25c93a0] quantizer
settings
rc_min_quantizer: 10
rc_max_quantizer: 42
[libvpx @
0x25c93a0] bitrate tolerance
rc_undershoot_pct: 100
rc_overshoot_pct: 100
[libvpx @ 0x25c93a0] decoder buffer model
rc_buf_sz: 2000
rc_buf_initial_sz: 1500
rc_buf_optimal_sz: 1666
[libvpx @ 0x25c93a0] 2 pass rate control settings
rc_2pass_vbr_bias_pct: 50
rc_2pass_vbr_minsection_pct: 0
rc_2pass_vbr_maxsection_pct: 200
[libvpx @ 0x25c93a0] keyframing
settings
kf_mode: 1
kf_min_dist: 0
kf_max_dist: 12
[libvpx @
0x25c93a0]
[libvpx @ 0x25c93a0] vpx_codec_control
[libvpx @ 0x25c93a0]
VP8E_SET_CPUUSED: 3
[libvpx @ 0x25c93a0] VP8E_SET_ARNR_MAXFRAMES:
0
[libvpx @ 0x25c93a0] VP8E_SET_ARNR_STRENGTH: 3
[libvpx @ 0x25c93a0]
VP8E_SET_ARNR_TYPE: 3
[libvpx @ 0x25c93a0] VP8E_SET_NOISE_SENSITIVITY:
0
[libvpx @ 0x25c93a0] VP8E_SET_TOKEN_PARTITIONS: 0
[libvpx @ 0x25c93a0]
VP8E_SET_STATIC_THRESHOLD: 0
[libvpx @ 0x25c93a0] VP8E_SET_CQ_LEVEL:
0
[libvpx @ 0x25c93a0] Using deadline: 1000000
Output #0, ffm, to
'http://serverip:8090/feed1.ffm':
Metadata:
creation_time : now
encoder : Lavf54.63.104
Stream #0:0, 0, 1/1000000: Audio: vorbis, 22050
Hz, mono, fltp, 32 kb/s
Stream #0:1, 0, 1/1000000: Video: vp8, yuv420p,
720x480, 1001/30000, q=10-42, 250 kb/s, 1000k tbn, 29.97 tbc
Stream
mapping:
Stream #1:0 -> #0:0 (pcm_s16le -> libvorbis)
Stream #0:0 ->
#0:1 (rawvideo -> libvpx)
Press [q] to stop, [?] for help
Trying to
remove 320 more samples than there are in the queuetrate= 66.4kbits/s
frame= 82 fps= 36 q=0.0 Lsize= 24kB time=00:00:02.76 bitrate=
71.0kbits/s
video:8kB audio:9kB subtitle:0 global headers:3kB muxing
overhead 18.512803%
Received signal 2: terminating.
Links:
------
[1] https://bugzilla.mozilla.org/show_bug.cgi?id=873775
More information about the ffmpeg-user
mailing list