我需要快速和不拆分大的視頻文件分割成多個部分的文件有錯誤。基本的想法是,我有一個2GB的視頻文件,我想改變成多種格式。我已閱讀編碼到一個不同的格式時,一些編碼器不能使用超過1個核心。所以,我有想法,這取決於有多少內核具有可單獨服務器上的大文件(這是非常快的)分成4/8片。將每個片段重新編碼爲新格式,然後使用這些格式按順序顯示視頻。FFmpeg的分裂大文件
所以
testfile.mp4
變得
- testfile_piece_1.mp4
- testfile_piece_2.mp4
- testfile_piece_3.mp4
- testfile_piece_4.mp4
這些可以被單獨轉換。
的解決方案不應該是特定的格式。但是我發現了mp4文件的問題。
我已經嘗試了下面的命令,它工作得很好,而且速度很快,但是會創建帶有錯誤的文件。
ffmpeg -i testfile.mp4 -ss 00:00:00 -t 00:20:00 -c copy testfile_piece_1.mp4
當我在VLC上播放testfile_piece_1.mp4時,它工作正常。將分割文件轉換爲不同高度和寬度的mp4文件時出現問題。我會得到「未找到的moov原子」類似的錯誤
我嘗試添加-movflags faststart
沒有運氣
我然後在這個庫https://code.google.com/archive/p/moovrelocator/其固定在MOOV問題來了,但隨後我會得到有關於錯誤aac「打開編碼器輸出流#0.0時出錯 - 可能是不正確的參數,如bit_rate,rate,width或height」
拆分文件的另一種方式是無用的,但涉及重新編碼文件。對於較小的文件大小來說不算太壞,但2GB文件可能需要幾天才能完成。
有沒有辦法快速拆分largr文件而不產生有錯誤的文件?我一直在努力工作好幾天沒有運氣。
控制檯輸出的評論 - FFmpeg splitting large files
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/usr/share/nginx/html/uploads/testfile01.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.36.100
Duration: 00:05:02.08, start: 302.120000, bitrate: 3254 kb/s
Stream #0:0(und): Video: h264 (High) (avc1/0x31637661), yuv420p(tv, bt709) , 1920x1080 [SAR 1:1 DAR 16:9], 3252 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (de fault)
Metadata:
handler_name : VideoHandler
[libx264 @ 0x165ffc0] width not divisible by 2 (853x480)
Output #0, mp4, to '/usr/share/nginx/html/uploads/testfile01_480.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.36.100
Stream #0:0(und): Video: h264, none, q=2-31, 128 kb/s, SAR 2560:2559 DAR 0:0 , 25 fps (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc56.41.100 libx264
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
控制檯輸出2
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/usr/share/nginx/html/uploads/testfile.mp4':
Metadata:
major_brand : dash
minor_version : 0
compatible_brands: iso6avc1mp41
creation_time : 2016-01-24 04:26:37
Duration: 01:15:58.08, start: 0.000000, bitrate: 3163 kb/s
Stream #0:0(und): Video: h264 (High) (avc1/0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 3161 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
Metadata:
creation_time : 2016-01-24 04:26:37
handler_name : VideoHandler
[segment @ 0x1197060] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0x11512a0] Codec for stream 0 does not use global headers but container format requires global headers
Output #0, segment, to '/usr/share/nginx/html/uploads/testfile%02d.mp4':
Metadata:
major_brand : dash
minor_version : 0
compatible_brands: iso6avc1mp41
encoder : Lavf56.36.100
Stream #0:0(und): Video: h264 (avc1/0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 3161 kb/s, 25 fps, 25 tbr, 12800 tbn, 25 tbc (default)
Metadata:
creation_time : 2016-01-24 04:26:37
handler_name : VideoHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mp4 @ 0x11512a0] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0x11512a0] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0x11512a0] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0x11512a0] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0x11512a0] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0x11512a0] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0x11512a0] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0x11512a0] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0x11512a0] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0x11512a0] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0x11512a0] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0x11512a0] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0x11512a0] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0x11512a0] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0x11512a0] Codec for stream 0 does not use global headers but container format requires global headers
感謝我給它一個鏡頭 –
'十字繡產生段ffmpeg -i testfile.mp4 -vcodec libx264 -preset slow -vf scale = -1:480 -acodec copy testfile_480.mp4'運行時我仍然得到錯誤,同時打開編碼器輸出流#0:0 - 可能是不正確的參數如bit_rate,rate,width or height' –
我剛剛注意到錯誤來自[libx264 @ 0x165ffc0]寬度不能被2整除(853x480)' –