VideoHelp Forum

+ Reply to Thread
Results 1 to 29 of 29
Thread
  1. 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.

    Code:
    mp4box -add self#1:par=3:4 i.mp4
    That specific file was encoded with 1024x576 resolution and according to MediaInfo, a 1:1 PAR (DAR was 16:9).
    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
    Quote Quote  
  2. Member
    Join Date
    May 2005
    Location
    Australia
    Search Comp PM
    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:

    Image
    [Attachment 67791 - Click to enlarge]


    Then click the Down arrow at the top to smart-render your MP4 into whatever DAR you chose.
    Quote Quote  
  3. 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.
    Quote Quote  
  4. 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
    Quote Quote  
  5. Member
    Join Date
    May 2005
    Location
    Australia
    Search Comp PM
    Did some trials with AVIDemux: VLC Player correctly played a 1024x576 4:3 file I converted to 16:9, but Windows Film and TV and my NLE still displayed it as 4:3. The Mediainfo DAR is 16:9, the ODAR is 4:3. Bummer.

    Where's ProWo when we need them?
    Last edited by Alwyn; 24th Nov 2022 at 06:24.
    Quote Quote  
  6. Cut 30 sec from your video with avidemux and post it here.
    Quote Quote  
  7. ...delete
    Last edited by ProWo; 24th Nov 2022 at 07:41.
    Quote Quote  
  8. 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 10:44. Reason: fixed typos in ffmpeg options
    Quote Quote  
  9. Member
    Join Date
    May 2005
    Location
    Australia
    Search Comp PM
    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.
    Quote Quote  
  10. 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.
    Quote Quote  
  11. Originally Posted by jagabo View Post
    Slightly modified for drag/drop (or SendTo) operation in a batch file:
    Code:
    ffmpeg -i "%~dpnx1" -aspect4:3 -map 0 -c copy -bsf:v h264_metadata=sample_aspect_ratio=3/4 "%~dpn1_AR.mp4"
    It should be
    ffmpeg -i "%~dpnx1" -aspect 16/9 -map 0 -c copy -bsf:v h264_metadata=sample_aspect_ratio=16/9 "%~dpn1_AR.mp4"
    Quote Quote  
  12. Originally Posted by ProWo View Post
    Originally Posted by jagabo View Post
    Slightly modified for drag/drop (or SendTo) operation in a batch file:
    Code:
    ffmpeg -i "%~dpnx1" -aspect4:3 -map 0 -c copy -bsf:v h264_metadata=sample_aspect_ratio=3/4 "%~dpn1_AR.mp4"
    It should be
    ffmpeg -i "%~dpnx1" -aspect 16/9 -map 0 -c copy -bsf:v h264_metadata=sample_aspect_ratio=16/9 "%~dpn1_AR.mp4"
    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"
    I'll edit the original post to fix the error too.

    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 10:44.
    Quote Quote  
  13. Member
    Join Date
    May 2005
    Location
    Australia
    Search Comp PM
    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:
    Image
    [Attachment 67807 - Click to enlarge]


    Dog:
    Image
    [Attachment 67808 - Click to enlarge]
    Image Attached Files
    Last edited by Alwyn; 24th Nov 2022 at 21:59. Reason: Images added, black bars ref removed.
    Quote Quote  
  14. 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
    Quote Quote  
  15. Originally Posted by Alwyn View Post
    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.
    Code:
    ffmpeg -i input.mp4 -aspect 16:9 -map 0 -c copy -bsf:v h264_metadata=sample_aspect_ratio=1 output.mp4
    Quote Quote  
  16. 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"
    For the 720x576 video:

    Code:
    ffmpeg -i "%~dpnx1" -aspect 4/3 -map 0 -c copy -bsf:v h264_metadata=sample_aspect_ratio=16/11 "%~dpn1_AR.mp4"
    Image Attached Files
    Quote Quote  
  17. Member
    Join Date
    May 2005
    Location
    Australia
    Search Comp PM
    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!
    Image Attached Files
    Quote Quote  
  18. Originally Posted by Alwyn View Post
    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.
    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.
    So where is the problem?
    Quote Quote  
  19. Originally Posted by Alwyn View Post
    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!
    ffmpeg -i VTS_01_1-00.07.43.863-00.07.54.874.VOB -map 0 -c copy -bsf:v mpeg2_metadata=display_aspect_ratio=16/9 VTS_01_1-00.07.43.863-00.07.54.874_16_9.VOB
    Image Attached Files
    Quote Quote  
  20. Member
    Join Date
    May 2005
    Location
    Australia
    Search Comp PM
    Where did you get the photos on the right?
    After running my files thru the earlier scripts; note the _AR suffixs.

    When I open both files in Videoredo, they are displayed correctly, MEP_Game as 16:9, MEP_Dog as 4:3.
    Yes, I agree, but the dog is 4:3 (as shown) when I want to change it to 16:9.

    Both are also displayed correctly on the left side of your photos.
    The game is correctly displayed as 16:9 (which I shouldn't have used, because the issue was converting a incorrectly coded 4:3 file to 16:9; I should have used a 4:3 file incorrectly coded as 16:9).

    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?
    The dog needs to be changed from 4:3 to 16:9. The latest script does that.
    Quote Quote  
  21. Member
    Join Date
    May 2005
    Location
    Australia
    Search Comp PM
    Originally Posted by ProWo
    ffmpeg -i VTS_01_1-00.07.43.863-00.07.54.874.VOB -map 0 -c copy -bsf:v mpeg2_metadata=display_aspect_ratio=16/9 VTS_01_1-00.07.43.863-00.07.54.874_16_9.VOB
    Thanks ProWo, I mashed together your script and Jagabo's and now have a drop-on BAT for VOBs (I do note that VideoRedo will overwrite the metadata of MPEGs to force the correct ratio; it won't do it for H264).
    Quote Quote  
  22. @ 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

    Image
    [Attachment 67900 - Click to enlarge]
    Last edited by ProWo; 29th Nov 2022 at 12:18.
    Quote Quote  
  23. Member
    Join Date
    May 2005
    Location
    Australia
    Search Comp PM
    @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:

    Image
    [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.

    Image
    [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.
    Quote Quote  
  24. Member
    Join Date
    May 2005
    Location
    Australia
    Search Comp PM
    Also, can we please please pretty please have your small Any CPU folder and TXT coded as a ZIP instead of a 7Z?
    Quote Quote  
  25. 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.
    Quote Quote  
  26. Member
    Join Date
    May 2005
    Location
    Australia
    Search Comp PM
    So MPEG 2 will require a different bitstream filter (mpeg2_metadata=...). HEVC will require another (hevc_metadata=...). Etc.
    Understood, for MPG/VOB, Clever FFMPEG is missing the input boxes for the Container and Stream DARs:

    Image
    [Attachment 67841 - Click to enlarge]
    Quote Quote  
  27. Originally Posted by Alwyn View Post
    I tried it with a MPG/VOB, and I couldn't change the DAR
    Should work now, in the newest beta (link below).

    Originally Posted by Alwyn View Post
    The only other comment I have would be that we have to also set the DAR on the Multiplex screen.
    Done too.

    Originally Posted by Alwyn View Post
    One more thing! We get an MKV and MP4 on Output, as opposed to just the selected container.
    Fixed.

    Originally Posted by Alwyn View Post
    Also, can we please please pretty please have your small Any CPU folder and TXT coded as a ZIP instead of a 7Z?
    Done.

    Try it: https://files.videohelp.com/u/292773/clever_ffmpeg_gui_newest_beta.zip
    Quote Quote  
  28. Originally Posted by jagabo View Post
    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.
    This will be taken into account in the newest beta (Link above).
    Quote Quote  
  29. Member
    Join Date
    May 2005
    Location
    Australia
    Search Comp PM
    @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.
    Quote Quote  



Similar Threads