2016-06-16 64 views
1

我正在將我的機頂盒(.ASF)格式的某些文件轉換爲更易於使用plex和roku的更便捷的文件。這樣做我使用ffmpeg,但有不令人滿意的結果。儘管原始文件沒有任何明顯的交錯缺陷,但轉換後的文件卻可以。我認爲這事做與libx264轉換器,因爲以下實驗:使用libx264進行ffmpeg轉換看起來很糟糕 - 隔行

運行此命令:

的ffmpeg -i file.asf -vcodec複製-acodec副本-bsf:一個aac_adtstoasc -ss 150 -t 15 short.mp4

ffmpeg version 3.0.2 Copyright (c) 2000-2016 the FFmpeg developers 
    built with Apple LLVM version 7.3.0 (clang-703.0.29) 
    configuration: --prefix=/usr/local/Cellar/ffmpeg/3.0.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-vda 
    libavutil  55. 17.103/55. 17.103 
    libavcodec  57. 24.102/57. 24.102 
    libavformat 57. 25.100/57. 25.100 
    libavdevice 57. 0.101/57. 0.101 
    libavfilter  6. 31.100/6. 31.100 
    libavresample 3. 0. 0/3. 0. 0 
    libswscale  4. 0.100/4. 0.100 
    libswresample 2. 0.101/2. 0.101 
    libpostproc 54. 0.100/54. 0.100 
[asf @ 0x7f9f84000000] Could not find codec parameters for stream 2 (Unknown: none): unknown codec 
Consider increasing the value for the 'analyzeduration' and 'probesize' options 
Input #0, asf, from 'file.asf': 
    Metadata: 
    title   : Slingbox 
    artist   : Sling Media 
    comment   : test 
    Duration: N/A, start: 0.000000, bitrate: N/A 
    Stream #0:0: Video: h264 (High) (h264/0x34363268), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 30.30 fps, 30 tbr, 1k tbn, 59.94 tbc 
    Stream #0:1: Audio: aac (LC) ([255][0][0][0]/0x00FF), 32000 Hz, stereo, fltp, 96 kb/s 
    Stream #0:2: Unknown: none 
File 'short.mp4' already exists. Overwrite ? [y/N] y 
Output #0, mp4, to 'short.mp4': 
    Metadata: 
    title   : Slingbox 
    artist   : Sling Media 
    comment   : test 
    encoder   : Lavf57.25.100 
    Stream #0:0: Video: h264 ([33][0][0][0]/0x0021), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 30.30 fps, 30 tbr, 16k tbn, 1k tbc 
    Stream #0:1: Audio: aac (LC) ([64][0][0][0]/0x0040), 32000 Hz, stereo, 96 kb/s 
Stream mapping: 
    Stream #0:0 -> #0:0 (copy) 
    Stream #0:1 -> #0:1 (copy) 
Press [q] to stop, [?] for help 
[mp4 @ 0x7f9f8388c200] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly 
[mp4 @ 0x7f9f8388c200] pts has no value 
    Last message repeated 449 times 
frame= 450 fps=0.0 q=-1.0 Lsize= 9002kB time=00:00:15.02 bitrate=4907.9kbits/s speed=92.1x  
video:8817kB audio:173kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.125406% 

將會產生不具有隔行掃描假象,似乎是相同的確切的文件大小作爲原始(如果沒有-ss和-t命令運行)的文件。

但運行此命令(不帶任何選項)

的ffmpeg -i test.asf -ss 150 -t 15 short2.mp4

ffmpeg version 3.0.2 Copyright (c) 2000-2016 the FFmpeg developers 
    built with Apple LLVM version 7.3.0 (clang-703.0.29) 
    configuration: --prefix=/usr/local/Cellar/ffmpeg/3.0.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-vda 
    libavutil  55. 17.103/55. 17.103 
    libavcodec  57. 24.102/57. 24.102 
    libavformat 57. 25.100/57. 25.100 
    libavdevice 57. 0.101/57. 0.101 
    libavfilter  6. 31.100/6. 31.100 
    libavresample 3. 0. 0/3. 0. 0 
    libswscale  4. 0.100/4. 0.100 
    libswresample 2. 0.101/2. 0.101 
    libpostproc 54. 0.100/54. 0.100 
[asf @ 0x7fec32801400] Could not find codec parameters for stream 2 (Unknown: none): unknown codec 
Consider increasing the value for the 'analyzeduration' and 'probesize' options 
Input #0, asf, from 'test.asf': 
    Metadata: 
    title   : Slingbox 
    artist   : Sling Media 
    comment   : test 
    Duration: N/A, start: 0.000000, bitrate: N/A 
    Stream #0:0: Video: h264 (High) (h264/0x34363268), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 30.30 fps, 30 tbr, 1k tbn, 59.94 tbc 
    Stream #0:1: Audio: aac (LC) ([255][0][0][0]/0x00FF), 32000 Hz, stereo, fltp, 96 kb/s 
    Stream #0:2: Unknown: none 
[libx264 @ 0x7fec32102800] using SAR=1/1 
[libx264 @ 0x7fec32102800] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2 
[libx264 @ 0x7fec32102800] profile High, level 4.0 
[libx264 @ 0x7fec32102800] 264 - core 148 r2668 fd2c324 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00 
Output #0, mp4, to 'short2.mp4': 
    Metadata: 
    title   : Slingbox 
    artist   : Sling Media 
    comment   : test 
    encoder   : Lavf57.25.100 
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0]/0x0021), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 30 fps, 15360 tbn, 30 tbc 
    Metadata: 
     encoder   : Lavc57.24.102 libx264 
    Side data: 
     unknown side data type 10 (24 bytes) 
    Stream #0:1: Audio: aac (LC) ([64][0][0][0]/0x0040), 32000 Hz, stereo, fltp, 128 kb/s 
    Metadata: 
     encoder   : Lavc57.24.102 aac 
Stream mapping: 
    Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264)) 
    Stream #0:1 -> #0:1 (aac (native) -> aac (native)) 
Press [q] to stop, [?] for help 
frame= 450 fps= 20 q=-1.0 Lsize= 6732kB time=00:00:15.00 bitrate=3674.9kbits/s speed=0.657x  
video:6481kB audio:240kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.168370% 
[libx264 @ 0x7fec32102800] frame I:12 Avg QP:18.85 size: 39804 
[libx264 @ 0x7fec32102800] frame P:291 Avg QP:21.40 size: 17543 
[libx264 @ 0x7fec32102800] frame B:147 Avg QP:22.61 size: 7167 
[libx264 @ 0x7fec32102800] consecutive B-frames: 42.9% 36.9% 11.3% 8.9% 
[libx264 @ 0x7fec32102800] mb I I16..4: 43.2% 52.0% 4.8% 
[libx264 @ 0x7fec32102800] mb P I16..4: 11.9% 16.0% 1.0% P16..4: 30.2% 3.0% 1.7% 0.0% 0.0% skip:36.2% 
[libx264 @ 0x7fec32102800] mb B I16..4: 0.6% 0.9% 0.1% B16..8: 25.7% 1.4% 0.2% direct: 4.6% skip:66.6% L0:49.0% L1:49.4% BI: 1.6% 
[libx264 @ 0x7fec32102800] 8x8 transform intra:55.1% inter:92.0% 
[libx264 @ 0x7fec32102800] coded y,uvDC,uvAC intra: 22.5% 38.6% 6.6% inter: 6.5% 17.3% 0.5% 
[libx264 @ 0x7fec32102800] i16 v,h,dc,p: 28% 47% 8% 17% 
[libx264 @ 0x7fec32102800] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 34% 15% 42% 1% 1% 2% 1% 2% 1% 
[libx264 @ 0x7fec32102800] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 78% 6% 1% 1% 1% 1% 1% 1% 
[libx264 @ 0x7fec32102800] i8c dc,h,v,p: 59% 19% 19% 3% 
[libx264 @ 0x7fec32102800] Weighted P-Frames: Y:14.4% UV:3.8% 
[libx264 @ 0x7fec32102800] ref P L0: 65.5% 6.6% 19.0% 8.4% 0.4% 
[libx264 @ 0x7fec32102800] ref B L0: 89.6% 8.9% 1.5% 
[libx264 @ 0x7fec32102800] ref B L1: 98.6% 1.4% 
[libx264 @ 0x7fec32102800] kb/s:3539.34 
[aac @ 0x7fec32103a00] Qavg: 573.580 

可生產具有相當文件當通過Plex通過Roku播放我的高清投影機時發生一些隔行掃描缺陷(直接播放啓用,顯然沒有轉碼)。

still frame from second transcode showing visual defect

免得我過於挑剔,我搞我的妻子在這個測試中,顯示她的兩個文件和她商定,用libx264一個是顯著惡化,無法觀看。無法弄清楚如何縮小這個文件而不會造成這些交錯缺陷 - 即使我不試圖縮小它也會發生!有什麼想法嗎?

視頻文件:

https://dl.dropboxusercontent.com/u/23091/m1/short.mp4 https://dl.dropboxusercontent.com/u/23091/m1/short2.mp4

更新:另外,我嘗試了一些設置來生成MPEG4(.AVI)文件,並有相似的缺乏成功的。類似的交錯缺陷。

+0

你應該去隔行它。將'-vf yadif'添加到您的命令中。 – Mulvya

+0

我不知道爲什麼這是必要的原始不交錯在首位。你可以解釋嗎? – justin

+0

原來是交錯的。 Mediainfo report for short.mp4:'Scan type:MBAFF,Scan order:Top Field First' – Mulvya

回答

1

源視頻是交錯的,所以它需要去隔行。

在FFmpeg中使用的標準過濾器是YADIF。

所以,基本的語法是

ffmpeg -i file.asf -vf yadif -c:a copy -bsf:a aac_adtstoasc file.mp4 
相關問題