Opened 15 months ago

Last modified 15 months ago

#9306 reopened defect

Can't handle slightly broken MP4 from some Hikvision IP camera + workaround

Reported by: marekm Owned by:
Priority: normal Component: avformat
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Reported in VLC as well:
https://code.videolan.org/videolan/vlc/-/issues/25864

Files downloaded from the NVR that were recorded from the Hikvision DS-2DE7184-AE (PTZ IP camera) are slightly broken in that VLC (latest as well as 3 years old tested) doesn't play them correctly, just shows still picture the whole time (the same file works fine in Hikvision VSPlayer and Linux mplayer). I have a few other IP cameras recorded by the same NVR but files from them don't show the same issue. ffmpeg can't copy such files even without any conversion, see the log below. The workaround is to repair the file using this command (just remove the audio, which I don't care about anyway - the camera has no microphone connected):

ffmpeg -i input.mp4 -c:v copy -an output.mp4

Yes, removing the audio allows video to play in VLC correctly!
Hopefully this will give a hint where the bug could be.
(well, it's in that Hikvision camera, but can't fix that - so "be liberal in what you accept")
I can provide sample files, but they are big (~1 GB).
The above command works fine, the below one doesn't, see the log:

ffmpeg -i input.mp4 -c copy output.mp4

ffmpeg started on 2021-06-27 at 22:54:25
Report written to "ffmpeg-20210627-225425.log"
Log level: 48
Command line:
"..
..
ffmpeg.exe" -report -i 00000000152000000.mp4 -c copy b.mp4
ffmpeg version 2021-06-27-git-49e3a8165c-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers

built with gcc 10.3.0 (Rev2, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libglslang --enable-vulkan --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora libavutil 57. 0.100 / 57. 0.100
libavcodec 59. 2.100 / 59. 2.100
libavformat 59. 3.101 / 59. 3.101
libavdevice 59. 0.100 / 59. 0.100
libavfilter 8. 0.103 / 8. 0.103
libswscale 6. 0.100 / 6. 0.100
libswresample 4. 0.100 / 4. 0.100
libpostproc 56. 0.100 / 56. 0.100

Splitting the commandline.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Reading option '-i' ... matched as input url with argument '00000000152000000.mp4'.
Reading option '-c' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option 'b.mp4' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url 00000000152000000.mp4.
Successfully parsed a group of options.
Opening an input file: 00000000152000000.mp4.
[NULL @ 00000000005b2940] Opening '00000000152000000.mp4' for reading
[file @ 00000000005c8340] Setting default whitelist 'file,crypto,data'
[mpeg @ 00000000005b2940] Format mpeg probed with size=1048576 and score=52
[mpeg @ 00000000005b2940] Before avformat_find_stream_info() pos: 6 bytes read:1048576 seeks:0 nb_streams:0
[mpeg @ 00000000005b2940] parser not found for codec pcm_mulaw, packets or times may be invalid.
[extract_extradata @ 00000000005cd700] nal_unit_type: 7(SPS), nal_ref_idc: 3
[extract_extradata @ 00000000005cd700] nal_unit_type: 8(PPS), nal_ref_idc: 3
[extract_extradata @ 00000000005cd700] nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 00000000005c8980] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 00000000005c8980] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 00000000005c8980] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 00000000005c8980] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 00000000005c8980] nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 00000000005c8980] Format yuv420p chosen by get_format().
[h264 @ 00000000005c8980] Reinit context to 1920x1088, pix_fmt: yuv420p
[h264 @ 00000000005c8980] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[h264 @ 00000000005c8980] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[h264 @ 00000000005c8980] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[h264 @ 00000000005c8980] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[h264 @ 00000000005c8980] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[h264 @ 00000000005c8980] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[mpeg @ 00000000005b2940] Probe buffer size limit of 5000000 bytes reached
[mpeg @ 00000000005b2940] rfps: 10.000000 0.009976
[mpeg @ 00000000005b2940] rfps: 15.000000 0.010102
[mpeg @ 00000000005b2940] rfps: 24.916667 0.011671
[mpeg @ 00000000005b2940] rfps: 25.000000 0.000110
[mpeg @ 00000000005b2940] rfps: 25.000000 0.000110
[mpeg @ 00000000005b2940] rfps: 25.083333 0.015204
[mpeg @ 00000000005b2940] rfps: 35.000000 0.010071
[mpeg @ 00000000005b2940] rfps: 40.000000 0.010449
[mpeg @ 00000000005b2940] rfps: 50.000000 0.000442
[mpeg @ 00000000005b2940] rfps: 50.000000 0.000442
[mpeg @ 00000000005b2940] rfps: 60.000000 0.010386
[mpeg @ 00000000005b2940] rfps: 59.940060 0.014711
[mpeg @ 00000000005b2940] rfps: 14.985015 0.010223
[mpeg @ 00000000005b2940] rfps: 14.985015 0.010223
[mpeg @ 00000000005b2940] After avformat_find_stream_info() pos: 6 bytes read:5344420 seeks:2 frames:172
Input #0, mpeg, from '00000000152000000.mp4':

Duration: 00:17:45.10, start: 3597.910689, bitrate: 8002 kb/s
Stream #0:0[0x1e0], 49, 1/90000: Video: h264 (Main), yuv420p(tv, bt709, progressive), 1920x1080, 10 fps, 25 tbr, 90k tbn
Stream #0:1[0x1c0], 123, 1/90000: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s

Successfully opened the file.
Parsing a group of options: output url b.mp4.
Applying option c (codec name) with argument copy.
Successfully parsed a group of options.
Opening an output file: b.mp4.
[file @ 0000000003527d40] Setting default whitelist 'file,crypto,data'
Successfully opened the file.
[mp4 @ 0000000002d69c00] Could not find tag for codec pcm_mulaw in stream #1, codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:1 --
Stream mapping:

Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)

[AVIOContext @ 0000000003527e00] Statistics: 0 seeks, 0 writeouts
[AVIOContext @ 00000000005d05c0] Statistics: 5344420 bytes read, 2 seeks

Change History (3)

comment:1 by marekm, 15 months ago

Component: undeterminedffmpeg
Version: unspecifiedgit-master

comment:2 by Carl Eugen Hoyos, 15 months ago

Component: ffmpegavformat
Resolution: needs_more_info
Status: newclosed

Please reopen this ticket if you can provide a sample file.

comment:3 by marekm, 15 months ago

Resolution: needs_more_info
Status: closedreopened

Here are the sample files (~1 GB each, and you really only need the first one - the second fixed one is the result of "ffmpeg -c:v copy -an" on the first, and plays correctly).

http://91.224.224.43/podpalenie20180409/maszt/00000001541000000.mp4
http://91.224.224.43/podpalenie20180409/maszt/00000001541000000-fixed.mp4

In case you are wondering about the contents - yes it was my car, and the criminal who has set it on fire over 3 years ago still hasn't been caught.

Note: See TracTickets for help on using tickets.