Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264
Register FAQ Calendar Today's Posts Search

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 30th November 2019, 08:35   #1  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,277
Changing PAR in H.264 bitstream using FFmpeg

Using a file named 'h264_par_1.mp4' with the following characteristics:

h264_par_1 had:
Sampled_Width : 640
Sampled_Height : 352
Pixel aspect ratio : 1.000 <-
Display aspect ratio : 1.818
Display aspect ratio : 16:9

one can use:
Code:
ffmpeg -y -i "E:\Output\h264_par_1.mp4" -map 0:0 -vcodec copy -an -sn  -bsf:v h264_metadata=sample_aspect_ratio=2 "E:\Output\h264_par_2.mp4"
(seems to work fine with any x264 encode)
to change the PAR from 1 to 2.

h264_par_2 has:
Sampled_Width : 640
Sampled_Height : 352
Pixel aspect ratio : 2.000 <-
Display aspect ratio : 3.636
Display aspect ratio : 3.636

Problem is if the input stream has no PAR data like 'Attica The Movie - Trailer By Brass':
(which I uploaded to my GoogleDrive

Width : 1280
Width : 1 280 pixels
Height : 720
Height : 720 pixels
Pixel aspect ratio : 1.000
Display aspect ratio : 1.778
Display aspect ratio : 16:9
note: MediaInfo shows no Sampled Width/Height

Code:
ffmpeg -y -i "F:\TestClips&Co\files\MPEG-4 H.264\Attica The Movie - Trailer By Brass.mp4" -map 0:0 -vcodec copy -an -sn -bsf:v h264_metadata=sample_aspect_ratio=2 "E:\Output\test.mp4"
fails with
Code:
[AVBSFContext @ 000001bcad3b5b00] rbsp_alignment_zero_bit out of range: 1, but must be in [0,0].
[AVBSFContext @ 000001bcad3b5b00] Failed to read unit 0 (type 7).
[AVBSFContext @ 000001bcad3b5b00] Failed to read extradata.
Error initializing bitstream filter: h264_metadata
My current guess is that the original stream has no explicit PAR (/ Sampled Width/Height) info which is why ffmpegs bitstream filter can't modify those values and change the PAR.

-> Does anyone know a way to change the PAR of such a stream without reencoding (preferably with ffmpeg)?

Cu Selur
__________________
Hybrid here in the forum, homepage

Last edited by Selur; 30th November 2019 at 08:37.
Selur is offline   Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:06.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.