Opened 9 years ago

Last modified 9 years ago

#4117 new defect

ffmpeg hangs while converting usb camera input

Reported by: Kenneth Kron Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by Carl Eugen Hoyos)

Summary of the bug:
How to reproduce:

 ffmpeg -f lavfi -i aevalsrc=0 -f video4linux2 -s 640x480 -i /dev/video0  -strict -2 http://localhost:8090/feed1.ffm
ffmpeg version N-67694-gdcb10ef Copyright (c) 2000-2014 the FFmpeg developers
  built on Nov 15 2014 13:25:02 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: --enable-libvpx --enable-libvorbis\
ffserver.conf:
HTTPPort 8090                      # Port to bind the server to
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 10000             # Maximum bandwidth per client
                               # set this high enough to exceed stream bitrate
CustomLog -

<Feed feed1.ffm>               # This is the input feed where FFmpeg will send
   File ./feed1.ffm            # video stream.
   FileMaxSize 10G              # Maximum file size for buffering video
   ACL allow 127.0.0.1
</Feed>

<Stream test.webm>              # Output stream URL definition
   Feed feed1.ffm
#   Format ogg
   Format webm
 
#   # Audio settings
   AudioCodec vorbis
   AudioBitRate 64             # Audio bitrate

   # Video settings
   VideoCodec libvpx
#   VideoCodec  vp8
   VideoSize 800x448
   VideoFrameRate 30
   AVOptionVideo flags +global_header  # Parameters passed to encoder
#   AVOptionVideo quality rt

                                       # (same as ffmpeg command-line parameters)
#   AVOptionVideo cpu-used 0
   AVOptionVideo qmin 10
   AVOptionVideo qmax 42
   AVOptionAudio flags +global_header

   PreRoll 15
   StartSendOnKey
   VideoBitRate 400            # Video bitrate
</Stream>

<Stream status.html>            # Server status URL
   Format status
   # Only allow local people to get the status
   ACL allow localhost
   ACL allow 192.168.0.0 192.168.255.255
</Stream>

<Redirect index.html>    # Just an URL redirect for index
   # Redirect index.html to the appropriate site
   URL http://www.ffmpeg.org/
</Redirect>

Change History (5)

comment:1 by Carl Eugen Hoyos, 9 years ago

Component: ffmpegundetermined
Description: modified (diff)
Keywords: ffmpeg hang removed
Priority: importantnormal

Is the issue only reproducible if you use multiple inputs or also with one input?
Is the issue only reproducible with ffm output?

Please provide the failing command line (that hangs) together with the complete, uncut console output and a backtrace when hanging to make this a valid ticket.

comment:2 by Kenneth Kron, 9 years ago

fmpeg -f lavfi -i aevalsrc=0 -f video4linux2 -s 640x480 -i /dev/video0 -strict -2 http://localhost:8090/feed1.ffm
ffmpeg version N-67694-gdcb10ef Copyright (c) 2000-2014 the FFmpeg developers

built on Nov 15 2014 13:25:02 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --enable-libvpx --enable-libvorbis
libavutil 54. 11.100 / 54. 11.100
libavcodec 56. 12.101 / 56. 12.101
libavformat 56. 12.103 / 56. 12.103
libavdevice 56. 3.100 / 56. 3.100
libavfilter 5. 2.103 / 5. 2.103
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100

Input #0, lavfi, from 'aevalsrc=0':

Duration: N/A, start: 0.000000, bitrate: 2822 kb/s

Stream #0:0: Audio: pcm_f64le, 44100 Hz, mono, dbl, 2822 kb/s

Input #1, video4linux2,v4l2, from '/dev/video0':

Duration: N/A, start: 3225.154243, bitrate: 147456 kb/s

Stream #1:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 147456 kb/s, 30 fps, 30 tbr, 1000k tbn, 1000k tbc

[libvpx @ 0x29758a0] v1.3.0-4832-gc3a9056
Output #0, ffm, to 'http://localhost:8090/feed1.ffm':

Metadata:

creation_time : now
encoder : Lavf56.12.103
Stream #0:0: Audio: vorbis (libvorbis), 22050 Hz, mono, fltp, 64 kb/s
Metadata:

encoder : Lavc56.12.101 libvorbis

Stream #0:1: Video: vp8 (libvpx), yuv420p, 800x448, q=10-42, 400 kb/s, 30 fps, 1000k tbn, 30 tbc
Metadata:

encoder : Lavc56.12.101 libvpx

Stream mapping:

Stream #0:0 -> #0:0 (pcm_f64le (native) -> vorbis (libvorbis))
Stream #1:0 -> #0:1 (rawvideo (native) -> vp8 (libvpx))

Press [q] to stop, ? for help
frame= 99 fps=3.6 q=0.0 Lsize= 104kB time=00:00:03.34 bitrate= 255.0kbits/s dup=73 drop=0
video:94kB audio:0kB subtitle:0kB other streams:0kB global headers:4kB muxing overhead: 10.710758%

Not sure if this depends on multiple inputs or not. I'll try to test.

comment:3 by Kenneth Kron, 9 years ago

This works fine
ffmpeg -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 output.mkv
as does
fmpeg -f lavfi -i aevalsrc=0 -f video4linux2 -s 640x480 -i /dev/video0 -strict -2 output.mkv

comment:4 by Kenneth Kron, 9 years ago

original commnand with -v 9 -loglevel 99

kkron@kkron-T430:~/Clients/AAS/VideoLogs/ivu$ ffmpeg -v 9 -loglevel 99 -f lavfi -i aevalsrc=0 -f video4linux2 -s 640x480 -i /dev/video0 -crf 12 -strict -2 http://localhost:8090/feed1.ffm
ffmpeg version N-67694-gdcb10ef Copyright (c) 2000-2014 the FFmpeg developers

built on Nov 15 2014 13:25:02 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --enable-libvpx --enable-libvorbis
libavutil 54. 11.100 / 54. 11.100
libavcodec 56. 12.101 / 56. 12.101
libavformat 56. 12.103 / 56. 12.103
libavdevice 56. 3.100 / 56. 3.100
libavfilter 5. 2.103 / 5. 2.103
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100

Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument '9'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument '99'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'lavfi'.
Reading option '-i' ... matched as input file with argument 'aevalsrc=0'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'video4linux2'.
Reading option '-s' ... matched as option 's' (set frame size (WxH or abbreviation)) with argument '640x480'.
Reading option '-i' ... matched as input file with argument '/dev/video0'.
Reading option '-crf' ... matched as AVOption 'crf' with argument '12'.
Reading option '-strict' ...Routing option strict to both codec and muxer layer

matched as AVOption 'strict' with argument '-2'.

Reading option 'http://localhost:8090/feed1.ffm' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument 9.
Successfully parsed a group of options.
Parsing a group of options: input file aevalsrc=0.
Applying option f (force format) with argument lavfi.
Successfully parsed a group of options.
Opening an input file: aevalsrc=0.
detected 4 logical cores
[Parsed_aevalsrc_0 @ 0x30d40c0] compat: called with args=[0]
[Parsed_aevalsrc_0 @ 0x30d40c0] Setting 'exprs' to value '0'
[out @ 0x30d4400] auto-inserting filter 'auto-inserted resampler 0' between the filter 'Parsed_aevalsrc_0' and the filter 'out'
[AVFilterGraph @ 0x30ca660] query_formats: 2 queried, 0 merged, 3 already done, 0 delayed
[Parsed_aevalsrc_0 @ 0x30d40c0] sample_rate:44100 chlayout:mono duration:-1
[auto-inserted resampler 0 @ 0x30d5f20] [SWR @ 0x30d6340] Using double precision mode
[auto-inserted resampler 0 @ 0x30d5f20] ch:1 chl:mono fmt:dblp r:44100Hz -> ch:1 chl:mono fmt:dbl r:44100Hz
[lavfi @ 0x30d2f60] All info found
Input #0, lavfi, from 'aevalsrc=0':

Duration: N/A, start: 0.000000, bitrate: 2822 kb/s

Stream #0:0, 1, 1/44100: Audio: pcm_f64le, 44100 Hz, mono, dbl, 2822 kb/s

Successfully opened the file.
Parsing a group of options: input file /dev/video0.
Applying option f (force format) with argument video4linux2.
Applying option s (set frame size (WxH or abbreviation)) with argument 640x480.
Successfully parsed a group of options.
Opening an input file: /dev/video0.
[video4linux2,v4l2 @ 0x30dcce0] fd:3 capabilities:84000001
[video4linux2,v4l2 @ 0x30dcce0] Current input_channel: 0, input_name: Camera 1, input_std: 0
[video4linux2,v4l2 @ 0x30dcce0] The V4L2 driver changed the pixel format from 0x32315559 to 0x56595559
[video4linux2,v4l2 @ 0x30dcce0] Trying to set codec:rawvideo pix_fmt:yuv420p
[video4linux2,v4l2 @ 0x30dcce0] The V4L2 driver changed the pixel format from 0x32315559 to 0x56595559
[video4linux2,v4l2 @ 0x30dcce0] Trying to set codec:rawvideo pix_fmt:yuv420p
[video4linux2,v4l2 @ 0x30dcce0] The V4L2 driver changed the pixel format from 0x32315659 to 0x56595559
[video4linux2,v4l2 @ 0x30dcce0] Trying to set codec:rawvideo pix_fmt:yuv422p
[video4linux2,v4l2 @ 0x30dcce0] The V4L2 driver changed the pixel format from 0x50323234 to 0x56595559
[video4linux2,v4l2 @ 0x30dcce0] Trying to set codec:rawvideo pix_fmt:yuyv422
[video4linux2,v4l2 @ 0x30dcce0] All info found
Input #1, video4linux2,v4l2, from '/dev/video0':

Duration: N/A, start: 11738.066916, bitrate: 147456 kb/s

Stream #1:0, 1, 1/1000000: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 1/1000000, 147456 kb/s, 30 fps, 30 tbr, 1000k tbn, 1000k tbc

Successfully opened the file.
Parsing a group of options: output file http://localhost:8090/feed1.ffm.
Successfully parsed a group of options.
Opening an output file: http://localhost:8090/feed1.ffm.
[http @ 0x30d5c40] request: GET /feed1.ffm HTTP/1.1
User-Agent: Lavf/56.12.103
Accept: */*
Range: bytes=0-
Connection: close
Host: localhost:8090
Icy-MetaData: 1

[http @ 0x30d5c40] header='HTTP/1.0 200 OK'
[http @ 0x30d5c40] http_code=200
[http @ 0x30d5c40] header='Pragma: no-cache'
[http @ 0x30d5c40] header='Content-Type: application/x-octet-stream'
[http @ 0x30d5c40] header=
[ffm @ 0x30df9c0] Format ffm probed with size=2048 and score=101
[AVIOContext @ 0x30e9ee0] Statistics: 4096 bytes read, 0 seeks
Codec AVOption crf (Select the quality for constant quality mode) specified for output file #0 (http://localhost:8090/feed1.ffm) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
[http @ 0x30d5c40] request: POST /feed1.ffm HTTP/1.1
Transfer-Encoding: chunked
User-Agent: Lavf/56.12.103
Accept: */*
Connection: close
Host: localhost:8090
Icy-MetaData: 1

Successfully opened the file.
[graph 0 input from stream 0:0 @ 0x30d26c0] Setting 'time_base' to value '1/44100'
[graph 0 input from stream 0:0 @ 0x30d26c0] Setting 'sample_rate' to value '44100'
[graph 0 input from stream 0:0 @ 0x30d26c0] Setting 'sample_fmt' to value 'dbl'
[graph 0 input from stream 0:0 @ 0x30d26c0] Setting 'channel_layout' to value '0x4'
[graph 0 input from stream 0:0 @ 0x30d26c0] tb:1/44100 samplefmt:dbl samplerate:44100 chlayout:0x4
[audio format for output stream 0:0 @ 0x30cab80] Setting 'sample_fmts' to value 'fltp'
[audio format for output stream 0:0 @ 0x30cab80] Setting 'sample_rates' to value '22050'
[audio format for output stream 0:0 @ 0x30cab80] Setting 'channel_layouts' to value '0x4'
[audio format for output stream 0:0 @ 0x30cab80] auto-inserting filter 'auto-inserted resampler 0' between the filter 'Parsed_anull_0' and the filter 'audio format for output stream 0:0'
[AVFilterGraph @ 0x30ca2c0] query_formats: 4 queried, 6 merged, 3 already done, 0 delayed
[auto-inserted resampler 0 @ 0x30e3180] [SWR @ 0x30ba4c0] Using double precision mode
[auto-inserted resampler 0 @ 0x30e3180] ch:1 chl:mono fmt:dbl r:44100Hz -> ch:1 chl:mono fmt:fltp r:22050Hz
[graph 1 input from stream 1:0 @ 0x30c9fe0] Setting 'video_size' to value '640x480'
[graph 1 input from stream 1:0 @ 0x30c9fe0] Setting 'pix_fmt' to value '1'
[graph 1 input from stream 1:0 @ 0x30c9fe0] Setting 'time_base' to value '1/1000000'
[graph 1 input from stream 1:0 @ 0x30c9fe0] Setting 'pixel_aspect' to value '0/1'
[graph 1 input from stream 1:0 @ 0x30c9fe0] Setting 'sws_param' to value 'flags=2'
[graph 1 input from stream 1:0 @ 0x30c9fe0] Setting 'frame_rate' to value '30/1'
[graph 1 input from stream 1:0 @ 0x30c9fe0] w:640 h:480 pixfmt:yuyv422 tb:1/1000000 fr:30/1 sar:0/1 sws_param:flags=2
[scaler for output stream 0:1 @ 0x30e2b60] Setting 'w' to value '800'
[scaler for output stream 0:1 @ 0x30e2b60] Setting 'h' to value '448'
[scaler for output stream 0:1 @ 0x30e2b60] Setting 'flags' to value '0x4'
[scaler for output stream 0:1 @ 0x30e2b60] w:800 h:448 flags:'0x4' interl:0
[format @ 0x30e2640] compat: called with args=[yuv420p|yuva420p]
[format @ 0x30e2640] Setting 'pix_fmts' to value 'yuv420p|yuva420p'
[AVFilterGraph @ 0x30c2140] query_formats: 5 queried, 4 merged, 0 already done, 0 delayed
[scaler for output stream 0:1 @ 0x30e2b60] picking yuv420p out of 2 ref:yuyv422 alpha:0
[scaler for output stream 0:1 @ 0x30e2b60] w:640 h:480 fmt:yuyv422 sar:0/1 -> w:800 h:448 fmt:yuv420p sar:0/1 flags:0x4
[libvpx @ 0x30e5c80] v1.3.0-4832-gc3a9056
[libvpx @ 0x30e5c80]
[libvpx @ 0x30e5c80] vpx_codec_enc_cfg
[libvpx @ 0x30e5c80] 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 @ 0x30e5c80] 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 @ 0x30e5c80] quantizer settings

rc_min_quantizer: 4
rc_max_quantizer: 63

[libvpx @ 0x30e5c80] bitrate tolerance

rc_undershoot_pct: 100
rc_overshoot_pct: 100

[libvpx @ 0x30e5c80] decoder buffer model

rc_buf_sz: 6000
rc_buf_initial_sz: 4000
rc_buf_optimal_sz: 5000

[libvpx @ 0x30e5c80] 2 pass rate control settings

rc_2pass_vbr_bias_pct: 50
rc_2pass_vbr_minsection_pct: 0
rc_2pass_vbr_maxsection_pct: 400

[libvpx @ 0x30e5c80] keyframing settings

kf_mode: 1
kf_min_dist: 0
kf_max_dist: 128

[libvpx @ 0x30e5c80]
[libvpx @ 0x30e5c80] vpx_codec_enc_cfg
[libvpx @ 0x30e5c80] generic settings

g_usage: 0
g_threads: 0
g_profile: 0
g_w: 800
g_h: 448
g_timebase: {1/30}
g_error_resilient: 0
g_pass: 0
g_lag_in_frames: 25

[libvpx @ 0x30e5c80] 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: 400

[libvpx @ 0x30e5c80] quantizer settings

rc_min_quantizer: 10
rc_max_quantizer: 42

[libvpx @ 0x30e5c80] bitrate tolerance

rc_undershoot_pct: 100
rc_overshoot_pct: 100

[libvpx @ 0x30e5c80] decoder buffer model

rc_buf_sz: 2000
rc_buf_initial_sz: 1500
rc_buf_optimal_sz: 1666

[libvpx @ 0x30e5c80] 2 pass rate control settings

rc_2pass_vbr_bias_pct: 50
rc_2pass_vbr_minsection_pct: 0
rc_2pass_vbr_maxsection_pct: 200

[libvpx @ 0x30e5c80] keyframing settings

kf_mode: 1
kf_min_dist: 0
kf_max_dist: 65535

[libvpx @ 0x30e5c80]
[libvpx @ 0x30e5c80] vpx_codec_control
[libvpx @ 0x30e5c80] VP8E_SET_CPUUSED: 1
[libvpx @ 0x30e5c80] VP8E_SET_ARNR_MAXFRAMES: 0
[libvpx @ 0x30e5c80] VP8E_SET_ARNR_STRENGTH: 3
[libvpx @ 0x30e5c80] VP8E_SET_ARNR_TYPE: 3
[libvpx @ 0x30e5c80] VP8E_SET_NOISE_SENSITIVITY: 0
[libvpx @ 0x30e5c80] VP8E_SET_TOKEN_PARTITIONS: 0
[libvpx @ 0x30e5c80] VP8E_SET_STATIC_THRESHOLD: 0
[libvpx @ 0x30e5c80] Using deadline: 1000000
Output #0, ffm, to 'http://localhost:8090/feed1.ffm':

Metadata:

creation_time : now
encoder : Lavf56.12.103
Stream #0:0, 0, 1/1000000: Audio: vorbis (libvorbis), 22050 Hz, mono, fltp, 64 kb/s
Metadata:

encoder : Lavc56.12.101 libvorbis

Stream #0:1, 0, 1/1000000: Video: vp8 (libvpx), yuv420p, 800x448, 1/30, q=10-42, 400 kb/s, 30 fps, 1000k tbn, 30 tbc
Metadata:

encoder : Lavc56.12.101 libvpx

Stream mapping:

Stream #0:0 -> #0:0 (pcm_f64le (native) -> vorbis (libvorbis))
Stream #1:0 -> #0:1 (rawvideo (native) -> vp8 (libvpx))

Press [q] to stop, ? for help
* 1 dup!

Last message repeated 2 times

* 1 dup!8 fps=0.0 q=0.0 size= 36kB time=00:00:00.26 bitrate=1105.9kbits/s dup=3 drop=0

Last message repeated 2 times

* 1 dup!4 fps= 11 q=0.0 size= 40kB time=00:00:00.46 bitrate= 702.2kbits/s dup=6 drop=0
* 1 dup!7 fps=7.7 q=0.0 size= 48kB time=00:00:00.56 bitrate= 693.9kbits/s dup=7 drop=0

Last message repeated 1 times

* 1 dup!3 fps=8.4 q=0.0 size= 56kB time=00:00:00.76 bitrate= 598.4kbits/s dup=9 drop=0
* 1 dup!6 fps=8.0 q=0.0 size= 56kB time=00:00:00.86 bitrate= 529.3kbits/s dup=10 drop=0

Last message repeated 1 times

* 62 dup!

Then the dup's climb sort of exponentially

comment:5 by Kenneth Kron, 9 years ago

Not caused by dual inputs
ffmpeg -f x11grab -r 25 -s 1280x800 -i :0.0 -c:v libvpx -f alsa -i pulse http://127.0.0.1:8090/feed1.ffm

does not hang

Note: See TracTickets for help on using tickets.