christopherw
15th April 2015, 23:50
Here's a curious thing I've come across whilst encoding some of my own files.
I've used a capture card to grab some video at 1920x1080 and store as Lagarith. I normally use VirtualDub to trim and encode using its external encoder feature, encoding Nero AAC and x264 and muxing with mp4box.
A sample x264 encode string (yes, the interlacing is deliberate):
--tff --demuxer raw --crf 15 --preset slower --tune film --psy-rd 0.0:0.0 --output-csp i422 --no-cabac --fps %(fps) --input-res %(width)x%(height) --index "%(outputdir)\%(outputname).ffindex" --output "%(tempvideofile)" -
I find that when piping the video to x264, I NEED to include the %(width)x%(height); if I don't then x264 bombs out with:
[i] VideoEnc: raw [error]: raw input requires a resolution.
[i] VideoEnc: x264 [error]: could not open input file `-'
If I DO include those virtualdub macros (or even specify --input-res 1920x1080), x264 still encodes the resulting file as 1920x1072 and seems to embed (or pass to mp4box) the original height of 1080, meaning MPC-HC shows:
"1920x1080 (AR 967:540)"
Here's a log sample from an encode...
[i] Dub: Recompressing using format: YUYV.
[i] VideoEnc: raw [info]: 1920x1080i 0:0 @ 25/1 fps (cfr)
[i] VideoEnc: resize [warning]: converting from yuv420p to yuv422p
[i] VideoEnc: x264 [warning]: interlace + weightp is not implemented
[i] VideoEnc: x264 [warning]: interlaced (1) > level limit (0)
[i] VideoEnc: x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
AVX FMA3 AVX2 LZCNT BMI2
[i] VideoEnc: x264 [info]: profile High 4:2:2, level 5.2, 4:2:2 10-bit
but later in the log:
[i] Mux: AVC-H264 import - frame size 1920 x 1072 at 25.000 FPS
If I perform some kind of processing, like deinterlace to 50p, the .h264 file's resolution is 1920x1080!!! I've tried things like altering the level of virtualdub video processing (fast recomp / normal / full) and inserting a null transform on full processing just to 'give' vdub something to do, but nothing makes a difference. If I don't do any meaningful processing, I don't get an 1920x1080 output video.
The 1920x1072 video isn't being cropped, it's squished (comparing the same frame from a 1920x1080 and 1920x1072 encode shows no missing pixels, but the aspect ratio is wrong.)
Anybody know where I'm going wrong?
Also, the SAR indicated by MPC-HC seems odd... Doing calculations it seems an input of 1920x1072 with display of 1920x1080 should have an SAR of 134/135, don't know where 967:540 comes from. I'm reticent to apply a video filter on the command line as I want to avoid quality loss.
I've used a capture card to grab some video at 1920x1080 and store as Lagarith. I normally use VirtualDub to trim and encode using its external encoder feature, encoding Nero AAC and x264 and muxing with mp4box.
A sample x264 encode string (yes, the interlacing is deliberate):
--tff --demuxer raw --crf 15 --preset slower --tune film --psy-rd 0.0:0.0 --output-csp i422 --no-cabac --fps %(fps) --input-res %(width)x%(height) --index "%(outputdir)\%(outputname).ffindex" --output "%(tempvideofile)" -
I find that when piping the video to x264, I NEED to include the %(width)x%(height); if I don't then x264 bombs out with:
[i] VideoEnc: raw [error]: raw input requires a resolution.
[i] VideoEnc: x264 [error]: could not open input file `-'
If I DO include those virtualdub macros (or even specify --input-res 1920x1080), x264 still encodes the resulting file as 1920x1072 and seems to embed (or pass to mp4box) the original height of 1080, meaning MPC-HC shows:
"1920x1080 (AR 967:540)"
Here's a log sample from an encode...
[i] Dub: Recompressing using format: YUYV.
[i] VideoEnc: raw [info]: 1920x1080i 0:0 @ 25/1 fps (cfr)
[i] VideoEnc: resize [warning]: converting from yuv420p to yuv422p
[i] VideoEnc: x264 [warning]: interlace + weightp is not implemented
[i] VideoEnc: x264 [warning]: interlaced (1) > level limit (0)
[i] VideoEnc: x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
AVX FMA3 AVX2 LZCNT BMI2
[i] VideoEnc: x264 [info]: profile High 4:2:2, level 5.2, 4:2:2 10-bit
but later in the log:
[i] Mux: AVC-H264 import - frame size 1920 x 1072 at 25.000 FPS
If I perform some kind of processing, like deinterlace to 50p, the .h264 file's resolution is 1920x1080!!! I've tried things like altering the level of virtualdub video processing (fast recomp / normal / full) and inserting a null transform on full processing just to 'give' vdub something to do, but nothing makes a difference. If I don't do any meaningful processing, I don't get an 1920x1080 output video.
The 1920x1072 video isn't being cropped, it's squished (comparing the same frame from a 1920x1080 and 1920x1072 encode shows no missing pixels, but the aspect ratio is wrong.)
Anybody know where I'm going wrong?
Also, the SAR indicated by MPC-HC seems odd... Doing calculations it seems an input of 1920x1072 with display of 1920x1080 should have an SAR of 134/135, don't know where 967:540 comes from. I'm reticent to apply a video filter on the command line as I want to avoid quality loss.