VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors. Consider supporting us by disable your adblocker or try DVDFab and copy, convert or make Blu-rays and DVDs! :)
+ Reply to Thread
Results 1 to 21 of 21
Thread
  1. Big problem with AVC1 encoded MP4 files playback in VLC and many other popular Windows players I tried, were the file is recorded with SYSM Camera Monitor in Windows 10 64-bit.

    One can view live footage and save audio & video from certain models of WiFi mini-cameras using SYSM Monitor, also known as P2PCamViewer. Its the only package I know that can recognize certain CN made mini WiFi Cam models. It shows camera footage on screen and allows to save it to disk, or manipulate the on-screen picture. It allows to save the muxed audio & video cam footage as generic MP4, AVI, or HKV file type (this one is MP4 proprietary format specific for CN cams). While I can play saved AVI footage, its impossible to play any recordings saved as MP4 or HKV on any software player I tried. Try this MP4 and HKV videos as examples.

    I'm not sure if this footage is in fact encoded by the WiFi camera itself based on file format option chosen in SYSM, or encoded by SYSM in Windows. However, CPU load is very small when recording the footage, hinting its probably encoded by the cam itself. Can someone suggest a codec allowing to play this video, and in which player? Latest version of SYSM Monitor comes with basic 200KB size HKV video player, editor, and converter to AVI that plays saved HKV files without problems (despite other players say the HKV file is invalid and doesn't contain any video), but not MP4 player. I prefer to save to MP4 as universally recognized format, but tried various media players, and none can play any MP4 from the cam saved by SYSM.

    Any ideas?
    Last edited by zamar27; 15th Jul 2018 at 20:46.
    Quote Quote  
  2. Upload a sample
    Quote Quote  
  3. You can download MP4 and HKV samples from the above links in the 1st post. I also uploaded MP4 sample to the forum, but for HKV the server says "Invalid file" upload error just like media players, so pls download from the Mediafire link. The issue with playing HKV files from cams was also reported here, and persisted for years without support from any popular player.
    Image Attached Files
    Last edited by zamar27; 15th Jul 2018 at 15:30.
    Quote Quote  
  4. I'm not a pro but the codec is mjpeg, resolution is 640x480, I played the file with MPC-BE and external LAV Splitter Source from LAV Fliters 0.70.1.
    Maybe other users can do more. I remember Budman1, 5th post here, he is a pro in my opinion
    https://forum.videohelp.com/threads/388744-How-would-I-go-about-fixing-asf-files-Or-wo...e-do-it-for-me
    Quote Quote  
  5. I just tried with current MPH-HC portable, which includes LAV Splitter, and it doesn't work well for the MP4 file, but played the HKV file with mjpeg video. Do I need to change some settings to view the MP4 video, since now it plays only audio?

    I added an external LAV Splitter from a portable LAV Filters source to portable MPH-BE, as I wanted to try your playback method, but it didn't play the MP4 video either. I then added external LAV filters to PotPlayer and set Preferred in prefs for H264, but it still doesn't play the MP4 correctly. What settings did you use for LAV Splitter Source to make the MP4 watchable, or you were only able to watch the HKV file?
    Last edited by zamar27; 18th Jul 2018 at 10:00.
    Quote Quote  
  6. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    Okay... your MP4's are ' Not really MP4s'.. they have merely added a different (proprietary?) header at the top instead of the ones for HKV. HKVs play correctly in Potplayer and can be converted using FFmpeg to an MP4. I took one of the MP4's that did NOT play, loaded it into the hex editor 'HxD' and replaced the header with one from an HKV up to the bytes that normally follow MP4 that look like YOYU but are hex characters. Save it as an HKV file extension.

    This allows it to be played as well as converted to an mp4. The following pictures are from an HKV converted to MP4 on the left and an MP4 converted to HKV by replacing the header on the right. The date shows it was actually the correct converted one.

    To convert to MP4 from HKV use FFmpeg -i <video.hkv> -vcodec libx264 -acodec copy <outputname.mp4>

    Image
    [Attachment 46081 - Click to enlarge]


    Below is the MP4 Header and how it was replaced by the HKV header

    Original Header
    Image
    [Attachment 46082 - Click to enlarge]


    Replaced Header
    Image
    [Attachment 46083 - Click to enlarge]
    Quote Quote  
  7. Changing the extension from .hkv to .ts allowed several players to play the original hkv video (but not VLC, no player played any audio, ffprobe showed no audio chunks, only video chunks). Remuxing the hkv to MOV and MKV with ffmpeg resulted in a video that played with several players, including VLC (again, no audio).
    Image Attached Files
    Quote Quote  
  8. Thank you guys.

    @ Budman1
    Hmm, so the MP4 files saved by SYSM and possibly encoded by the cam, are in fact HKV files with a different header? Why then MediaInfo tool in players says Video codec H264 MPEG-4 AVC (part 10) for the MP4 file, and Mjpeg for the HKV file I posted? If this is the same codec, it should read the same in MediaInfo - correct? Once you replaced the header, did MediaInfo still read it as H264, or as Mjpeg encoded? Or it just identifies media codecs from whatever is written in the file header?
    Quote Quote  
  9. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    Not quite correct. The mp4 files are mp4 with avc/264 coding but are quicktime format that just don't play in any of my players. The HKV files seem to be just an mp4 (qtime) file with a different header. The hkv file play in my Potplayer and others using ffmpeg codec. That is why if you have the unplayable mp4 and you replace the header and rename HIV, it play as an hkv. This can be converted to a VALID mp4 file that plays on many viewers.

    If you notice in my images, the "mdat" is overplayed by the hkv header. This is normally necessary for an mp4.

    As far as what mediainfo reports, and I may be wrong here, my experience is it reports what's in the header and if it's not there it looks further inside. That's why the encoding format on some AVC 264 mp4s do not show in the initial mediainfo report but you can get this by forcing mediainfo to look deeper
    Last edited by Budman1; 15th Jul 2018 at 21:25.
    Quote Quote  
  10. But the original HKV file saved by SYSM has mjpeg video, while the original MP4 from SYSM has H264 video. So I assume the difference btw MP4 and HKV saved by SYSM is H264 vs Mjpeg video codec used - correct? And after you replaced the header, the video is still H264, so the new file still uses a different codec from original HKV, hence its not really HKV?
    Quote Quote  
  11. "The SYSM Monitor application can also be used to export these .hkv files to the AVI file format. This software is recommended for playing and exporting these HKV video files."
    Are there export settings in your program?
    source:
    https://file.org/extension/hkv
    Quote Quote  
  12. No, just Export - Save As AVI. The link to a standalone player is in the 1st post. However, HKV video files are not so frequently found despite proliferation in the world of CN made Cams. I guess they invent format incarnations to avoid paying licensing fees. The problem is, no popular player can run their MP4 files, may be some less known Chinese player can, otherwise why would they even offer to save as MP4?

    Got interesting reply here from VLC devs: "Seem they put MJPEG inside MP4 as AVC and expect it to work somewhere else... ".
    Last edited by zamar27; 16th Jul 2018 at 19:25.
    Quote Quote  
  13. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    AFAIK... or what I can find, HKV are composed of MJPEG images instead of normal GOP type bidirectional referencing frames (I,B,P).

    No. pts_time type
    0 0.000000 1 I
    1 0.040000 1 I
    2 0.080000 1 I
    3 0.120000 1 I
    4 0.160000 1 I
    5 0.200000 1 I
    6 0.240000 1 I
    7 0.280000 1 I
    8 0.320000 1 I
    9 0.360000 1 I
    FFprobe reports they are all I-Frames (or more or less complete frames... MJPEG?) MediaInfo shows information on the MP4s that are unplayable as avc type but only in the atoms describing them, encoded in QuickTime format but they must be still MJPEG because just changing the header does not change a files format or coding. This probably why they do not play and can be changed so easily.

    Image
    [Attachment 46098 - Click to enlarge]


    One quick question... I know VLC will not play HKV files on my computer but PotPlayer does because it uses FFmpeg codec and the files can be changed to valid MP4 using FFmpeg. What is your main goal? Have MP4s directly from camera? Would converting (can be done batch like) with FFmpeg to MP4 be satifactory?

    Right now you have HKV that can be played by some viewers and MP4's that can only be changed back to HKV, right?
    Quote Quote  
  14. The main goal is to run daily clips list through motion detection software to identify clips with continuous motion, since SYSM doesn't support motion detection in software, and the cams are tiny with no MD in HW. Is there a package that can do that?

    Now on top I apparently need to batch convert HKV to MP4 first with FFmpeg. Can it also join the converted clips together?

    Still its not clear why SYSM offers to save to a fake MP4 which no video player can play...
    Quote Quote  
  15. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    Is there a package that can do that?
    Courtesy of Shinmai at superuser...> You can use the select FFMPEG filter with the scene expression, that compares the similarity of consecutive frames: select=gt(scene\,0.003) for instance. The higher the number, the more change between frames is ignored, in quick testing you might need to go as low as 0.00001-0.00005 depending on the kind of footage you're dealing with. Similar to :
    Code:
     ffmpeg -i input.mp4 -vf "select=gt(scene\,0.003),setpts=N/(25*TB)"  output.mp4
    Now on top I apparently need to batch convert HKV to MP4 first with FFmpeg. Can it also join the converted clips together?
    Joining clips is mainly dependent on them being the same in format, container, bit rate, etc. Also audio can get out of sync and need to be corrected if not done correctly. The good news is, your videos don't seem to contain audio anyweay and since you will be converting them, they would all be the same if you used the same batch command or script to convert them so they should have few problems by many programs when you join (Including FFmpeg again if you choose.)

    Still its not clear why SYSM offers to save to a fake MP4 which no video player can play...
    It may be that the developers put together a package/codec to convert their files to the more popular MP4 but didn't test it fully. Unless they hear regularly from users who use HKV, they probably know of no reason to change it. I'm assuming they are not easy to contact?
    Quote Quote  
  16. mov is better suited than mp4 for MJPEG. Most programs that can deal with mp4 can deal with mov.
    Quote Quote  
  17. The HKV clips do contain audio from the cam, when Cam Mic recording is switched On in SYSM.

    Is it possible to analyze the HKV (Mjpeg) clips for motion detection in FFmpeg without converting them first to MP4 or MOV? What would FFmpeg "Join Clips" command look like in this case?

    If MOV is better suited for Mjpeg, and can be analyzed for motion detection after converting HKV to MOV, will the required FFmpeg command be similar to MP4 motion detection command above?

    I tried to ask the SYSM dev about MP4 fake format and suggested file viewer, but never got any reply. Its kind of strange he never tested the converter, unless its all encoded in HW by the cam. Can't ask the manufacturer, since these cams are "generic".
    Quote Quote  
  18. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    Is it possible to analyze the HKV (Mjpeg) clips for motion detection in FFmpeg without converting them first to MP4 or MOV? What would FFmpeg "Join Clips" command look like in this case?
    Yes! I washed it through a program I have half built already and only needed to use 0.300000 variance on your HKV because there was a lot of motion. ( the variance shown in the image below is truncated... Got to fix that. LOL)

    I tried to COPY the frames to HKV but it failed and COPYING the HKV to an MP4 (MJPEGs) it faiiled like the MP4's you supplied. Wow, Imagine that! So I created a re-encoded mp4 and it played perfect.
    Image
    [Attachment 46104 - Click to enlarge]
    Image
    [Attachment 46105 - Click to enlarge]



    Just to be careful I used a bad (grainy video) with .003000 variance and got thewhole thing. Check the images in my program and there are multiple pages so it caught everything.

    Image
    [Attachment 46106 - Click to enlarge]
    Image
    [Attachment 46107 - Click to enlarge]



    If MOV is better suited for Mjpeg, and can be analyzed for motion detection after converting HKV to MOV, will the required FFmpeg command be similar to MP4 motion detection command above?
    Yes You just have to specify the file name and ffmpeg uses the codec necessary to analyze it. BUT it already analyzes the HKV so that shouldn't be a biggy.

    I tried to ask the SYSM dev about MP4 fake format and suggested file viewer, but never got any reply. Its kind of strange he never tested the converter, unless its all encoded in HW by the cam.
    Looks like the same problem as when I tried to COPY the MJPEGS into an MP4 container. Had to actually re-encode with libx264 codec.
    Quote Quote  
  19. Wow... That would be quite useful program, given the number of small CN Cam incarnations, which don't do motion detection in HW, and are neither recognized by any popular surveillance packages, probably because they are Ad-Hoc cams, not real IP cams. Any way to test your program? It seems to have gone through several versions already.

    Interesting is, the SYSM dev managed to copy MJPEG frames to MP4, but the effort was fruitless anyway. I wonder if he selected the right encoder settings? It might be he was unable to copy the frames as MJPEG, and then decided to copy them as H264 if that trick is possible, but simply fooled himself and the cam users.
    Last edited by zamar27; 18th Jul 2018 at 10:05.
    Quote Quote  
  20. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    The program is actually supposed to divide a video up by scene changes with the first image denoting the first scene, the second image the second scene, etc. The main thing I am trying to do, and looks good so far, is cut on precise frame AND make the first frame timestamp 0.000000 so there are less problems when someone joins them

    I notice many programs seem to cut on an I-frame boundary but the beginning has an arbitrary amount of voice with repeated frames frozen. Most of the time this is unnoticeable at the beginning but shows up after trying to join segments as voice sync. It is particularly noticeable if you cut any mid GOP (between I-frame of 250 gop).

    Anyway it cuts pretty well so far. The problem is it uses ffmpeg, ffprobe and ffplay which are not speed demons. It analyzes about 3.75-4 mbps on my computer so...

    The program will show exact cut point with a label embedded with frame number and timestamp to microsecond if you left click the image. It plays the scene of you right click it. Also with embedded timestamps and frame number.

    It will also produce a list of all frames and their timestamps to be used manually if someone wishes. So far the first 2 image,scenes information can be adjusted manually for trimming an entire segment.

    So it was not originally made to do motion detection, it does this by adjusting the scene change variable quite well, especially with security which has the same scene for long durations.
    Quote Quote  
  21. Did you try DVR-Scan and similar OpenCV packages? I wonder if they address audio sync and speed issues in motion detection video post-processing you mentioned?

    Some more links:

    Basic motion detection and tracking with Python and OpenCV
    Motion detection using OpenCV
    Python motion detection tool

    Also, I didn't know VLC has motion detection filter.
    Last edited by zamar27; 20th Jul 2018 at 09:35.
    Quote Quote  



Similar Threads