2011-04-07 49 views
4

我有一個1920x1080 mpeg2 .ts文件。我需要爲每個幀獲取原始YUV文件。 我試過ffmpeg,但沒有運氣。我結束了許多小文件。我期望每幀都是1920x1080x1.5 = 3110400字節。如何從MPEG2 TS文件中提取原始YUV文件?

[[email protected] frames]# ffmpeg -i video.ts -f image2 foo-%03d.yuv 
FFmpeg version git-N-28713-g65daa94, Copyright (c) 2000-2011 the FFmpeg developers 
    built on Mar 30 2011 09:20:16 with gcc 4.6.0 
    configuration: --prefix=/usr --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libfaac --enable-libxvid --enable-libx264 --enable-libvpx --enable-libtheora --enable-postproc --enable-shared --enable-x11grab --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libschroedinger --enable-libopenjpeg --enable-version3 --enable-nonfree --enable-runtime-cpudetect --disable-debug 
    libavutil 50. 40. 0/50. 40. 0 
    libavcodec 52.116. 0/52.116. 0 
    libavformat 52.104. 0/52.104. 0 
    libavdevice 52. 4. 0/52. 4. 0 
    libavfilter 1. 76. 0/1. 76. 0 
    libswscale 0. 13. 0/0. 13. 0 
    libpostproc 51. 2. 0/51. 2. 0 
Input #0, mpegts, from 'video.ts': 
    Duration: 00:04:51.58, start: 0.333333, bitrate: 36041 kb/s 
    Program 10 
    Stream #0.0[0x20]: Video: mpeg2video (Main), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 35000 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc 
    Stream #0.1[0x21]: Audio: ac3, 48000 Hz, 5.1, s16, 224 kb/s 
Incompatible pixel format 'yuv420p' for codec 'mjpeg', auto-selecting format 'yuvj420p' 
[buffer @ 0x97148c0] w:1920 h:1080 pixfmt:yuv420p 
[setdar @ 0x9714df0] a:16/9 
[setdar @ 0x9714df0] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'Parsed filter 0 setdar' 
[scale @ 0x9711db0] w:1920 h:1080 fmt:yuv420p -> w:1920 h:1080 fmt:yuvj420p flags:0x4 
[setdar @ 0x9714df0] w:1920 h:1080 -> dar:16/9 sar:1/1 
Output #0, image2, to 'foo-%03d.yuv': 
    Metadata: 
    encoder   : Lavf52.104.0 
    Stream #0.0: Video: mjpeg, yuvj420p, 1920x1080 [PAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 23.98 tbc 
Stream mapping: 
    Stream #0.0 -> #0.0 
+1

我有一種解決方法了。 '對於編解碼器'mjpeg',自動選擇格式'yuvj420p' [buffer @ 0x97148c0] w:1920 h:1080 pixfmt:yuv420p'不兼容像素格式'yuv420p'是問題。使用「識別」程序,我將這些輸出圖像作爲jpeg文件。解決方案是消除參數-f image2並僅使用一個輸出文件out.yuv。然後用dd將輸出剪切成不同的小文件,大小分別爲1920 * 1080 * 1.5。 – 2011-04-08 07:37:25

回答

1

當您使用圖像作爲格式(-f image2)時,它將採用mjpeg格式,即圖像壓縮格式。所以,是的,你的解決方案是正確的,你需要刪除-f image2。

6

您也可以使用該選項-vframes得到如下單YUV框架:

ffmpeg -i video.ts -pix_fmt yuv420p -vframes 1 foo-1.yuv 
相關問題