View Full Version : Adding encoding settings after encode?
Forteen88
23rd August 2020, 15:36
Hi, I wonder, is it OK to add some extra encoding settings after the encode is done? And how do I do that?
I thought that the source DVD wouldn't have any settings like this,
"Color primaries: BT.601 PAL
Transfer characteristics: BT.470 System B/G
Matrix coefficients: BT.470 System B/G"
The x265-encode took ~40 hours, so I prefer not to redo it :)
Thanks.
UPDATE: Oh, now I see that "Color primaries: BT.601 PAL" is not a valid input in x265's --colorprim!
benwaggoner
24th August 2020, 01:48
You want to use bt470bg; that's old school PAL.
Forteen88
24th August 2020, 08:37
You want to use bt470bg; that's old school PAL.Thanks.
foxyshadis
28th August 2020, 12:17
I'm not sure if you're still sitting on this or if you're already re-encoded, but if you still need to fix just the colors, you need to scan the stream and modify every VUI NAL to change video_format to 1, colour_primaries to 5, and transfer_characteristics to 5. x265 should include generic defaults for all of those, and they aren't CABAC, so it's just a matter of hex editing one of the first NALs of the stream. Even if not, it's still *much* faster to rewrite than re-encode.
Unfortunately, I don't know of a ready-made free tool that can do this, only commercial ones, like Jongbel.
Forteen88
28th August 2020, 13:11
foxyshadis. Thanks, but I already re-encoded it. That info is good to know though.
Forteen88
1st November 2020, 20:00
I've got another DVD-source now, a Japanese movie, in NTSC (not PAL-source as in this old thread's DVD-source),
MediaInfo says:
Color primaries: BT.601 NTSC
Transfer characteristics: BT.601
Matrix coefficients: BT.601
What should I enter in x265's "--colorprim --colormatrix --transfer --range" parameters now?
UPDATE: Oh, it seems these are the parameters I should use,
So the right args for ffmpeg are:
NTSC:
# NTSC
ffmpeg -i input \
-colorspace smpte170m -color_primaries smpte170m -color_trc smpte170m
mediainfo:
Color primaries : BT.601 NTSC
Transfer characteristics : BT.601
Matrix coefficients : BT.601
PAL:
-color_trc doesn't accept bt470bg, but ffmpeg -h full shows that gamma28 means "BT.470 BG" for that option.
# PAL
ffmpeg -i input \
-colorspace bt470bg -color_primaries bt470bg -color_trc gamma28
mediainfo:
Color primaries : BT.601 PAL
Transfer characteristics : BT.470 System B, BT.470 System G
Matrix coefficients : BT.601
https://video.stackexchange.com/questions/16840/ffmpeg-explicitly-tag-h-264-as-bt-601-rather-than-leaving-unspecified
Although some other webpage says:
Case "BT.601 NTSC"
If colour_primaries.Contains("BT.601 NTSC") Then
cl += " --colorprim bt470m"
End If
Case "BT.601 PAL"
If colour_primaries.Contains("BT.601 PAL") Then
cl += " --colorprim bt470bg"
https://github.com/staxrip/staxrip/issues/172
MGarret
2nd November 2020, 01:31
You should enter smpte170m if I remember correctly.
Forteen88
2nd November 2020, 09:01
You should enter smpte170m if I remember correctly.Thanks, I followed that 1st-link information (saying that smpte170m should be set for NTSC DVD) for my ongoing NTSC-encode, so it's great to get that confirmed.
FranceBB
4th November 2020, 08:15
I'm glad you found it.
Just in case someone needs help or looks at this thread for further references in the future while muxing / remuxing with FFMpeg, this is my "bible":
-color_primaries <int> ED.V.... color primaries (from 1 to 10) (default unspecified)
bt709 ED.V.... BT.709
unspecified ED.V.... Unspecified
bt470m ED.V.... BT.470 M
bt470bg ED.V.... BT.470 BG
smpte170m ED.V.... SMPTE 170 M
smpte240m ED.V.... SMPTE 240 M
film ED.V.... Film
bt2020 ED.V.... BT.2020
smpte428_1 ED.V.... SMPTE ST 428-1
-color_trc <int> ED.V.... color transfer characteristics (from 1 to 18) (default unspecified)
bt709 ED.V.... BT.709
unspecified ED.V.... Unspecified
gamma22 ED.V.... BT.470 M
gamma28 ED.V.... BT.470 BG
smpte170m ED.V.... SMPTE 170 M
smpte240m ED.V.... SMPTE 240 M
linear ED.V.... Linear
log ED.V.... Log
log_sqrt ED.V.... Log square root
iec61966_2_4 ED.V.... IEC 61966-2-4
bt1361 ED.V.... BT.1361
iec61966_2_1 ED.V.... IEC 61966-2-1
bt2020_10bit ED.V.... BT.2020 - 10 bit
bt2020_12bit ED.V.... BT.2020 - 12 bit
smpte2084 ED.V.... SMPTE ST 2084
smpte428_1 ED.V.... SMPTE ST 428-1
-colorspace <int> ED.V.... color space (from 0 to 10) (default unspecified)
rgb ED.V.... RGB
bt709 ED.V.... BT.709
unspecified ED.V.... Unspecified
fcc ED.V.... FCC
bt470bg ED.V.... BT.470 BG
smpte170m ED.V.... SMPTE 170 M
smpte240m ED.V.... SMPTE 240 M
ycocg ED.V.... YCOCG
bt2020_ncl ED.V.... BT.2020 NCL
bt2020_cl ED.V.... BT.2020 CL
-color_range <int> ED.V.... color range (from 0 to 2) (default unspecified)
unspecified ED.V.... Unspecified
mpeg ED.V.... MPEG (219*2^(n-8))
jpeg ED.V.... JPEG (2^n-1)
-chroma_sample_location <int> ED.V.... chroma sample location (from 0 to 6) (default unspecified)
unspecified ED.V.... Unspecified
left ED.V.... Left
center ED.V.... Center
topleft ED.V.... Top-left
top ED.V.... Top
bottomleft ED.V.... Bottom-left
bottom ED.V.... Bottom
Cheers,
Frank
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.