VideoHelp Forum
+ Reply to Thread
Results 1 to 7 of 7
Thread
  1. Hello, I am talking as an employee of a small company operating surveillance systems. I'm new and I have a problem with ffmpeg converting video files.

    The resulting files are corrupted, namely from converting .dat files (that are fine) into .mp4 files. The files are used to provide pseudo-livestream for a website. The conversation is done with ffmpeg and I am hoping that there is a quick solution.

    The results can be seen here: http://balatonlelle.dyndns.tv/kamera/

    The first few seconds are fine but the video becomes increasingly corrupted as the image moves.

    As seen, it shows a panorama camera's view of lake Balaton (popular holiday resort), so people can see the current state of the weather at the lake. While it is not a straight-on redirected stream, the converted files are constantly updated and the delay is merely minutes. The reason this method was chosen was from a desire that the video could be viewed from phones, back in the day, and would not require installing ActiveX addons and such to play. Hence why .mp4 format.

    The heart of the problem is twofold: first, the person who made the system is gone and left no documentation (and worse, is unavailable). Compounding the problem is that the server is a Windows XP machine and we have no funds to replace it at the moment (nor time to just make a new one as we have to go out to various locations to fix problems at locations).

    Here is the commands used in the batch file (or rather, the problematic bit) that contains command for using ffmpeg:
    copy /Y %1 %2
    set gg=%3
    set mit=%gg:~0,14%
    vid\ff\bin\ffmpeg -y -t 00:01:00 -ss 00:00:15 -r 10 -i vid\honnan\%mit%.dat -s 1280x720 -b:v 4M -preset ultrafast %2\%4.ogg
    move %2\%4.ogg vid\konvert
    vid\ff\bin\ffmpeg -y -t 00:01:00 -ss 00:00:15 -r 10 -i vid\honnan\%mit%.dat -s 1280x720 -b:v 4M -preset ultrafast %2\%4.mp4
    move %2\%4.mp4 vid\konvert
    del /F vid\honnan\%mit%.*
    rem pause
    exit
    I belive %1 and %2 are filenames, as the resulting files in the "konvert" directory are named things like

    Details of the system are below. I highlighted the problem area.

    How it works: the server plays several roles:
    1. It acts as a virtual NVR (through a network) for the panorama camera. This is done with an old version of Central Management Software. Said software continuously makes new .dat video files from panorama camera feed. This part works fine.
    2. A batch file is run that copies the latest .dat file and moves them into a different folder, readying it for conversation and deleting old files. I believe that the converstion is two-step, with the first step is converting it from a .dat file into a .avi file. This too works (the .avi file is not corrupted).
    3. PROBLEM-> A sub-batch file is run to convert the file, that I gave the code for in the above. An .mp4 video file is created. This is where the problem is as the .mp4 file is corrupted. I have checked with VLAN and it is the converted .mp4 file that is bad, not the original .dat or .avi file.
    4. The server acts as an xampp host for the the webpage linked above via xampp. The video that is seen is from a .mp4 file that is located on the server machine. As the webpage works, this part too works fine.
    5. The webpage allows playing the .mp4 file. This works.

    The version of ffmpeg used is 2014-05-14 git-0aac9b7. I have tried the latest version but that causes problems and does not work.

    I am hoping that someone savvy with FFmpeg might spot what is wrong with this, rather than require several hours of experimenting or making another batch file from scratch.
    Quote Quote  
  2. Originally Posted by Vidikon View Post
    Hello, I am talking as an employee of a small company operating surveillance systems. I'm new and I have a problem with ffmpeg converting video files.

    The resulting files are corrupted, namely from converting .dat files (that are fine) into .mp4 files. The files are used to provide pseudo-livestream for a website. The conversation is done with ffmpeg and I am hoping that there is a quick solution.

    The results can be seen here: http://balatonlelle.dyndns.tv/kamera/

    The first few seconds are fine but the video becomes increasingly corrupted as the image moves.

    As seen, it shows a panorama camera's view of lake Balaton (popular holiday resort), so people can see the current state of the weather at the lake. While it is not a straight-on redirected stream, the converted files are constantly updated and the delay is merely minutes. The reason this method was chosen was from a desire that the video could be viewed from phones, back in the day, and would not require installing ActiveX addons and such to play. Hence why .mp4 format.

    The heart of the problem is twofold: first, the person who made the system is gone and left no documentation (and worse, is unavailable). Compounding the problem is that the server is a Windows XP machine and we have no funds to replace it at the moment (nor time to just make a new one as we have to go out to various locations to fix problems at locations).

    Here is the commands used in the batch file (or rather, the problematic bit) that contains command for using ffmpeg:
    copy /Y %1 %2
    set gg=%3
    set mit=%gg:~0,14%
    vid\ff\bin\ffmpeg -y -t 00:01:00 -ss 00:00:15 -r 10 -i vid\honnan\%mit%.dat -s 1280x720 -b:v 4M -preset ultrafast %2\%4.ogg
    move %2\%4.ogg vid\konvert
    vid\ff\bin\ffmpeg -y -t 00:01:00 -ss 00:00:15 -r 10 -i vid\honnan\%mit%.dat -s 1280x720 -b:v 4M -preset ultrafast %2\%4.mp4
    move %2\%4.mp4 vid\konvert
    del /F vid\honnan\%mit%.*
    rem pause
    exit
    I belive %1 and %2 are filenames, as the resulting files in the "konvert" directory are named things like

    Details of the system are below. I highlighted the problem area.

    How it works: the server plays several roles:
    1. It acts as a virtual NVR (through a network) for the panorama camera. This is done with an old version of Central Management Software. Said software continuously makes new .dat video files from panorama camera feed. This part works fine.
    2. A batch file is run that copies the latest .dat file and moves them into a different folder, readying it for conversation and deleting old files. I believe that the converstion is two-step, with the first step is converting it from a .dat file into a .avi file. This too works (the .avi file is not corrupted).
    3. PROBLEM-> A sub-batch file is run to convert the file, that I gave the code for in the above. An .mp4 video file is created. This is where the problem is as the .mp4 file is corrupted. I have checked with VLAN and it is the converted .mp4 file that is bad, not the original .dat or .avi file.
    4. The server acts as an xampp host for the the webpage linked above via xampp. The video that is seen is from a .mp4 file that is located on the server machine. As the webpage works, this part too works fine.
    5. The webpage allows playing the .mp4 file. This works.

    The version of ffmpeg used is 2014-05-14 git-0aac9b7. I have tried the latest version but that causes problems and does not work.

    I am hoping that someone savvy with FFmpeg might spot what is wrong with this, rather than require several hours of experimenting or making another batch file from scratch.
    At first you can use newer ffmpeg compiled to run on XP - at least i would give a chance to newer version https://ffmpeg.zeranoe.com/forum/viewtopic.php?p=10000#p10000

    Secondly not sure if ffmpeg configuration is most optimal - but this is not main issue for you.

    Are you able to provide samples - source before and after conversion (after with errors)? If not then perhaps you can add "-report" and upload log created by ffmpeg - then we can see if there any complains (perhaps issue is somewhere else).

    I'm not command-line guru (some guys on forum are way more advanced than i) however seem there are 4 parameters passed to script %1 %2 are assume are foldernames but variable gg use %3 parameter and also seem there %4 - "-report" may help

    btw this is wrong forum - ffmpegx is explicitly Macintosh (Apple) ffmpeg app version. It is not highly popular - perhaps you should ask moderator to move this thread to more appropriate .
    Quote Quote  
  3. Mod Neophyte Super Moderator redwudz's Avatar
    Join Date
    Sep 2002
    Location
    USA
    Search Comp PM
    I'll move the thread to Newbie/General forum.
    And welcome to our forums.

    Moderator redwudz
    Quote Quote  
  4. I'm sorry I posted in the wrong forum section. I simply saw "ffmpeg" and thought it was the ideal place. I did not know that ffmpegX was its own thing.

    I can provide two samples, although not of the same time. One of the .avi and one of the .dat files.

    .Avi
    https://drive.google.com/file/d/1UErtffEX-gp02Va7MimgJbUlrNF5-8_V/view?usp=sharing
    .dat
    https://drive.google.com/file/d/1uESZIymH17sYJmdu-2BghElDK1O4x6P4/view?usp=sharing

    (I just noticed that when the google drive's video preview plays the .dat file, the video is corrupted in a similar manner as in the end product, which confuses me).
    Quote Quote  
  5. I dug around the batch file and I am afraid that the conversation process is a bit more complicated than I thought. Virtualdub is invovled (it is found among the folders).


    I will now post the complete batch file. Note that "576p.bat " is posted above.

    Translations: "töröljük a nem szükséges videókat" = "delete the unnecessary video files"


    rem @echo off
    set konyvtar=C:\RecData5319ebd4cff4454597aad4d0c111490 7\
    set kam1=0018ae3f302400
    set kam1_dat=@
    set hova=c:\xampp\htdocs\kamera\vid\honnan
    set tid=
    set kam1_time=0

    call torol.bat %konyvtar%%kam1%
    rem töröljük a nem szükséges videókat
    for /f "skip=3" %%G IN ('dir /b /a-d /o-d "%konyvtar%%kam1%"') DO del %konyvtar%%kam1%\%%G

    for /F "tokens=2 delims= " %%A IN ('tasklist /FI ^"imagename eq cmd.exe^" /NH ') DO (
    set tid=%%A
    goto again
    )

    rem timeout /t 30
    :again
    set /A cou=1
    :loop
    echo %cou%
    ping -4 -n 6 "" > nul
    rem timeout /t %kam1_time%
    del /F %hova%\*.dat
    del /F c:\xampp\htdocs\kamera\vid\hova\*.avi
    set line=
    for /f "skip=1" %%G IN ('dir /b /a-d /o-d "%konyvtar%%kam1%"') DO if not defined line set "line=%%G"
    rem pause
    if %kam1_dat% neq %line% (
    set "kam1_dat=%line%"
    start konvert-576p.bat %konyvtar%%kam1%\%line% %hova% %line% kam1
    set kam1_time=6
    )
    timeout /t 30
    if %cou%==300 (
    call taskkill /F /IM cmd.exe /FI ^"PID ne %tid%^" /T
    timeout /t 12
    for /R "c:\xampp\htdocs\kamera\vid\VirtualDub\" %%I IN ("vdsub.zip") DO (
    "c:\Program Files\7-Zip\7z.exe" x -y -o"%%~dpI" "%%~fI"
    )
    for /f "skip=3" %%G IN ('dir /b /a-d /o-d "%konyvtar%%kam1%"') DO del %konyvtar%%kam1%\%%G
    goto again
    ) ELSE (
    set /A cou+=1
    goto loop
    )
    timeout /t 30
    torol.bat
    SETLOCAL ENABLEDELAYEDEXPANSION
    set line=
    for /f %%G IN ('dir /b /a-d /o-d "%1"') DO (
    set "line=%%G"
    FOR %%A IN (%1\!line!) DO (
    set "size=%%~zA"
    if !size! LSS 40000000 (
    del %1\!line!
    )
    )
    )
    ENDLOCAL
    Quote Quote  
  6. Originally Posted by pandy View Post
    Originally Posted by Vidikon View Post
    [snip]
    At first you can use newer ffmpeg compiled to run on XP - at least i would give a chance to newer version https://ffmpeg.zeranoe.com/forum/viewtopic.php?p=10000#p10000

    Secondly not sure if ffmpeg configuration is most optimal - but this is not main issue for you.

    Are you able to provide samples - source before and after conversion (after with errors)? If not then perhaps you can add "-report" and upload log created by ffmpeg - then we can see if there any complains (perhaps issue is somewhere else).

    I'm not command-line guru (some guys on forum are way more advanced than i) however seem there are 4 parameters passed to script %1 %2 are assume are foldernames but variable gg use %3 parameter and also seem there %4 - "-report" may help

    btw this is wrong forum - ffmpegx is explicitly Macintosh (Apple) ffmpeg app version. It is not highly popular - perhaps you should ask moderator to move this thread to more appropriate .
    I have been experimenting with this and it turns otu that the heart of the problem lies with the original file. I noticed when I accidentally played it back when uploading it on google drive, the browser's webplayer giving the same corruption as before. VLC of course plays it back fine.

    So it is not that the conversion process that's messing up the file, it's something that the conversation doesn't do.

    My theory is that the converted files lack some kind of metadata that allows proper playback. VLC, being very robust, manages to find its way to give proper playback without this metadata (perhaps some sort of codec issue). That it lacks such metadata makes some sense, as these are files copied out from the NVR software's folders.

    The question I want to figure out is how to force new metadata unto converted files. This is a problem my predecessor tried to get around by using virtualdub. I may end up just writing a new batch file and method.

    Oh and I tried having the XP server machine with a newer ffmpeg that you linked. It does not solve the problem.
    Quote Quote  
  7. I have made progress.

    I managed to find out how to get ffmpeg to convert the .dat files correctly. All I had to do was:

    ffmpeg -f h264 source.dat output.mp4
    When I add that (specifying the origin file's codec), the resulting video is free of the corruption. I tested this with the same version of ffmpeg that the server machine uses.

    I have tried to add it to the batch file, it just doesn't run and the resulting file that should appear, doesn't.
    Quote Quote  



Similar Threads