Opened 9 years ago

Closed 10 months ago

#5154 closed enhancement (fixed)

Demux h264 stream from Arecont camera

Reported by: Carl Eugen Hoyos Owned by:
Priority: wish Component: avformat
Version: git-master Keywords: h264
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

http://ffmpeg.org/pipermail/ffmpeg-user/2016-January/030122.html
A user provided a stream dump from his Arecont Vision AV20365CO. FFmpeg correctly autodetects the stream as h264 but every frame starts with a http content header that makes remuxing impossible:

$ ffmpeg -r 25 -i h264stream.dump -vcodec copy out.mov
ffmpeg version N-77810-g405abdb Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --enable-libx264
  libavutil      55. 13.100 / 55. 13.100
  libavcodec     57. 22.100 / 57. 22.100
  libavformat    57. 21.101 / 57. 21.101
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 23.100 /  6. 23.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
[h264 @ 0x29a9440] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, h264, from 'h264stream.dump':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: h264 (Baseline), yuv420p, 1280x960, 25 fps, 25 tbr, 1200k tbn, 50 tbc
[mov @ 0x2a378e0] Codec for stream 0 does not use global headers but container format requires global headers
Output #0, mov, to 'out.mov':
  Metadata:
    encoder         : Lavf57.21.101
    Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p, 1280x960, q=2-31, 25 fps, 25 tbr, 12800 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mov @ 0x2a378e0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
frame=   20 fps=0.0 q=-1.0 Lsize=   13897kB time=00:00:00.80 bitrate=142304.5kbits/s speed=34.4x
video:13896kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.006613%

The output file is unreadable.
The following works fine:

$ cat h264stream.dump | sed -u -b -e '/^--fbdr\r$/ {N;N;N;d}' | ffmpeg -i - -vcodec copy out.mov
ffmpeg version N-77810-g405abdb Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --enable-libx264
  libavutil      55. 13.100 / 55. 13.100
  libavcodec     57. 22.100 / 57. 22.100
  libavformat    57. 21.101 / 57. 21.101
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 23.100 /  6. 23.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
[h264 @ 0x27a33c0] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, h264, from 'pipe:':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: h264 (Baseline), yuv420p, 1280x960, 25 fps, 25 tbr, 1200k tbn, 50 tbc
[mov @ 0x27aa460] Codec for stream 0 does not use global headers but container format requires global headers
[mov @ 0x27aa460] WARNING codec timebase is very high. If duration is too long,
file may not be playable by quicktime. Specify a shorter timebase
or choose different container.
Output #0, mov, to 'out.mov':
  Metadata:
    encoder         : Lavf57.21.101
    Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p, 1280x960, q=2-31, 25 fps, 25 tbr, 1200k tbn, 1200k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
[mov @ 0x27aa460] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
frame=   20 fps=0.0 q=-1.0 Lsize=   13896kB time=00:00:00.76 bitrate=149782.4kbits/s speed=17.2x
video:13895kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.006635%

http://www.stardot-tech.com/developer/api.html describes a different but similar format, it also distinguishes between "Content-type: video/H.264I" for I-frames and "Content-type: video/H.264P" for P-frames.

Change History (2)

comment:2 by Marton Balint, 10 months ago

Resolution: fixed
Status: newclosed

This appears to work now :)

Note: See TracTickets for help on using tickets.