深夜提醒

现在是深夜,建议您注意休息,不要熬夜哦~

🏮 🏮 🏮

新年快乐

祝君万事如意心想事成!

2024 桐庐半程马拉松
00:00:00
时间
0.00
距离(公里)
--:--
配速
--
步频
--
心率 (bpm)
--
配速
步频
|
share-image
ESC

使用 ffplay 指定http header播放视频

在给客户进行故障排查时,使用 ffplay 去播放,希望看播放视频的分辨率,发现客户设置了 referer 防盗链,直接访问返回 http 状态码403。之前都是直接用 ffplay 来进行播放的,查了下帮助文档,发现参数太大,于是使用 grep 打法过滤了下发现可以指定–headers 来进行自定义 http 请求头。

➜  ~ ffplay --help | grep 'HTTP'
ffplay version 3.3 Copyright (c) 2003-2017 the FFmpeg developers
built with Apple LLVM version 8.1.0 (clang-802.0.42)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libavresample 3. 5. 0 / 3. 5. 0
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
-ffrtmphttp_tls <boolean> .D...... Use a HTTPS tunneling connection (RTMPTS). (default false)
-http_proxy <string> ED...... set HTTP proxy to tunnel through
-headers <string> ED...... set custom HTTP headers, can override built in default headers
-post_data <binary> ED...... set custom HTTP post data
-cookies <string> .D...... set cookies to be sent in applicable future requests, use newline delimited Set-Cookie HTTP field value syntax
-auth_type <int> ED...... HTTP authentication type (from 0 to 1) (default none)
basic ED...... HTTP basic authentication
-method <string> ED...... Override the HTTP method or set the expected HTTP method from a client
-listen <int> ED...... listen on HTTP (from 0 to 2) (default 0)
-http_proxy <string> ED...... set HTTP proxy to tunnel through
-headers <string> ED...... set custom HTTP headers, can override built in default headers
-post_data <binary> ED...... set custom HTTP post data
-cookies <string> .D...... set cookies to be sent in applicable future requests, use newline delimited Set-Cookie HTTP field value syntax
-auth_type <int> ED...... HTTP authentication type (from 0 to 1) (default none)
basic ED...... HTTP basic authentication
-method <string> ED...... Override the HTTP method or set the expected HTTP method from a client
-listen <int> ED...... listen on HTTP (from 0 to 2) (default 0)
http .D...... HTTP tunneling
http .D...... HTTP tunneling

其中的

-headers           <string>     ED...... set custom HTTP headers, can override built in default headers

就是我们想要的了,知道了用什么就好办了,直接

➜  ~ ffplay -headers 'referer:xxx.cn' http://xxxxx/a/11.m3u8
ffplay version 3.3 Copyright (c) 2003-2017 the FFmpeg developers
built with Apple LLVM version 8.1.0 (clang-802.0.42)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libavresample 3. 5. 0 / 3. 5. 0
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
[http @ 0x7fd5b2d93320] No trailing CRLF found in HTTP header.
Input #0, hls,applehttp, from 'http://xxxxx/a/11.m3u8':B f=0/0
Duration: 00:08:25.90, start: 1.466667, bitrate: 0 kb/s
Program 0
Metadata:
variant_bitrate : 0
Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 720x1280 [SAR 1:1 DAR 9:16], 30 fps, 30 tbr, 90k tbn, 60 tbc
Metadata:
variant_bitrate : 0
Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, mono, fltp
Metadata:
variant_bitrate : 0
3.68 A-V: -0.034 fd= 0 aq= 13KB vq= 126KB sq= 0B f=0/0

其中这段显示的是客户改视频文件视频的编码方式是 H264,yuv420p是使用的颜色空间其中,Y表示亮度,而U,V则与颜色相关,而420则分别对应着存储相应分量所占用的比特数之,720x1280是视频的分辨率,[SAR 1:1 DAR 9:16]是视频的大小是16比9,30 fps 就是帧率咯,tbr, 90k tbn, 60 tbc 这是表示在相应层上的时间单元,比如tbn=2997就相当于在视频流层把1s的时间分成了2997个时间单元,如此精细可以更好的与其他流比如音频流同步,对应着fps=29.97就表示每100个时间单元中有一帧。

Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 720x1280 [SAR 1:1 DAR 9:16], 30 fps, 30 tbr, 90k tbn, 60 tbc

对于多媒体这块了解不多,也就是在处理 cdn 问题的时候稍微了解下。

文章作者:阿文
文章链接: https://www.awen.me/post/1895316841.html
版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 阿文的博客
本文于 2017-06-15 13:21 发布,已超过半年(3195天),请注意甄别内容是否已过期。

评论

0 条评论
😀😃😄 😁😅😂 🤣😊😇 🙂🙃😉 😌😍🥰 😘😗😙 😚😋😛 😝😜🤪 🤨🧐🤓 😎🥸🤩 🥳😏😒 😞😔😟 😕🙁☹️ 😣😖😫 😩🥺😢 😭😤😠 😡🤬🤯 😳🥵🥶 😱😨😰 😥😓🤗 🤔🤭🤫 🤥😶😐 😑😬🙄 😯😦😧 😮😲🥱 😴🤤😪 😵🤐🥴 🤢🤮🤧 😷🤒🤕 🤑🤠😈 👿👹👺 🤡💩👻 💀☠️👽 👾🤖🎃 😺😸😹 😻😼😽 🙀😿😾 👍👎👏 🙌👐🤲 🤝🤜🤛 ✌️🤞🤟 🤘👌🤏 👈👉👆 👇☝️ 🤚🖐️🖖 👋🤙💪 🦾🖕✍️ 🙏💅🤳 💯💢💥 💫💦💨 🕳️💣💬 👁️‍🗨️🗨️🗯️ 💭💤❤️ 🧡💛💚 💙💜🖤 🤍🤎💔 ❣️💕💞 💓💗💖 💘💝💟 ☮️✝️☪️ 🕉️☸️✡️ 🔯🕎☯️ ☦️🛐 🆔⚛️🉑 ☢️☣️📴 📳🈶🈚 🈸🈺🈷️ ✴️🆚💮 🉐㊙️㊗️ 🈴🈵🈹 🈲🅰️🅱️ 🆎🆑🅾️ 🆘 🛑📛 🚫💯💢 ♨️🚷🚯 🚳🚱🔞 📵🚭 ‼️⁉️🔅 🔆〽️⚠️ 🚸🔱⚜️ 🔰♻️ 🈯💹❇️ ✳️🌐 💠Ⓜ️🌀 💤🏧🚾 🅿️🈳 🈂🛂🛃 🛄🛅🛗 🚀🛸🚁 🚉🚆🚅 ✈️🛫🛬 🛩️💺🛰️
您的评论由 AI 智能审核,一般1分钟内会展示,若不展示请确认你的评论是否符合社区和法律规范
加载中...

选择联系方式

留言反馈

😀😃😄 😁😅😂 🤣😊😇 🙂🙃😉 😌😍🥰 😘😗😙 😚😋😛 😝😜🤪 🤨🧐🤓 😎🥸🤩 🥳😏😒 😞😔😟 😕🙁☹️ 😣😖😫 😩🥺😢 😭😤😠 😡🤬🤯 😳🥵🥶 😱😨😰 😥😓🤗 🤔🤭🤫 🤥😶😐 😑😬🙄 😯😦😧 😮😲🥱 😴🤤😪 😵🤐🥴 🤢🤮🤧 😷🤒🤕 🤑🤠😈 👿👹👺 🤡💩👻 💀☠️👽 👾🤖🎃 😺😸😹 😻😼😽 🙀😿😾 👍👎👏 🙌👐🤲 🤝🤜🤛 ✌️🤞🤟 🤘👌🤏 👈👉👆 👇☝️ 🤚🖐️🖖 👋🤙💪 🦾🖕✍️ 🙏💅🤳 💯💢💥 💫💦💨 🕳️💣💬 👁️‍🗨️🗨️🗯️ 💭💤❤️ 🧡💛💚 💙💜🖤 🤍🤎💔 ❣️💕💞 💓💗💖 💘💝💟 ☮️✝️☪️ 🕉️☸️✡️ 🔯🕎☯️ ☦️🛐 🆔⚛️🉑 ☢️☣️📴 📳🈶🈚 🈸🈺🈷️ ✴️🆚💮 🉐㊙️㊗️ 🈴🈵🈹 🈲🅰️🅱️ 🆎🆑🅾️ 🆘 🛑📛 🚫💯💢 ♨️🚷🚯 🚳🚱🔞 📵🚭 ‼️⁉️🔅 🔆〽️⚠️ 🚸🔱⚜️ 🔰♻️ 🈯💹❇️ ✳️🌐 💠Ⓜ️🌀 💤🏧🚾 🅿️🈳 🈂🛂🛃 🛄🛅🛗 🚀🛸🚁 🚉🚆🚅 ✈️🛫🛬 🛩️💺🛰️