如何使用ffmpeg为wmv和avi视频文件生成m3u8文件和TS段文件列表

时间:2018-04-25 04:34:20

标签: ffmpeg

我可以使用以下m3u8命令从.ts视频文件生成mp4和段(ffmpeg)文件列表

ffmpeg -i Bee_Free.mp4 -codec copy -vbsf h264_mp4toannexb -map 0 -f segment -segment_list free.m3u8 -segment_time 10 free%03d.ts

我使用相同的命令从m3u8ts文件生成.wmv.avi个文件

.avi文件的

命令

ffmpeg -i PalivalaBadraVatakam.avi -codec copy -vbsf h264_mp4toannexb -map 0 -f segment -segment_list palivaala.m3u8 -segment_time 10 palivaala%03d.ts

错误

ffmpeg version N-89041-g91a565e20f Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 7.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-            
libbluray --enable-libfreetype --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-    
libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable- 
libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx
libavutil      56.  0.100 / 56.  0.100
libavcodec     58.  3.101 / 58.  3.101
libavformat    58.  2.100 / 58.  2.100
libavdevice    58.  0.100 / 58.  0.100
libavfilter     7.  0.101 /  7.  0.101
libswscale      5.  0.101 /  5.  0.101
libswresample   3.  0.101 /  3.  0.101
libpostproc    55.  0.100 / 55.  0.100
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, avi, from 'PalivalaBadraVatakam.avi':
Metadata:
date            : 2018-04-24T17:08:40+05:30
encoder         : Adobe Premiere Pro CC 2018.1 (Windows)
Duration: 00:00:53.19, start: 0.000000, bitrate: 30317 kb/s
Stream #0:0: Video: dvvideo (dvsd / 0x64737664), yuv411p, 720x480 [SAR 8:9 DAR 4:3], 28789 kb/s, 29.97 fps, 29.97 tbr, 29.97 tbn, 29.97 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16, 1536 kb/s
[AVBSFContext @ 000001e976f84080] Codec 'dvvideo' (24) is not supported by the bitstream filter 'h264_mp4toannexb'. Supported codecs are: h264 (27)
Error initializing bitstream filter: h264_mp4toannexb
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Last message repeated 1 times

.wmv文件的命令

ffmpeg -i Palivaalaa.wmv -codec copy -vbsf h264_mp4toannexb -map 0 -f segment -segment_list palivaalaa.m3u8 -segment_time 10 palivaalaa%03d.ts

错误

ffmpeg version N-89041-g91a565e20f Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 7.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable- 
libbluray --enable-libfreetype --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable- 
libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable- 
libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx
libavutil      56.  0.100 / 56.  0.100
libavcodec     58.  3.101 / 58.  3.101
libavformat    58.  2.100 / 58.  2.100
libavdevice    58.  0.100 / 58.  0.100
libavfilter     7.  0.101 /  7.  0.101
libswscale      5.  0.101 /  5.  0.101
libswresample   3.  0.101 /  3.  0.101
libpostproc    55.  0.100 / 55.  0.100
[wmv3 @ 0000024020a04a40] Extra data: 8 bits left, value: 20
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, asf, from 'Palivaalaa.wmv':
Metadata:
Application     : Windows Movie Maker 2.6.4037.0
WMFSDKVersion   : 12.0.16299.248
WMFSDKNeeded    : 0.0.0.0000
artist          : Sathish
IsVBR           : 0
DeviceConformanceTemplate: MP@ML
Duration: 00:01:00.10, start: 0.000000, bitrate: 571 kb/s
Stream #0:0(eng): Audio: wmav2 (a[1][0][0] / 0x0161), 44100 Hz, stereo, fltp, 96 kb/s
Stream #0:1(eng): Video: wmv3 (Main) (WMV3 / 0x33564D57), yuv420p, 640x480, 768 kb/s, SAR 1:1 DAR 4:3, 25 fps, 25 tbr, 1k tbn, 1k tbc
[AVBSFContext @ 0000024020a9b420] Codec 'wmv3' (71) is not supported by the bitstream filter 'h264_mp4toannexb'. Supported codecs are: h264 (27)
Error initializing bitstream filter: h264_mp4toannexb
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Last message repeated 1 times

2 个答案:

答案 0 :(得分:1)

带有TS文件的HLS仅支持h.264视频编解码器和aac或mp3音频。因此-codec副本将无法正常工作。只需删除它,ffmpeg应自动选择libx264。

答案 1 :(得分:0)

这里列出了TS muxer支持的文件格式https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/mpegts.h#L45-L64

总之,它们是:

  • VIDEO_MPEG1
  • VIDEO_MPEG2
  • AUDIO_MPEG1
  • AUDIO_MPEG2
  • AUDIO_AAC
  • AAC_LATM
  • VIDEO_MPEG4
  • METADATA
  • VIDEO_H264
  • VIDEO_HEVC
  • VIDEO_CAVS
  • VIDEO_VC1
  • VIDEO_DIRAC
  • AUDIO_AC3
  • AUDIO_DTS
  • AUDIO_TRUEHD
  • AUDIO_EAC3

列出了您正在尝试的所有编解码器。正如它的名字一样, -vbsf h264_mp4toannexb 和错误消息 Codec' wmv3'比特流过滤器' h264_mp4toannexb'不支持(71)。支持的编解码器是:h264(27),h264_mp4toannexb过滤器仅支持h264