Reputation: 41
I have a h.264 progressive 640x480 video. I'm trying to create 2 separate video files, each is 640x240 and consisting only the odd fields and even fields seperately. Firstly I converted the file to interlaced but now I need to convert to 2 files. How do I do that based on yuv format?
Once I'm done, I will encode the files separately and then rejoin them to a single interlaced file.
How do I do that?
Upvotes: 2
Views: 1924
Reputation: 93299
Starting with the full progressive video, you can do it in one step.
ffmpeg -i in.mp4 -filter_complex "[0]il=l=d:c=d,split[o][e];[o]crop=iw:ih/2:0:0[odd];[e]crop=iw:ih/2:0:ih/2[even]" -map "[odd]" -f rawvideo odd.yuv -map "[even]" -f rawvideo even.yuv
The il filter takes the odd lines and moves them to top-half of the result, and the even lines to the bottom. From there on, the result is split to two, and one copy cropped to the top half; the other to the bottom half. Each is output to a separate YUV file.
To reverse the effect, you would input the two YUV files and use the filter in the opposite mode
ffmpeg -i odd.yuv -i even.yuv -filter_complex "[0][1]vstack,il=l=i:c=i" rejoined.mp4
(You'll have to manually set input stream properties for each YUV file e.g. -video_size 640x240 -pixel_format yuv420p -framerate 25 -i odd.yuv
)
At no time will any stream be detected or formally marked as interlaced. These are just operations being performed on alternate lines of a progressive stream.
Upvotes: 2