MKV转码为TS

来源:互联网 发布:彼得堡遗书 知乎 编辑:程序博客网 时间:2024/04/29 22:22

参考 http://www.shortword.net/blog/2009/12/18/converting-h-264-mpeg4-to-ts-with-ffmpeg/

root@Ubuntu32:/home/zhangbin/streaming/http/segmenter# ffmpeg -i /home/zhangbin/Downloads/testVideos/U.F.O.1080p.BluRay.x264-SONiDO-sample.mkv -vcodec copy -acodec copy -vbsf h264_mp4toannexb ufo1080p.ts

ffmpeg version 1.2 Copyright (c) 2000-2013 the FFmpeg developers
  built on Apr 16 2013 19:40:09 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --prefix=/home/zhangbin/ffmpeg/ffmpegx86/ffmpegHome --enable-gpl --enable-version3 --enable-nonfree --enable-shared --enable-runtime-cpudetect --enable-gray --enable-avresample --enable-x11grab --enable-bzlib --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libspeex --enable-libtheora --enable-libv4l2 --enable-libvo-aacenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-zlib --enable-pic --enable-libfaac --enable-libass --enable-libfaac --enable-librtmp --enable-openssl
  libavutil      52. 18.100 / 52. 18.100
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.104 / 54. 63.104
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 42.103 /  3. 42.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, matroska,webm, from '/home/zhangbin/Downloads/testVideos/U.F.O.1080p.BluRay.x264-SONiDO-sample.mkv':
  Metadata:
    creation_time   : 2013-01-23 22:31:21
  Duration: 00:00:43.13, start: 0.000000,
bitrate: 12119 kb/s
    Stream #0:0(eng): Video: h264 (High), yuv420p, 1920x1080, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr,1k tbn, 47.95 tbc (default)
    Stream #0:1(eng): Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s (default)
Output #0, mpegts, to 'ufo1080p.ts':
  Metadata:
    encoder         : Lavf54.63.104   主要是mux的过程么?所以是avformat出马?
    Stream #0:0(eng): Video: h264, yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 23.98 fps,90k tbn, 23.98 tbc (default)  与原始的不同
    Stream #0:1(eng): Audio: dts, 48000 Hz, 5.1(side), 1536 kb/s (default)
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)

Press [q] to stop, [?] for help  还可以停止?
frame=  123 fps=0.0 q=-1.0 size=    7586kB time=00:00:05.11 bitrate=12152.6kbitsframe=  250 fps=247 q=-1.0 size=   17119kB time=00:00:10.39 bitrate=13492.3kbitsframe=  413 fps=273 q=-1.0 size=   27437kB time=00:00:17.23 bitrate=13044.2kbitsframe=  529 fps=263 q=-1.0 size=   35023kB time=00:00:22.10 bitrate=12979.3kbitsframe=  580 fps=229 q=-1.0 size=   38512kB time=00:00:24.19 bitrate=13039.0kbitsframe=  591 fps=185 q=-1.0 size=   39188kB time=00:00:24.63 bitrate=13031.8kbitsframe=  602 fps=139 q=-1.0 size=   39971kB time=00:00:25.11 bitrate=13038.7kbitsframe=  712 fps=147 q=-1.0 size=   46489kB time=00:00:29.74 bitrate=12804.3kbitsframe=  818 fps=153 q=-1.0 size=   53013kB time=00:00:34.10 bitrate=12733.7kbitsframe=  933 fps=160 q=-1.0 size=   62325kB time=00:00:38.95 bitrate=13105.3kbitsframe= 1034 fps=168 q=-1.0 Lsize=   69726kB time=00:00:43.11 bitrate=13247.2kbits/s    
video:55845kB audio:7944kB subtitle:0 global headers:0kB muxing overhead 9.306255%

root@Ubuntu32:/home/zhangbin/streaming/http/segmenter# 



root@Ubuntu32:/home/zhangbin/streaming/http/segmenter# ls
Makefile.txt  segmenter  segmenter.c  setFFmpegEnv.sh  setFFmpegEnv.sh~  U.F.O.1080p.BluRay.x264-SONiDO-sample.mkv  ufo1080p.ts
root@Ubuntu32:/home/zhangbin/streaming/http/segmenter# ffplay ufo1080p.ts 
ffplay version 1.2 Copyright (c) 2003-2013 the FFmpeg developers
  built on Apr 16 2013 19:40:09 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --prefix=/home/zhangbin/ffmpeg/ffmpegx86/ffmpegHome --enable-gpl --enable-version3 --enable-nonfree --enable-shared --enable-runtime-cpudetect --enable-gray --enable-avresample --enable-x11grab --enable-bzlib --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libspeex --enable-libtheora --enable-libv4l2 --enable-libvo-aacenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-zlib --enable-pic --enable-libfaac --enable-libass --enable-libfaac --enable-librtmp --enable-openssl
  libavutil      52. 18.100 / 52. 18.100
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.104 / 54. 63.104
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 42.103 /  3. 42.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, mpegts, from 'ufo1080p.ts':B vq=    0KB sq=    0B f=0/0   
  Duration: 00:00:43.12, start: 1.400000, bitrate: 13247 kb/s
  Program 1 
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg

    Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 1920x1080, 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc
    Stream #0:1[0x101](eng): Audio: dts (DTS) ([6][0][0][0] / 0x0006), 48000 Hz, 5.1(side), fltp, 1536 kb/s

  66.04 A-V: 18.636 fd= 162 aq=    0KB vq=    0KB sq=    0B f=0/0   
root@Ubuntu32:/home/zhangbin/streaming/http/segmenter# 











root@Ubuntu32:/home/zhangbin/streaming/http/segmenter# 
root@Ubuntu32:/home/zhangbin/streaming/http/segmenter# ffmpeg -i /home/zhangbin/Downloads/testVideos/Vikings.S01E02.WEBRip.x264-UNPOPULAR.mp4 -vcodec copy -acodec copy -vbsf h264_mp4toannexb Vikings.S01E02.ts
ffmpeg version 1.2 Copyright (c) 2000-2013 the FFmpeg developers
  built on Apr 16 2013 19:40:09 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --prefix=/home/zhangbin/ffmpeg/ffmpegx86/ffmpegHome --enable-gpl --enable-version3 --enable-nonfree --enable-shared --enable-runtime-cpudetect --enable-gray --enable-avresample --enable-x11grab --enable-bzlib --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libspeex --enable-libtheora --enable-libv4l2 --enable-libvo-aacenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-zlib --enable-pic --enable-libfaac --enable-libass --enable-libfaac --enable-librtmp --enable-openssl
  libavutil      52. 18.100 / 52. 18.100
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.104 / 54. 63.104
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 42.103 /  3. 42.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/zhangbin/Downloads/testVideos/Vikings.S01E02.WEBRip.x264-UNPOPULAR.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isomavc1
    creation_time   : 2013-03-04 16:20:45
    encoder         : HandBrake 0.9.8 2012071700
  Duration: 00:44:20.54, start: 0.000000, bitrate: 670 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 512x288, 505 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc
    Metadata:
      creation_time   : 2013-03-04 16:20:45
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 159 kb/s    音频是aac?
    Metadata:
      creation_time   : 2013-03-04 16:20:45


输出
Output #0, mpegts, to 'Vikings.S01E02.ts':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isomavc1
    encoder         : Lavf54.63.104
    Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 512x288, q=2-31, 505 kb/s, 23.98 fps, 90k tbn, 23.98 tbc
    Metadata:
      creation_time   : 2013-03-04 16:20:45
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, 159 kb/s
    Metadata:
      creation_time   : 2013-03-04 16:20:45
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[adts @ 0x959aee0] Encoder did not produce proper pts, making some up.
frame=63788 fps=2826 q=-1.0 Lsize=  244321kB time=00:44:20.54 bitrate= 752.3kbits/s    
video:164269kB audio:51904kB subtitle:0 global headers:0kB muxing overhead 13.021019%
root@Ubuntu32:/home/zhangbin/streaming/http/segmenter# 




root@Ubuntu32:/home/zhangbin/streaming/http/segmenter# 
root@Ubuntu32:/home/zhangbin/streaming/http/segmenter# 
root@Ubuntu32:/home/zhangbin/streaming/http/segmenter# ffplay Vikings.S01E02.ts 
ffplay version 1.2 Copyright (c) 2003-2013 the FFmpeg developers
  built on Apr 16 2013 19:40:09 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --prefix=/home/zhangbin/ffmpeg/ffmpegx86/ffmpegHome --enable-gpl --enable-version3 --enable-nonfree --enable-shared --enable-runtime-cpudetect --enable-gray --enable-avresample --enable-x11grab --enable-bzlib --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libspeex --enable-libtheora --enable-libv4l2 --enable-libvo-aacenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-zlib --enable-pic --enable-libfaac --enable-libass --enable-libfaac --enable-librtmp --enable-openssl
  libavutil      52. 18.100 / 52. 18.100
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.104 / 54. 63.104
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 42.103 /  3. 42.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[mpegts @ 0xafc02560] max_analyze_duration 5000000 reached at 5004000 microseconds
Input #0, mpegts, from 'Vikings.S01E02.ts':   0KB sq=    0B f=0/0   
  Duration: 00:44:20.48, start: 1.400000, bitrate: 752 kb/s
  Program 1 
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 512x288, 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc
    Stream #0:1[0x101](und): Audio: aac ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 131 kb/s
 230.26 A-V: -0.015 fd=  88 aq=    3KB vq=    8KB sq=    0B f=0/0   
root@Ubuntu32:/home/zhangbin/streaming/http/segmenter# 
root@Ubuntu32:/home/zhangbin/streaming/http/segmenter# 
root@Ubuntu32:/home/zhangbin/streaming/http/segmenter# 
root@Ubuntu32:/home/zhangbin/streaming/http/segmenter# 
root@Ubuntu32:/home/zhangbin/streaming/http/segmenter# 



USAGE: ./segmenter -i input-MPEG-TS-file -d seconds-per-segment [-o segment-file-prefix] -x output-playlist-m3u8 [-p http-prefix] [-w max-live-segments] [-P pid-file] [--watch-for-kill-file] [--strict-segment-duration] [--avformat-option opt value] [--loglevel level] 


Compiled by Daniel Espendiller - www.espend.de
build on Apr 17 2013 06:52:18 with 4.6.3


Took some code from:
 - source:http://svn.assembla.com/svn/legend/segmenter/
 - iStreamdev:http://projects.vdr-developer.org/git/?p=istreamdev.git;a=tree;f=segmenter;hb=HEAD
 - live_segmenter:http://github.com/carsonmcdonald/HTTP-Live-Video-Stream-Segmenter-and-Distributor
root@Ubuntu32:/home/zhangbin/streaming/http/segmenter#  ./segmenter -i Vikings.S01E02.ts -d 600 [-o zhangbin] -x output-playlist-m3u8 [-p ahttpb] [-w 20 ] [--loglevel debug ]
[mpegts @ 0x9dd54e0] max_analyze_duration 5000000 reached at 5004000 microseconds
Output #0, mpegts, to '':
    Stream #0:0: Video: h264 ([27][0][0][0] / 0x001B), yuv420p, 512x288, q=2-31, 90k tbn, 23.98 tbc
    Stream #0:1: Audio: aac ([15][0][0][0] / 0x000F), 48000 Hz, stereo, 131 kb/s
root@Ubuntu32:/home/zhangbin/streaming/http/segmenter# 





root@Ubuntu32:/home/zhangbin/streaming/http/segmenter# ls
-1.ts  -3.ts  -5.ts         output-playlist-m3u8  segmenter.c      setFFmpegEnv.sh~  Vikings.S01E02.ts
-2.ts  -4.ts  Makefile.txt  segmenter             setFFmpegEnv.sh  ufo1080p.ts
root@Ubuntu32:/home/zhangbin/streaming/http/segmenter# ffplay -5.ts
ffplay version 1.2 Copyright (c) 2003-2013 the FFmpeg developers
  built on Apr 16 2013 19:40:09 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --prefix=/home/zhangbin/ffmpeg/ffmpegx86/ffmpegHome --enable-gpl --enable-version3 --enable-nonfree --enable-shared --enable-runtime-cpudetect --enable-gray --enable-avresample --enable-x11grab --enable-bzlib --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libspeex --enable-libtheora --enable-libv4l2 --enable-libvo-aacenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-zlib --enable-pic --enable-libfaac --enable-libass --enable-libfaac --enable-librtmp --enable-openssl
  libavutil      52. 18.100 / 52. 18.100
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.104 / 54. 63.104
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 42.103 /  3. 42.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Missing argument for option '5.ts'
root@Ubuntu32:/home/zhangbin/streaming/http/segmenter# ffplay output-playlist-m3u8 
ffplay version 1.2 Copyright (c) 2003-2013 the FFmpeg developers
  built on Apr 16 2013 19:40:09 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --prefix=/home/zhangbin/ffmpeg/ffmpegx86/ffmpegHome --enable-gpl --enable-version3 --enable-nonfree --enable-shared --enable-runtime-cpudetect --enable-gray --enable-avresample --enable-x11grab --enable-bzlib --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libspeex --enable-libtheora --enable-libv4l2 --enable-libvo-aacenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-zlib --enable-pic --enable-libfaac --enable-libass --enable-libfaac --enable-librtmp --enable-openssl
  libavutil      52. 18.100 / 52. 18.100
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.104 / 54. 63.104
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 42.103 /  3. 42.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[mpegts @ 0xafb08bc0] Estimating duration from bitrate, this may be inaccurate
Input #0, hls,applehttp, from 'output-playlist-m3u8':    0B f=0/0   
  Duration: 00:44:20.00, start: 1.400000, bitrate: N/A
  Program 0 
    Metadata:
      variant_bitrate : 0
    Stream #0:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 512x288, 11.99 fps, 23.98 tbr, 90k tbn, 47.95 tbc
    Stream #0:1: Audio: aac ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 129 kb/s
  20.28 A-V:  0.003 fd= 115 aq=   10KB vq=    4KB sq=    0B f=0/0   

原创粉丝点击