VideoHelp Forum
+ Reply to Thread
Results 1 to 19 of 19

Thread: rewriting avi?

Thread
  1. Member
    Join Date: Apr 2013
    Location: Italy
    Search PM
    Hi

    I have do an experiment:

    cfourcc.exe -i input.avi -u MJPG -d MJPG

    where input.avi is an .avi yuy2 file of 18GB

    ccfourcc have changed the tag from yuy2 to MJPG in "0" second, without waiting, it don't have rewrite the avi file.

    How is possible? if I change hex values into a file I still have to rewrite it, or not?


    ps. I have download cfourcc from the Release.7z by this page

    http://forum.videohelp.com/threads/341713-GUI-Tool-created-for-batch-video-tasks
    Last edited by marcorocchini; 5th May 2014 at 07:16.
    Quote Quote  
  2. vanished El Heggunte's Avatar
    Join Date: Jun 2009
    Location: Misplaced Childhood
    Search Comp PM
    Originally Posted by marcorocchini View Post
    Hi

    I have do an experiment:

    cfourcc.exe -i input.avi -u MJPG -d MJPG

    where input.avi is an .avi yuy2 file of 18GB

    ccfourcc have changed the tag from yuy2 to MJPG in "0" second, without waiting, it don't have rewrite the avi file.

    How is possible? if I change hex values into a file I still have to rewrite it, or not?
    Probably the application overwrites only the disk cluster that contains the offending info.
    Quote Quote  
  3. Any program can open an existing file, change a few bytes, and only update the portion of the file that it changed. So only four bytes have to be written if you're only changing four bytes. In practice, Windows will read at least one sector (or maybe an entire cluster) change the four bytes, then write back the entire sector (or cluster) -- because that's the smallest I/O unit you can transfer on a hard drive.

    It's only necessary to rewrite the entire file if you insert or remove data. Then everything after the insertion/removal point (at least) has to be rewritten. With many kinds of files it's easier to rewrite the the entire file because other structures (indices, lengths, pointers, etc.) within the files have to be updated when you insert or remove data. AVI, files, for example.
    Last edited by jagabo; 5th May 2014 at 08:56.
    Quote Quote  
  4. Member
    Join Date: Apr 2013
    Location: Italy
    Search PM
    thank you jagabo, so if I would like replace a block as this

    Click image for larger version

Name:	TC10.JPG
Views:	14
Size:	173.0 KB
ID:	24959

    how should I do?
    is there a dos-command or a program that can auto-modify a .avi file?
    Quote Quote  
  5. Member
    Join Date: Mar 2008
    Location: United States
    Search Comp PM
    How about the HEX editor in Virtualdub ?
    Quote Quote  
  6. I think you're screwing up the RIFF structure with that cut/paste hack. Use the RIFF viewer in VirtualDub's hex editor to verify.
    Last edited by jagabo; 5th May 2014 at 11:04.
    Quote Quote  
  7. Member
    Join Date: Apr 2013
    Location: Italy
    Search PM
    I can change .avi files with hex editor gui ecc.. but I need to batch automate the timecode writing in file, so I'm looking for a dos command line to simply replace a block of data as image attached
    Quote Quote  
  8. You need to understand RIFF structure before you can make patches like that.
    http://msdn.microsoft.com/en-us/library/windows/desktop/dd318189%28v=vs.85%29.aspx
    Quote Quote  
  9. Member
    Join Date: Apr 2013
    Location: Italy
    Search PM
    I know that my procedure are not regular, but teorically if I want timecode I have to change virtualdub and this is not possible.

    I am not able to rewrite a version of virtualdub that do timecode as I want, and think nobody is able to do. Simply I just noticed that replacing bytes as show in attachement, my NLE have the timecode of the clip and and the clip are perfet playable. Analizing riff chink of the .avi file of course I get a "invalid chunk error" but this is not important when I can use clip with timecode in nle and all work ok.

    Being that I have no chance to rewrite virtualdub for my specific needs, I'm forced to find a way to change "manually" and automatically with a batch procedure, individual bytes and an entire block in the file .avi header
    Quote Quote  
  10. If you really want to screw up your files like that search for binary patch utilities.
    Quote Quote  
  11. if the position and size of the data is consistantly in the same place for each of the .avi files, and does not require moving data downward, then it may be possible. same way the cfourcc.exe app is doing it with the fourcc tag name--it is only four chars.

    VHELP's - Sample Clips [last: 12.29.06],
    my YouTube videos
    Quote Quote  
  12. Member Cornucopia's Avatar
    Join Date: Oct 2001
    Location: Deep in the Heart of Texas
    Search Comp PM
    Except not all AVIs will have that consistently in quite the same place, nor of the same length. To do it right, one needs to parse the RIFF structure and insert/change/remove things accordingly so the structure remains intact and proper. Otherwise, you might get lucky, but you might not.

    Scott

    (Btw, I allow an exception to this rule - recovery of already-corrupt files)
    "When will the rhetorical questions end?!" - George Carlin
    Quote Quote  
  13. Member
    Join Date: Apr 2013
    Location: Italy
    Search PM
    Originally Posted by jagabo View Post
    If you really want to screw up your files like that search for binary patch utilities.
    yes, I'm looking for a partch utility but I in the string to replace I need to extract timecode from the source .mxf file and "stamp" into the .avi destination file

    It's not easy, but not impossibile
    Quote Quote  
  14. Member Cornucopia's Avatar
    Join Date: Oct 2001
    Location: Deep in the Heart of Texas
    Search Comp PM
    If it were impossible, we wouldn't need to warn you to avoid such a brute-force approach, would we?

    Scott
    "When will the rhetorical questions end?!" - George Carlin
    Quote Quote  
  15. I wrote a quick dirty program that can copy a block of data from one file to another, with the positions specified for each.

    Code:
    AviMangler  source_file  destination_file  source_pos  length  destination_pos
    I hesitate to give you a copy because you're going to be messing up your files by doing this. The program has no error checking or reporting and I've only tested it on a few small files.
    Last edited by jagabo; 6th May 2014 at 19:45.
    Quote Quote  
  16. Member Cornucopia's Avatar
    Join Date: Oct 2001
    Location: Deep in the Heart of Texas
    Search Comp PM
    "Whoa, whoa - WHOA! Nice shootin' there, Tex."

    Scott
    "When will the rhetorical questions end?!" - George Carlin
    Quote Quote  
  17. Member
    Join Date: Apr 2013
    Location: Italy
    Search PM
    thanks, in the meantime I have noticed that virtualdub can handle comment tag by the File-->Set text information windows

    I need of a "ISMP" tag and the timecode (e.g. 01:34:21:10) and my nle can read timecode. But the problem is that: I can not batch automate the process in virtualdub because it allow only the manual input of a tag trought the "set textual information" window. It don't allow (strange!) e.g.

    VirtualDub.video.AddComment(0x00000004,"ISMP","01: 34:21:10");

    because it don't allow AddComment in .vcf script

    VirtualdubMOD seems allow the addComment in .vcf script but I cannot change any of the default tags in "ISMP" ...
    Quote Quote