Skip to content

Instantly share code, notes, and snippets.

@EHfive
Last active November 8, 2021 05:40
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save EHfive/bfc6098feb99a02bf59192618107d2ef to your computer and use it in GitHub Desktop.
Save EHfive/bfc6098feb99a02bf59192618107d2ef to your computer and use it in GitHub Desktop.
给VLC打补丁, 使flac网络文件/流的Content-Type始终为"audio/flac", 以"修复"网易云音乐获取的flac网络文件Content-Type为"audio/mpeg"而导致VLC不能正确识别文件而播放失败的问题
diff --git a/modules/access/http/resource.c b/modules/access/http/resource.c
index 9a28bb50f3..4919cb3a05 100644
--- a/modules/access/http/resource.c
+++ b/modules/access/http/resource.c
@@ -315,6 +315,18 @@ char *vlc_http_res_get_type(struct vlc_http_resource *res)
if (status < 200 || status >= 300)
return NULL;
+ if(res->path){
+ char *suffix = "\0";
+ for(int i = (int) (strlen(res->path) - 1); i >= 0; --i){
+ if(res->path[i] == '.'){
+ suffix = res->path + i + 1;
+ break;
+ }
+ }
+ if(strcmp(suffix, "flac") == 0)
+ return strdup("audio/flac");
+ }
+
const char *type = vlc_http_msg_get_header(res->response, "Content-Type");
return (type != NULL) ? strdup(type) : NULL;
}
_pkgname=vlc
pkgname=vlc-ncm
_vlcver=3.0.12
# optional fixup version including hyphen
_vlcfixupver=
pkgver=${_vlcver}${_vlcfixupver//-/.r}
pkgrel=1
pkgdesc='Multi-platform MPEG, VCD/DVD, and DivX player'
url='https://www.videolan.org/vlc/'
arch=('x86_64')
license=('LGPL2.1' 'GPL2')
depends=('flac' 'mpg123' 'libpulse' 'alsa-lib' 'libsamplerate' 'libsoxr')
makedepends=()
options=('!emptydirs')
source=(https://download.videolan.org/${_pkgname}/${_vlcver}/${_pkgname}-${_vlcver}${_vlcfixupver}.tar.xz{,.asc}
ncm.patch)
sha512sums=('ebec92bf732540be117551e94613747c53514ade7e280167c08400375738df9a01ee0e5d7c7733aca151a4f80f1c7163fd41318f2cc80b04a3201f0ba697e5df'
'SKIP'
'0dd7a8a140173af3d43a86edab709128a5ee5ec05323425067ae4f8db937c104d086695ff4dc97763a550fb3e6cb4c4e0174673bc032bb04dae37451741a5b15')
validpgpkeys=('65F7C6B4206BD057A7EB73787180713BE58D1ADC') # VideoLAN Release Signing Key
prepare() {
cd ${_pkgname}-${_vlcver}
sed -e 's:truetype/ttf-dejavu:TTF:g' -i modules/visualization/projectm.cpp
sed -e 's|-Werror-implicit-function-declaration||g' -i configure
sed 's|whoami|echo builduser|g' -i configure
sed 's|hostname -f|echo arch|g' -i configure
local src
for src in "${source[@]}"; do
src="${src%%::*}"
src="${src##*/}"
[[ $src = *.patch ]] || continue
echo "Applying patch $src..."
patch -Np1 < "../$src"
done
}
build() {
cd ${_pkgname}-${_vlcver}
export CXXFLAGS+=" -std=c++11"
./configure \
--prefix=/opt/vlc-ncm \
--sysconfdir=/opt/vlc-ncm/etc \
--disable-rpath \
--enable-mpg123 \
--enable-flac \
--disable-pulse \
--enable-alsa \
--enable-samplerate \
--enable-soxr \
--enable-gnutls \
--disable-update-check \
--disable-vlc \
--disable-lua \
--disable-avcodec \
--disable-avformat \
--disable-gst-decode \
--disable-swscale \
--disable-a52 \
--without-x \
--disable-xcb \
--disable-vdpau \
--disable-wayland \
--disable-sdl-image \
--disable-srt \
--disable-qt \
--disable-caca
make
}
package() {
cd ${_pkgname}-${_vlcver}
make DESTDIR="${pkgdir}" install
install -Dm 644 "${srcdir}/update-vlc-ncm-plugin-cache.hook" -t "${pkgdir}/usr/share/libalpm/hooks"
}
# vim: ts=2 sw=2 et:
@EHfive
Copy link
Author

EHfive commented Mar 5, 2021

此PKGBUILD只在clean chroot中构建通过,在用户环境下可能需要自行调整构建选项。
如果有卡顿可以尝试关闭pulseaudio后端( --enable-pulse -> --disable-pulse) 只留下ALSA后端。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment