当前位置: 首页 > 知识库问答 >
问题:

FFMPEG:如何从mpd清单中手动选择视频质量?

冯嘉荣
2023-03-14

我想问我应该使用什么命令从mpd清单中选择视频质量?

MPD清单链接

https://anevia115(dot)mncnow(dot)id/vod/eds/kiko-season1-eps1-mobil-kabur-anv6/_/sa_dash_vmx/kiko-season1-eps1-mobil-kabur-anv6.mpd

这里是mpd文件:

<?xml version="1.0" encoding="utf-8"?>
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd" xmlns:cenc="urn:mpeg:cenc:2013" xmlns:mspr="urn:microsoft:playready" profiles="urn:mpeg:dash:profile:isoff-live:2011" type="static" mediaPresentationDuration="PT7M59.240000S" minBufferTime="PT0S" maxSegmentDuration="PT4S">
  <Period duration="PT7M59.240000S">
    <AdaptationSet id="1" group="1" mimeType="audio/mp4" lang="en" contentType="audio" minBandwidth="32000" maxBandwidth="64000">
<ContentProtection schemeIdUri="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"/><ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="5094c697-d5c4-84b7-cf4f-7830ba7d58a8" />      <Role schemeIdUri="urn:mpeg:dash:role:2011" value="main" />
      <Representation id="mp4a_32000_eng=6" bandwidth="32000" audioSamplingRate="22050" codecs="mp4a.40.2">
        <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2" />
        <SegmentTemplate timescale="10000000" initialization="kiko-season1-eps1-mobil-kabur-anv6-$RepresentationID$-init.mp4" media="kiko-season1-eps1-mobil-kabur-anv6-$RepresentationID$-$Time$.mp4">
          <SegmentTimeline>
            <S t="0" d="36223129" r="1" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758731" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758731" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" r="1" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758731" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758731" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" r="1" />
            <S d="35758731" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758731" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758731" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758731" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758731" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758731" />
            <S d="36223129" r="1" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758731" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758731" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" r="1" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="3715193" />
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
      <Representation id="mp4a_64000_eng=2" bandwidth="64000" audioSamplingRate="22050" codecs="mp4a.40.2">
        <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2" />
        <SegmentTemplate timescale="10000000" initialization="kiko-season1-eps1-mobil-kabur-anv6-$RepresentationID$-init.mp4" media="kiko-season1-eps1-mobil-kabur-anv6-$RepresentationID$-$Time$.mp4">
          <SegmentTimeline>
            <S t="0" d="36223129" r="1" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758731" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758731" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" r="1" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758731" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758731" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" r="1" />
            <S d="35758731" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758731" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758731" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758731" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758731" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758731" />
            <S d="36223129" r="1" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758731" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758731" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" r="1" />
            <S d="35758730" />
            <S d="36223130" />
            <S d="35758730" />
            <S d="36223129" />
            <S d="3715193" />
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
    </AdaptationSet>
    <AdaptationSet id="2" group="2" frameRate="25" mimeType="video/mp4" startWithSAP="1" contentType="video" par="16:9" minBandwidth="150119" maxBandwidth="5002530" minWidth="256" maxWidth="1920" minHeight="144" maxHeight="1080">
<ContentProtection schemeIdUri="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"/><ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="5094c697-d5c4-84b7-cf4f-7830ba7d58a8" />      <Role schemeIdUri="urn:mpeg:dash:role:2011" value="main" />
      <SegmentTemplate timescale="10000000" initialization="kiko-season1-eps1-mobil-kabur-anv6-$RepresentationID$-init.mp4" media="kiko-season1-eps1-mobil-kabur-anv6-$RepresentationID$-$Time$.mp4">
        <SegmentTimeline>
          <S t="0" d="36000000" r="132" />
          <S d="4400000" />
        </SegmentTimeline>
      </SegmentTemplate>
      <Representation id="avc1_150119=5" bandwidth="150119" width="256" height="144" codecs="avc1.4d400c" />
      <Representation id="avc1_500565=7" bandwidth="500565" width="640" height="360" codecs="avc1.4d401e" />
      <Representation id="avc1_1001193=9" bandwidth="1001193" width="854" height="480" codecs="avc1.4d401e" />
      <Representation id="avc1_2502286=1" bandwidth="2502286" width="1280" height="720" codecs="avc1.4d401f" />
      <Representation id="avc1_5002530=3" bandwidth="5002530" width="1920" height="1080" codecs="avc1.4d4028" />
    </AdaptationSet>
  </Period>
</MPD>

视频没有用DRM加密。当我尝试用FFmpeg下载时,成功了,但是FFmpeg自动选择了质量最差的(144p)。

我使用的FFmpeg命令:

ffmpeg -i https://anevia115(dot)mncnow(dot)id/vod/eds/kiko-season1-eps1-mobil-kabur-anv6/_/sa_dash_vmx/kiko-season1-eps1-mobil-kabur-anv6.mpd -c copy kiko1.mp4

来自ffmpeg的结果

ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
  configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
[dash @ 0x562ae2e98000] Opening '[URL]https://anevia115(dot)mncnow(dot)id/vod/eds/kiko-season1-eps1-mobil-kabur-anv6/_/sa_dash_vmx/kiko-season1-eps1-mobil-kabur-anv6-avc1_150119=5-init.mp4[/URL]' for reading [dash @ 0x562ae2e98000] Could not read complete fragment.
[dash @ 0x562ae2e98000] Opening '[URL]https://anevia115(dot)mncnow(dot)id/vod/eds/kiko-season1-eps1-mobil-kabur-anv6/_/sa_dash_vmx/kiko-season1-eps1-mobil-kabur-anv6-avc1_150119=5-0.mp4[/URL]' for reading
[dash @ 0x562ae2e98000] Opening '[URL]https://anevia115(dot)mncnow(dot)id/vod/eds/kiko-season1-eps1-mobil-kabur-anv6/_/sa_dash_vmx/kiko-season1-eps1-mobil-kabur-anv6-mp4a_32000_eng=6-init.mp4[/URL]' for reading [dash @ 0x562ae2e98000] Could not read complete fragment.
[dash @ 0x562ae2e98000] Opening '[URL]https://anevia115(dot)mncnow(dot)id/vod/eds/kiko-season1-eps1-mobil-kabur-anv6/_/sa_dash_vmx/kiko-season1-eps1-mobil-kabur-anv6-mp4a_32000_eng=6-0.mp4[/URL]' for reading
[aac @ 0x562ae32ced00] channel element 2.3 is not allocated
[h264 @ 0x562ae32cc500] top block unavailable for requested intra mode -1
[h264 @ 0x562ae32cc500] error while decoding MB 0 0, bytestream 38
[h264 @ 0x562ae32cc500] concealing 144 DC, 144 AC, 144 MV errors in I frame
Input #0, dash, from '[URL]https://anevia115(dot)mncnow(dot)id/vod/eds/kiko-season1-eps1-mobil-kabur-anv6/_/sa_dash_vmx/kiko-season1-eps1-mobil-kabur-anv6.mpd[/URL]':
  Duration: 00:07:59.00, start: 0.000000, bitrate: 0 kb/s 
Program 0
     Stream #0:0: Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 256x144 [SAR 1:1 DAR 16:9], 153 kb/s, 25 fps, 25 tbr, 10000k tbn, 50 tbc  
     Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 32 kb/s
Output #0, mp4, to 'kiko1.mp4': 
   Metadata:   
      encoder         : Lavf57.83.100   
      Stream #0:0: Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 256x144 [SAR 1:1 DAR 16:9], q=2-31, 153 kb/s, 25 fps, 25 tbr, 10000k tbn, 10000k tbc
Stream mapping: 
   Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[dash @ 0x562ae2e98000] Opening '[URL]https://anevia115(dot)mncnow(dot)id/vod/eds/kiko-season1-eps1-mobil-kabur-anv6/_/sa_dash_vmx/kiko-season1-eps1-mobil-kabur-anv6-mp4a_32000_eng=6-36223129.mp4[/URL]' for reading
[dash @ 0x562ae2e98000] Opening '[URL]https://anevia115(dot)mncnow(dot)id/vod/eds/kiko-season1-eps1-mobil-kabur-anv6/_/sa_dash_vmx/kiko-season1-eps1-mobil-kabur-anv6-avc1_150119=5-36000000.mp4[/URL]' for reading
....
....
frame=11978 fps= 99 q=-1.0 Lsize=    8891kB time=00:07:59.08 bitrate= 152.0kbits/s speed=3.97x
video:8779kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.269990%

试过youtube dl

注意:只需将(点)更改为


共有1个答案

乐正涵忍
2023-03-14

如果知道清单(表示集)中的流,那么可以使用ffmpeg的“map”参数。您可以使用ffprobe列出流图

ffprobe yourmanifest.mpd

你会得到这样的结果

Input #0, dash, from 'manifest.mpd':
  Duration: 00:27:36.00, start: -0.042667, bitrate: 0 kb/s
  Program 0
    Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 412 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      variant_bitrate : 1745920
      id              : video/avc1/1705k
    Stream #0:1: Video: h264 (High) (avc1 / 0x31637661), yuv420p, 682x384 [SAR 1024:1023 DAR 16:9], 89 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      variant_bitrate : 296960
      id              : video/avc1/290k
    Stream #0:2(en): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 65 kb/s (default)
    Metadata:
      variant_bitrate : 67335
      id              : audio/en/mp4a/64k

现在您可以将清单转换为MP4

ffmpeg -i yourmanifest.mpd -map 0:1 -map 0:2 -codec copy output.mp4

这将为您提供一个MP4,其中包含第二个视频流(索引1处的样本中的“290k”)和索引2处的音频流。

 类似资料:
  • 有个透明视频 text.mov 和一个背景图 bg.jpg(将作为视频背景),合并之后视频的质量明显降低,设置了帧率、码流、编码方式都不行,有没有解决过类似问题的,悬赏千元求解,谢谢诸位!!!

  • crf 20是相当高的质量,接近100%,恢复的帧应该接近原始。视频播放器暂停帧显示足够的质量。(虽然我不能说它是否在关键帧上) ffmpeg版本信息:

  • 我有一堆从Youtube下载的视频,我想从他们中提取帧。我使用的当前命令是: 但是我还想设置-r和-t选项。我想要的fps是每个视频的fps,持续时间是他们的持续时间。我知道如果我不设置-r选项,默认值是25 fps。

  • ap.chooseVideo(OPTION | maxDuration, CALLBACK) 录制或从手机相册中选择视频。可直接传入一个数字作为 OPTION.maxDuration 参数。 OPTION 参数说明 名称 类型 必选 描述 maxDuration Number 否 最大录制时长,单位秒,默认60s sourceType String Array 否 相册选取或者拍照,默认 ['ca

  • 我想在背景图像上覆盖透明视频。我有一个视频,其中上半部分是RGB对象,下半部分是阿尔法掩码。 现在,为了制作这个,我执行以下步骤: