Selur
30th November 2019, 08:35
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:
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 (https://drive.google.com/open?id=19wKFoFAW3xEUaOuoC0dDSPN3ISEQswv_)
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
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
[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
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:
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 (https://drive.google.com/open?id=19wKFoFAW3xEUaOuoC0dDSPN3ISEQswv_)
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
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
[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