Opened 9 months ago

Last modified 6 months ago

#5921 open defect

Can not read mjpeg from IP camera

Reported by: qqqzhouhk Owned by:
Priority: important Component: avformat
Version: git-master Keywords: mpjpeg regression
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Summary of the bug: I downloaded a FFmpeg demo from the internet. Tried to change the video source to IP camera, but it shows bugs as follows. BTW I use OC in Xcode
How to reproduce:

self.video =[[XYQMovieObject alloc] initWithVideo:@"http://192.168.10.123:7060"];

The bug shows that

Input #0, mpjpeg, from 'http://192.168.10.123:7060':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj422p(pc, bt470bg/unknown/unknown), 640x480, 25 tbr, 25 tbn, 25 tbc
[mpjpeg @ 0x7feadc818000] Expected boundary '--' not found, instead found a line of 8 bytes
[mpjpeg @ 0x7feadc818000] Expected boundary '--' not found, instead found a line of 2 bytes

I don't know what to do to fix it. It works when I use other internet source of video like

self.video = [[XYQMovieObject alloc] initWithVideo:@"http://live.hkstv.hk.lxdns.com/live/hks/playlist.m3u8"]; 

Can any one tell me what to do to debug that? I would really appreciate that. Thanks guys.

Attachments (1)

stream (1.5 MB) - added by qqqzhouhk 9 months ago.
sample

Download all attachments as: .zip

Change History (14)

comment:1 follow-up: Changed 9 months ago by cehoyos

Does it work with the ffmpeg executable?

Please try to dump the stream into a file with something like wget http://192.168.10.123:7060 and upload the resulting file.

comment:2 in reply to: ↑ 1 ; follow-up: Changed 9 months ago by qqqzhouhk

Replying to cehoyos:
Really thank you that you are willing to help me.

Does it work with the ffmpeg executable?

Sorry, what do you mean by ffmpeg executable? The demo code is working when the video source is from internet live stream, but it does not when changes to my IP camera, which uses HTTP protocol.

Please try to dump the stream into a file with something like wget http://192.168.10.123:7060 and upload the resulting file.

How to dump the stream into a file? The demo code can be downloaded from below:https://github.com/xiayuanquan/FFmpegDemo
Can you please be more specific? Since I am new to program. Thank you very much!!

comment:3 in reply to: ↑ 2 Changed 9 months ago by cehoyos

Replying to qqqzhouhk:

Replying to cehoyos:
Really thank you that you are willing to help me.

Does it work with the ffmpeg executable?

Sorry, what do you mean by ffmpeg executable?

Does the following command line work?

$ ffmpeg -i http://192.168.10.123:7060 -qscale 2 -vcodec mpeg4 out.mov

Please try to dump the stream into a file with something like wget http://192.168.10.123:7060 and upload the resulting file.

How to dump the stream into a file?

Please try the following command line to dump the http stream into a file:

$ wget http://192.168.10.123:7060

comment:4 follow-up: Changed 9 months ago by cehoyos

An alternative is the following:

$ curl -o stream http://192.168.10.123:7060

comment:5 in reply to: ↑ 4 ; follow-up: Changed 9 months ago by qqqzhouhk

Replying to cehoyos:

An alternative is the following:

$ curl -o stream http://192.168.10.123:7060

I have tried what you told me to do, and here is the screenshoot of them:

$ ffmpeg -i http://192.168.10.123:7060 -qscale 2 -vcodec mpeg4 out.mov
-bash: ffmpeg: command not found
$ wget http://192.168.10.123:7060
-bash: wget: command not found
$ curl -o stream http://192.168.10.123:7060
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                  Dload  Upload   Total   Spent    Left   Speed
100 108M    0  108M    0   0        299k      0     --:--:--  0:06:11 --:--:--  338k

Received data seems to keep going up continuously. So what else should I do?

comment:6 in reply to: ↑ 5 ; follow-ups: Changed 9 months ago by llogan

Replying to qqqzhouhk:

$ ffmpeg -i http://192.168.10.123:7060 -qscale 2 -vcodec mpeg4 out.mov
-bash: ffmpeg: command not found

You need to have a ffmpeg binary to run ffmpeg. So far you haven't provided any method for us to duplicate the issue, and we have no idea how FFmpeg is involved here. Are you using the FFmpeg libraries, or are you somehow using the ffmpeg cli tool (although if you are it appears not to be in your PATH)?

I'm assuming you're using the libraries because you mentioned something called "FFmpegDemo", but we do not support third-party tools. Testing with a recent ffmpeg binary will more easily show if the issue is valid here.

$ curl -o stream http://192.168.10.123:7060
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                  Dload  Upload   Total   Spent    Left   Speed
100 108M    0  108M    0   0        299k      0     --:--:--  0:06:11 --:--:--  338k

Received data seems to keep going up continuously. So what else should I do?

You have to eventually stop the command. Because we do not have access to your input, creating a sample file can possibly be used as an alternative input to attempt to duplicate the alleged issue.

Changed 9 months ago by qqqzhouhk

sample

comment:7 in reply to: ↑ 6 Changed 9 months ago by qqqzhouhk

Replying to llogan:

Replying to qqqzhouhk:

$ ffmpeg -i http://192.168.10.123:7060 -qscale 2 -vcodec mpeg4 out.mov
-bash: ffmpeg: command not found

You need to have a ffmpeg binary to run ffmpeg. So far you haven't provided any method for us to duplicate the issue, and we have no idea how FFmpeg is involved here. Are you using the FFmpeg libraries, or are you somehow using the ffmpeg cli tool (although if you are it appears not to be in your PATH)?

I'm assuming you're using the libraries because you mentioned something called "FFmpegDemo", but we do not support third-party tools. Testing with a recent ffmpeg binary will more easily show if the issue is valid here.

$ curl -o stream http://192.168.10.123:7060
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                  Dload  Upload   Total   Spent    Left   Speed
100 108M    0  108M    0   0        299k      0     --:--:--  0:06:11 --:--:--  338k

Received data seems to keep going up continuously. So what else should I do?

You have to eventually stop the command. Because we do not have access to your input, creating a sample file can possibly be used as an alternative input to attempt to duplicate the alleged issue.

I have already upload the sample file, please check the attachment. :)

comment:8 in reply to: ↑ 6 Changed 9 months ago by qqqzhouhk

Replying to llogan:

Replying to qqqzhouhk:

$ ffmpeg -i http://192.168.10.123:7060 -qscale 2 -vcodec mpeg4 out.mov
-bash: ffmpeg: command not found

You need to have a ffmpeg binary to run ffmpeg. So far you haven't provided any method for us to duplicate the issue, and we have no idea how FFmpeg is involved here. Are you using the FFmpeg libraries, or are you somehow using the ffmpeg cli tool (although if you are it appears not to be in your PATH)?

this is what I got when executing the above command line:

Last login: Wed Nov  2 15:56:47 on ttys000
huaikaideMacBook-Pro:~ apple$ ffmpeg -i http://192.168.10.123:7060 -qscale 2 -vcodec mpeg4 out.mov
ffmpeg version 3.1.3 Copyright (c) 2000-2016 the FFmpeg developers
  built with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
  configuration: --prefix=/Volumes/Ramdisk/sw --enable-gpl --enable-pthreads --enable-version3 --enable-libspeex --enable-libvpx --disable-decoder=libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-filters --enable-libgsm --enable-libvidstab --enable-libx265 --disable-doc --arch=x86_64 --enable-runtime-cpudetect
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 48.101 / 57. 48.101
  libavformat    57. 41.100 / 57. 41.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 47.100 /  6. 47.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mpjpeg, from 'http://192.168.10.123:7060':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj422p(pc, bt470bg/unknown/unknown), 640x480, 25 tbr, 25 tbn, 25 tbc
Please use -q:a or -q:v, -qscale is ambiguous
[swscaler @ 0x7f8fa201be00] deprecated pixel format used, make sure you did set range correctly
[mov @ 0x7f8fa1011e00] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Output #0, mov, to 'out.mov':
  Metadata:
    encoder         : Lavf57.41.100
    Stream #0:0: Video: mpeg4 (mp4v / 0x7634706D), yuv420p, 640x480, q=2-31, 200 kb/s, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.48.101 mpeg4
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg (native) -> mpeg4 (native))
Press [q] to stop, [?] for help
[mpjpeg @ 0x7f8fa1006200] Expected boundary '--' not found, instead found a line of 5 bytes
http://192.168.10.123:7060: Invalid data found when processing input
frame=    1 fps=0.0 q=2.0 Lsize=      18kB time=00:00:00.00 bitrate=1928923.1kbits/s speed=0.0102x
video:18kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.512364%

comment:9 follow-up: Changed 9 months ago by cehoyos

  • Component changed from undetermined to avformat
  • Keywords mpjpeg regression added
  • Priority changed from normal to important
  • Reproduced by developer set
  • Status changed from new to open
  • Version changed from unspecified to git-master

From a user's perspective, this is a regression since 6dc1d5f87ced885d748f8d0c7bfbc5ff6471483f

comment:10 in reply to: ↑ 9 Changed 9 months ago by qqqzhouhk

Replying to cehoyos:

From a user's perspective, this is a regression since 6dc1d5f87ced885d748f8d0c7bfbc5ff6471483f

Sorry, I am still confused about what is the problem and how can I fix it? If it possible, could you please give me more hints or explain it in details, I would really appreciate it. Thank you again!

comment:11 follow-up: Changed 9 months ago by cehoyos

Work-around is to specify -f mjpeg.

comment:12 in reply to: ↑ 11 Changed 9 months ago by qqqzhouhk

Replying to cehoyos:

Work-around is to specify -f mjpeg.

Man, you are awesome!! It works, but how can I achieve it when I am using FFMPEG library, as in FFMPEGdemo code? Thank you again, my bro!

comment:13 Changed 6 months ago by hackeron

I'm having the same issue:

$ ffmpeg -i 'http://admin:meinsm@192.168.100.232/cgi-bin/faststream.jpg?stream=full&fps=5.0&noaudio&data=v.mjpeg' -y test.mkv
ffmpeg version N-83119-g0ba0187 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
  configuration: --enable-libx264 --enable-libfdk_aac --enable-gpl --enable-nonfree --enable-shared --enable-pic --enable-openssl
  libavutil      55. 43.100 / 55. 43.100
  libavcodec     57. 72.100 / 57. 72.100
  libavformat    57. 62.100 / 57. 62.100
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 69.100 /  6. 69.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, mpjpeg, from 'http://admin:meinsm@192.168.100.232/cgi-bin/faststream.jpg?stream=full&fps=5.0&noaudio&data=v.mjpeg':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 640x480 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
No pixel format specified, yuvj420p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0x20bb920] using SAR=1/1
[libx264 @ 0x20bb920] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 0x20bb920] profile High, level 3.0
[libx264 @ 0x20bb920] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to 'test.mkv':
  Metadata:
    encoder         : Lavf57.62.100
    Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuvj420p(pc), 640x480 [SAR 1:1 DAR 4:3], q=-1--1, 25 fps, 1k tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.72.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[mpjpeg @ 0x20b60e0] Expected boundary '--' not found, instead found a line of 39 bytes
http://admin:meinsm@192.168.100.232/cgi-bin/faststream.jpg?stream=full&fps=5.0&noaudio&data=v.mjpeg: Invalid data found when processing input
frame=    2 fps=0.7 q=-1.0 Lsize=      64kB time=00:00:00.04 bitrate=12706.7kbits/s speed=0.0153x    
video:63kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.235873%
[libx264 @ 0x20bb920] frame I:1     Avg QP:29.30  size: 57648
[libx264 @ 0x20bb920] frame P:1     Avg QP:31.82  size:  6004
[libx264 @ 0x20bb920] mb I  I16..4:  0.7% 98.2%  1.1%
[libx264 @ 0x20bb920] mb P  I16..4:  0.0%  8.3%  0.0%  P16..4:  1.7%  1.8%  0.5%  0.0%  0.0%    skip:87.8%
[libx264 @ 0x20bb920] 8x8 transform intra:98.4% inter:93.5%
[libx264 @ 0x20bb920] coded y,uvDC,uvAC intra: 99.7% 2.5% 2.4% inter: 3.9% 0.1% 0.0%
[libx264 @ 0x20bb920] i16 v,h,dc,p: 100%  0%  0%  0%
[libx264 @ 0x20bb920] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  7% 32% 39%  3%  2%  2%  4%  3%  7%
[libx264 @ 0x20bb920] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 17% 29%  4%  3%  3%  4%  5%  7%
[libx264 @ 0x20bb920] i8c dc,h,v,p: 98%  1%  1%  0%
[libx264 @ 0x20bb920] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x20bb920] kb/s:6365.20
$

I cannot use the -f mjpeg workaround because I'm using ffmpeg through openCV where there is no option to pass this parameter.

Any ideas?

Note: See TracTickets for help on using tickets.