Hi,
I have a couple files that have a wrong aspect ratio in their properties. Most of them are .mp4 and I was able to modify the container aspect ratio with MP4Box.
That specific file was encoded with 1024x576 resolution and according to MediaInfo, a 1:1 PAR (DAR was 16:9).Code:mp4box -add self#1:par=3:4 i.mp4
After running MP4Box, I now have DAR=4:3 and Original DAR=16:9.
Unfortunately, it seems Windows Movies & TV app and also MX Player don't look at the container PAR value.
In fact, I was only able to have it right in VLC.
So my question is: how can I get the PAR value changed in the stream itself without reencoding?
MediaInfo from my file:
Code:General Complete name : C:\temp\i.mp4 Format : MPEG-4 Format profile : Base Media Codec ID : isom (isom/iso2/avc1/mp41) File size : 1.43 GiB Duration : 1 h 42 min Overall bit rate : 2 007 kb/s Encoded date : UTC 2015-04-15 00:21:08 Tagged date : UTC 2015-04-15 00:21:08 Writing application : Lavf56.30.100 Copyright : ADVRIP 15/04/2015 Video ID : 1 Format : AVC Format/Info : Advanced Video Codec Format profile : Main@L4.1 Format settings : CABAC / 2 Ref Frames Format settings, CABAC : Yes Format settings, Reference frames : 2 frames Codec ID : avc1 Codec ID/Info : Advanced Video Coding Duration : 1 h 42 min Bit rate : 1 800 kb/s Width : 1 024 pixels Height : 576 pixels Display aspect ratio : 4:3 Original display aspect ratio : 16:9 Frame rate mode : Constant Frame rate : 25.000 FPS Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Bits/(Pixel*Frame) : 0.122 Stream size : 1.28 GiB (90%) Writing library : x264 core 146 r2538 Encoding settings : cabac=1 / ref=2 / deblock=1:0:0 / analyse=0x1:0x131 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=6 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=0 / b_adapt=1 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=2pass / mbtree=1 / bitrate=1800 / ratetol=1.0 / qcomp=0.60 / qpmin=10 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=24000 / vbv_bufsize=24000 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00 Encoded date : UTC 2015-04-15 00:21:08 Tagged date : UTC 2022-11-24 03:25:23 Menus : 5 mdhd_Duration : 6128800 Codec configuration box : avcC Audio #1 ID : 2 Format : AAC LC Format/Info : Advanced Audio Codec Low Complexity Codec ID : mp4a-40-2 Duration : 1 h 42 min Source duration : 1 h 42 min Bit rate mode : Constant Bit rate : 128 kb/s Channel(s) : 2 channels Channel layout : L R Sampling rate : 48.0 kHz Frame rate : 46.875 FPS (1024 SPF) Compression mode : Lossy Stream size : 93.5 MiB (6%) Source stream size : 93.5 MiB (6%) Language : French Default : Yes Alternate group : 1 Encoded date : UTC 2015-04-15 00:21:08 Tagged date : UTC 2022-11-24 03:25:23 Menus : 5 Audio #2 ID : 3 Format : AAC LC Format/Info : Advanced Audio Codec Low Complexity Codec ID : mp4a-40-2 Duration : 1 h 42 min Source duration : 1 h 42 min Bit rate mode : Constant Bit rate : 64.2 kb/s Channel(s) : 2 channels Channel layout : L R Sampling rate : 48.0 kHz Frame rate : 46.875 FPS (1024 SPF) Compression mode : Lossy Stream size : 46.9 MiB (3%) Source stream size : 46.9 MiB (3%) Language : English Default : No Alternate group : 1 Encoded date : UTC 2015-04-15 00:21:08 Tagged date : UTC 2022-11-24 03:25:23 Menus : 5 Text ID : 4 Format : VobSub Codec ID : mp4s-E0 Codec ID/Info : The same subtitle format used on DVDs Duration : 1 h 41 min Source duration : 1 h 41 min Bit rate mode : Constant Bit rate : 6 072 b/s Stream size : 4.39 MiB (0%) Source stream size : 4.39 MiB (0%) Language : French Default : Yes Forced : No Alternate group : 3 Encoded date : UTC 2015-04-15 00:21:08 Tagged date : UTC 2022-11-24 03:25:23 Menus : 5 Menu #1 ID : 5 Codec ID : text Duration : 1 h 42 min Encoded date : UTC 2015-04-15 00:21:08 Tagged date : UTC 2022-11-24 03:25:23 Bit rate mode : CBR Menu For : 1,2,3,4 00:00:00.000 : Chapitre 01 00:12:31.480 : Chapitre 02 00:25:40.040 : Chapitre 03 00:38:23.600 : Chapitre 04 00:51:12.080 : Chapitre 05 01:04:01.480 : Chapitre 06 01:17:06.360 : Chapitre 07 01:30:15.360 : Chapitre 08 Bit rate mode : Constant Menu #2 00:00:00.000 : Chapitre 01 00:12:31.480 : Chapitre 02 00:25:40.040 : Chapitre 03 00:38:23.600 : Chapitre 04 00:51:12.080 : Chapitre 05 01:04:01.480 : Chapitre 06 01:17:06.360 : Chapitre 07 01:30:15.360 : Chapitre 08
+ Reply to Thread
Results 1 to 29 of 29
-
-
AVIDemux should do it. It can be run in portable mode so you don't need to install it.
Set it up as follows, setting the DAR in the MP4 Muxer Config:
[Attachment 67791 - Click to enlarge]
Then click the Down arrow at the top to smart-render your MP4 into whatever DAR you chose. -
Thank you @Alwyn for the link. I'll give it a look. Unfortunately, from what I can tell from the interface, I don't think it would have worked for my specific problem since I needed a custom value (5:4 to bring back a PAL 4:3 ~4:5~ encoded in 16:9 to an NTSC 4:3).
After some more search, I found a tool call archange that directly modifies the AVCC atom to set the new PAR. If you look further down the thread, you will also find another version from a different user that is supposed to handle larger files. Basically, a 64 bits version.
In fact, according to this feature request, ARChange was the base for the PAR modification option of MP4Box but MP4Box only changes the container, not the stream. Odd...
Using both MP4Box and ARChange, I was able to get MediaInfo to have only a DAR value, no ODAR and most players (including DSVideo from Synology) are now showing the right aspect. Unfortunately, MX Player on FireStick still use a 1:1 PAR but I suppose it is the software that has a bug. -
With ffmpeg:
Code:ffmpeg -i input.mp4 -aspect 4:3 -map 0 -c copy -bsf:v h264_metadata=sample_aspect_ratio=3/4 output.mp4
-
Last edited by Alwyn; 24th Nov 2022 at 05:24.
-
Luke M's answer is right. The display aspect ratio will be flagged at the container level and the sampling aspect ratio will be flagged in the AVC bitstream. Slightly modified for drag/drop (or SendTo) operation in a batch file:
Code:ffmpeg -i "%~dpnx1" -aspect 4/3 -map 0 -c copy -bsf:v h264_metadata=sample_aspect_ratio=3/4 "%~dpn1_AR.mp4"
Last edited by jagabo; 24th Nov 2022 at 09:44. Reason: fixed typos in ffmpeg options
-
Jagabo, newby question: where does the converted file end up? I've put the batch file and my distorted MP4 in the folder containing ffmpeg.exe, then I drop the MP4 on the BAT file and the command window pops up briefly and then nothing.
-
The new file should be in the same folder as the source. "_AR" is appended to the base filename so as conflict with the original filename. So video_AR.mp4 will be created from video.mp4. If something is going wrong add a second line to the batch file with just "PAUSE". That will leave the CLI window open so you can see any error messages.
-
-
Oops, I tested with a file of different aspect ratios then cut/pasted into the post and edited it. I left out a space and used a : instead of /. It should have read:
Code:ffmpeg -i "%~dpnx1" -aspect 4/3 -map 0 -c copy -bsf:v h264_metadata=sample_aspect_ratio=3/4 "%~dpn1_AR.mp4"
As I understand it, the OP's input video is 16:9 DAR and he wants to change it to 4:3 DAR. Of course, if it's the other way around, your command line is correct.Last edited by jagabo; 24th Nov 2022 at 09:44.
-
I'm having no luck with this. I've got both BATs working OK, but every conversion is still not displaying properly in Films and TV my NLE and VideoRedo. In VLC Player and VDub, all conversions display correctly.
Attached are are my two source files. The game show is encoded correctly at 16:9; the dog video needs to be stretched from 4:3 to 16:9.
Game:
[Attachment 67807 - Click to enlarge]
Dog:
[Attachment 67808 - Click to enlarge]Last edited by Alwyn; 24th Nov 2022 at 20:59. Reason: Images added, black bars ref removed.
-
For the Dog, you wouldn't use the values posted above
a 16:9 1920x1080 file would need a SAR of 1:1, and a DAR of 16:9 - so you'd adjust those values accordingly
because DAR = FAR x SAR (these sometimes have different names, but the ratios mean are the same)
Display Aspect Ratio = Frame Aspect Ratio x Sample Aspect Ratio
16/9 = 1920/1080 * 1/1
-aspect 16/9 -bsf:v h264_metadata=sample_aspect_ratio=1
There are rare cases in some software where sometimes the container AR signalling is combined with the stream signalling and you get distorted results. If you had to choose (1), go with the stream values -
-
For th 1920x1080 video:
Code:ffmpeg -i "%~dpnx1" -aspect 16/9 -map 0 -c copy -bsf:v h264_metadata=sample_aspect_ratio=1/1 "%~dpn1_AR.mp4"
Code:ffmpeg -i "%~dpnx1" -aspect 4/3 -map 0 -c copy -bsf:v h264_metadata=sample_aspect_ratio=16/11 "%~dpn1_AR.mp4"
-
All sorted now, thank you all.
I made myself a 16-9 video which should be 4-3 and I found that Jagabo's first code worked on it as well as the Dog video (which was 4:3 but should have been 16:9).
A further question: there is a similar topic here:
https://forum.videohelp.com/threads/407660-Convert-DVDs-with-Incorrect-Resolution-Header/page2
where the header of a VOB (let's say an MPEG) needs to be changed in a similar fashion to this topic to make it play correctly.
I've used DVD Patcher to change the header but it then won't play in some players.
Can a similar FFMPEG command (smart-recode) be used on an MPEG 2 file and if so, what would it be?
The subject VOB is attached (I hope greenrobert doesn't mind!). It is 4:3 but should be 16:9.
Thanks! -
-
-
Where did you get the photos on the right?
When I open both files in Videoredo, they are displayed correctly, MEP_Game as 16:9, MEP_Dog as 4:3.
Both are also displayed correctly on the left side of your photos.
The dog is incorrectly displayed (well, the VRD display is correct, but the file is incorrectly coded as 4:3).
So where is the problem? -
@ Alwyn
You can try the newest beta of clever-FFmpeg-GUI.
Added: Change DAR at stream level and/or container level, for avc, hevc, mpeg2.
https://files.videohelp.com/u/292773/clever_ffmpeg_gui_newest_beta.zip
[Attachment 67900 - Click to enlarge]Last edited by ProWo; 29th Nov 2022 at 11:18.
-
@ProWo, excellent! That changes H264 and HEVC (got a warning about couldn't find scan type for the HEVC).
I tried it with a MPG/VOB, and I couldn't change the DAR:
[Attachment 67840 - Click to enlarge]
Otherwise, should be a great solution for the OP.
I note you've simplified the setting of that "bin" folder with that image; makes life much easier for us non-nerds.
The only other comment I have would be that we have to also set the DAR on the Multiplex screen. be good if that was set from the info we put in on the "Change DAR" screen. Not a major issue but just another thing to set (or miss) prior to Multiplexing.
[Attachment 67839 - Click to enlarge]
One more thing! We get an MKV and MP4 on Output, as opposed to just the selected container.
Great work though. Thanks. -
Also, can we please please pretty please have your small Any CPU folder and TXT coded as a ZIP instead of a 7Z?
-
Bitstream settings are specific to each codec.
https://ffmpeg.org/ffmpeg-bitstream-filters.html
So MPEG 2 will require a different bitstream filter (mpeg2_metadata=...). HEVC will require another (hevc_metadata=...). Etc. -
So MPEG 2 will require a different bitstream filter (mpeg2_metadata=...). HEVC will require another (hevc_metadata=...). Etc.
[Attachment 67841 - Click to enlarge] -
Should work now, in the newest beta (link below).
Done too.
Fixed.
Done.
Try it: https://files.videohelp.com/u/292773/clever_ffmpeg_gui_newest_beta.zip -
-
@ProWo, that's fantastic. It all works perfectly, I changed 16-9 and 4-3 MP4s and MPEGs to the opposite without a problem.
Thanks very much.
I'll suggest CleverFFMPEG to GreenRobert with AR issues.
Similar Threads
-
SAR , PAR , DAR - some practical questions
By robw1947 in forum Newbie / General discussionsReplies: 32Last Post: 22nd Feb 2022, 04:40 -
modify script
By filipino in forum Video Streaming DownloadingReplies: 6Last Post: 2nd Jan 2022, 18:06 -
PAR wrong 5:4 instead of 4:3. How to fix this?
By Aaron79 in forum RestorationReplies: 2Last Post: 13th Dec 2021, 04:08 -
restore PAR?
By taigi in forum Video ConversionReplies: 22Last Post: 20th May 2021, 23:30 -
Remove stream from xvid/divx file without reencoding
By akrako1 in forum EditingReplies: 3Last Post: 15th Jan 2018, 13:03