How do I split a video to 2 separate files for odd and even fields using ffmpeg?

旧街凉风 提交于 2021-01-28 02:41:46

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/49955100/how-do-i-split-a-video-to-2-separate-files-for-odd-and-even-fields-using-ffmpeg

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!