Open qinhaifangpku opened 3 years ago
Hi @qinhaifangpku , Thanks for your continued interest.
What I did was:
(i) Convert .mp4 file to .yuv using ffmpeg: ffmpeg -i <input_video.mp4> <output_video.yuv>
(ii) Read YUV frames from .yuv videos - like this, there's no need to convert from RGB to YUV. You can refer to Deep-SR-ITM/utils/load_yuv.m for loading YUV frames and this issue for more details on the function.
(iii) Save as .mat file.
As for your question, load_yuv.m basically repeats values in a 4:2:0 frame to create a full 3840x2160 frame. For (ii) and (iii), please refer to the below Matlab code:
file_SDR = '<path_to_SDR_file>'
file_HDR = '<path_to_HDR_file>'
format = '420';
[w_factor, h_factor] = yuv_factor(format);
height = 2160;
width = 3840;
for fr = 1:num_frames
% read data
SDR_YUV(:, :, :, fr) = imresize(uint8(load_yuv(file_SDR , fr, height, width, h_factor, w_factor, 'SDR')), 0.25); % read SDR frame and resize
HDR_YUV(:, :, :, fr) = uint16(loadYUV(file_HDR, fr, height, width, h_factor, w_factor ,'HDR')); % read HDR frame
end
save('./data/test_SDR_x4.mat', 'SDR_YUV', '-v7.3');
save('./data/test_HDR.mat', 'HDR_YUV', '-v7.3');
Hope this helps, and let me know if you have any other issues!
Soo Ye
hi, thanks for your fancy work!
I am now trying to put the testset on my own
I download the testset as you say in 4kmedia.org
For HDR video:
ffmpeg -i movie_name -color_primaries bt2020 ./4k/LG_Daylight_4K_Demo_BG/%08d.png
for the rgb2yuv_hdr() function, I refer the issue 19 and write them in python:
questions I happened is below:
**1. if I use 4:4:4 -> 4:2:0, the YUV channel will have the different shape, while I read your mat file, the Y,U,V channel are all the shape 3840x2160.
so I decide to use 4:4:4, while I try to save mat and try to read them use code below, the image looks something wrong:**
import numpy as np for i, img in enumerate(imgs): img = np.transpose(img, (2, 1, 0)) print(img.shape) BGR = yuv_tobgr(img, 10) cv2.imwrite('./hdr{}.tiff'.format(i), BGR)