Hi
IF the cats. Anyway
please I wonder if does exist a way to change, via commandline in windows, the height value tag of an .avi file like this temp.avi
https://www.swisstransfer.com/d/c6be6f53-50c7-4f8f-87dc-365d232a4f47
so that the height internal tag change from the originally 1088 to 1080
hex change from 4008 into 3808 in 3 points
from
[Attachment 73097 - Click to enlarge]
to
[Attachment 73096 - Click to enlarge]
thanks
+ Reply to Thread
Results 1 to 12 of 12
-
-
I did what you wanted three changes, no problem to post python script to use in batch or even make an exe to run it with arguments,
but I did those changes in avi header on pos 44, then it seams to be following video stream header bytes 54 (2bytes) and 72 (4bytes) changes, but mediainfo still reports original height 1088. Is that file suppose to be fixed? -
but yes the temp_1080.avi is recognized as 1080 correctly, my mediainfo tell 1088 il the original height but this is not a problem: the height value is 1080
another .avi example:
https://www.swisstransfer.com/d/3d48c3e1-968c-4e1e-96b5-b0333ab94dcd
https://www.swisstransfer.com/d/06d514ec-5fbd-4aa0-b4fc-b750995f8c7b
also this other .avi mjpeg files are intimately 1920x1080 but written in stream copy modee by ffmpeg which however marks them as 1088Last edited by marcorocchini; 10th Aug 2023 at 13:13.
-
-
based on this, this python script was made, you can use this python file in your batch script if you have python installed, usage as python is in there:
Code:import os import sys def load_value(avi_path, offset, length): with open(avi_path,'rb') as f: f.seek(offset,0) return int.from_bytes(f.read(length), byteorder='little') def get_offset(avi_path, string): with open(avi_path,'rb') as f: offset = 0 f.seek(0) while (buff := f.read(16)): if string in buff: return offset + buff.index(string) else: offset += 16 else: print(f' avi header with fcc type: "{string.decode()}" not found, avi header not found in {avi_path}') return None def overwrite_bytes(avi_path, offset, new_integer, length): with open(avi_path,'r+b') as f: f.seek(offset,0) bytes_val = new_integer.to_bytes(length, 'little') f.write(bytes_val) def main(avi_path, new_dwHeight): new_dwHeight = int(new_dwHeight) avih_offset = get_offset(avi_path, b'avih') if avih_offset is not None: dwHeight = load_value(avi_path, avih_offset + 44, 4) overwrite_bytes(avi_path, avih_offset + 44, new_dwHeight, 4) print(f' avih pos 44: {dwHeight} to {new_dwHeight} {avi_path}') vids_offset = get_offset(avi_path, b'vids') if vids_offset is not None: dwHeight = load_value(avi_path, vids_offset + 54, 2) overwrite_bytes(avi_path, vids_offset + 54, new_dwHeight, 2) print(f' vids pos 54: {dwHeight} to {new_dwHeight} {avi_path}') dwHeight = load_value(avi_path, vids_offset + 72, 4) overwrite_bytes(avi_path, vids_offset + 72, new_dwHeight, 4) print(f' vids pos 72: {dwHeight} to {new_dwHeight} {avi_path}') if __name__ == '__main__': ''' usage, this should change mjpg avi to height 1080 if using python in cmd prompt: python change_avi_height.py filename.avi 1080 ''' args = [] for arg in sys.argv[1:]: args.append(arg) if len(args) < 2: raise ValueError('Two arguments needed. First argument is avi filename, second is new height') for i, arg in enumerate(args[:2]): if i==0: if not os.path.isfile(arg) or not arg.lower().endswith('.avi'): raise ValueError(f'First argument must be existing avi filepath. Got: {arg}') else: try: int(arg) except (TypeError, ValueError): raise ValueError(f'Second height argument must be an integer. Got: {arg}') print(f'Changing avi header heights for files to: {args[1]}') main(*args)
If having python, you can make exe file yourself, install pyinstaller in cmd prompt:Code:pip install PyInstaller
Code:"C:\Users\*** user name ***\AppData\Roaming\Python\Python38\Scripts\pyinstaller.exe" "*** your path to python file ***\change_avi_height.py" --name "change height in mjpg avi" -–onefile
Code:"change height in mjpg avi.exe" "filenami.avi" 1080
-
[Attachment 73103 - Click to enlarge]
oh wow it works
absoluty useful (but I don't understand how you did it, but everything is fine)
it changes very well
[Attachment 73104 - Click to enlarge]
oh my ***
thanks -
-
my old version of mediainfo 0.7.90 over the modify temp.avi report:
Code:Generale Complete name : C:\temp.avi Format : AVI Format/Info : Audio Video Interleave Format profile : OpenDML File size : 2,65 GiB Duration : 1 min 34s Overall bit rate : 242 Mb/s Writing application : Lavf59.16.100 Video ID : 0 Format : JPEG Codec ID : MJPG Duration : 1 min 34s Bit rate : 242 Mb/s Width : 1.920 pixel Height : 1.080 pixel Original height : 1.088 pixel Display aspect ratio : 16:9 Frame rate : 25,000 FPS Color space : YUV Chroma subsampling : 4:2:2 Bit depth : 8 bit Scan type : Interlacciato Scan order : Top field first Compression mode : Con perdita Bits/(Pixel*Frame) : 4.677 Stream size : 2,65 GiB (100%)
I think ffmpeg have at least a "problem": when concatenate multiple .avi mpeg files that are 1920x1080 --> generate a final output strangely 1920X1088
however your programs works fine -
I was referring to his source images in another thread where he was concatenating two MJPEG AVI files into one. That's the cause of the 1088 line problem in the videos here.
https://forum.videohelp.com/threads/410710-how-to-merge-multiple-avi-mjpeg-files#post2700803
Similar Threads
-
Change channel configuration inside MP4-container
By FLX90 in forum AudioReplies: 1Last Post: 8th Jun 2023, 07:48 -
how to find hex or brackpoint with hex editor o w32DMSN?
By marcorocchini in forum ProgrammingReplies: 0Last Post: 31st Dec 2021, 21:37 -
Trying to find HEX key
By Djste18 in forum Video Streaming DownloadingReplies: 3Last Post: 14th Jan 2020, 17:16 -
can I manage preferred DirectShow filter via commandline?
By marcorocchini in forum Newbie / General discussionsReplies: 1Last Post: 29th Jul 2019, 15:51 -
seeking commandline front-end for using NVEnc
By hydra3333 in forum Video ConversionReplies: 28Last Post: 6th Mar 2019, 14:13