一行命令解决电视盒子播放下载的电视剧无声音的问题

 快过年了,防止无聊,下载了部经典喜剧在电视盒子上看看。

现在片源越来越不好找了,好不容易下了部 

一行命令解决电视盒子播放下载的电视剧无声音的问题_第1张图片

回家在机顶盒上一播放,傻眼了,有图像没声音,声道切换也不管用

这点事情难不倒程序猿,ffprobe查看视频属性

ffprobe 01.mkv

 结果

ffprobe version 4.1.3 Copyright (c) 2007-2019 the FFmpeg developers
  built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1.3_1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-11.0.2.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-11.0.2.jdk/Contents/Home/include/darwin' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-videotoolbox --disable-libjack --disable-indev=jack --enable-libaom --enable-libsoxr
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Input #0, matroska,webm, from '01.mkv':
  Metadata:
    encoder         : libebml v1.3.0 + libmatroska v1.4.0
    creation_time   : 2014-08-06T02:14:45.000000Z
  Duration: 00:42:07.96, start: 0.000000, bitrate: 2324 kb/s
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 720x540 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 1k tbn, 50 tbc (default) (forced)
    Metadata:
      title           : CMCT@小五压制
    Stream #0:1: Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s (default) (forced)
    Metadata:
      title           : 国语
    Stream #0:2: Subtitle: ass (default) (forced)
    Metadata:
      title           : 简体中字
    Stream #0:3: Subtitle: ass
    Metadata:
      title           : 繁体中字

根据以往经验,删除掉多出的几个Stream,应该就能顺利播放

新建out目录

mkdir out

用一行代码解决这个问题: 

find . | grep mkv| sed 's#./##g' |xargs -n 1 -I {}  ffmpeg  -i {}  -map 0:0 -map 0:1  -vcodec copy -acodec copy out/{}

所有处理后的视频都放到当前文件夹out子目录里

再次用ffprob查看处理后的结果

ffprobe 01.mkv
ffprobe version 4.1.3 Copyright (c) 2007-2019 the FFmpeg developers
  built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1.3_1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-11.0.2.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-11.0.2.jdk/Contents/Home/include/darwin' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-videotoolbox --disable-libjack --disable-indev=jack --enable-libaom --enable-libsoxr
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Input #0, matroska,webm, from '01.mkv':
  Metadata:
    ENCODER         : Lavf58.20.100
  Duration: 00:42:07.96, start: 0.000000, bitrate: 2325 kb/s
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 720x540 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 1k tbn, 50 tbc (default) (forced)
    Metadata:
      title           : CMCT@小五压制
      DURATION        : 00:42:07.960000000
    Stream #0:1: Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s (default) (forced)
    Metadata:
      title           : 国语
      DURATION        : 00:42:07.904000000

现在是单音轨+单视频Stream了,电视盒子应该可以了吧!

再次播放,又傻眼了,还是无法播放!

查看能正常播放出声音的视频

ffprobe 01.mkv
ffprobe version 4.1.3 Copyright (c) 2007-2019 the FFmpeg developers
  built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1.3_1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-11.0.2.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-11.0.2.jdk/Contents/Home/include/darwin' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-videotoolbox --disable-libjack --disable-indev=jack --enable-libaom --enable-libsoxr
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Input #0, matroska,webm, from '01.mkv':
  Metadata:
    encoder         : libebml v0.7.9 + libmatroska v0.8.1
    creation_time   : 2010-05-06T07:47:43.000000Z
  Duration: 00:42:04.24, start: 0.000000, bitrate: 487 kb/s
    Stream #0:0: Video: h264 (Main), yuv420p(progressive), 608x448 [SAR 1:1 DAR 19:14], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
    Metadata:
      title           : XTM HALFCD TEAM
    Stream #0:1: Audio: aac (HE-AACv2), 48000 Hz, stereo, fltp (default)

发现声音编码用的是

Stream #0:1: Audio: aac (HE-AACv2), 48000 Hz, stereo, fltp (default)

而不能播放的视频用的是

Stream #0:1: Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s (default) 

转换成aac 应该就ok了,执行转换命令

ffmpeg  -i 01.mkv  -map 0:0 -map 0:1 -vcodec copy -acodec copy -c:a libfdk_aac -vbr 2  out01.mkv

提示错误

brew安装的ffmpeg默认不带libfdk_aac

修改默认ffmpeg.rb

brew edit ffmpeg

在args后面加上两行

一行命令解决电视盒子播放下载的电视剧无声音的问题_第2张图片

--enable-libfdk-aac
--enable-nonfree

重新从源码安装ffmpeg

brew reinstall -s ffmpeg

cpu负荷升高,可以感知到在默默编译,并安装完成

一行命令解决电视盒子播放下载的电视剧无声音的问题_第3张图片

实验下效果,执行

ffmpeg  -i 01.mkv  -map 0:0 -map 0:1 -vcodec copy -acodec copy -c:a libfdk_aac -vbr 2  out01.mkv

顺利执行

Stream #0:1: Audio: aac (libfdk_aac) ([255][0][0][0] / 0x00FF), 48000 Hz, 5.1, s16 (default) (forced)
    Metadata:
      title           : 国语
      encoder         : Lavc58.54.100 libfdk_aac
frame=  326 fps=0.0 q=-1.0 size=    1442kB time=00:00:13.16 bitrate= 897.7kbitsframe=  665 fps=664 q=-1.0 size=    4263kB time=00:00:26.64 bitrate=1310.7kbitsframe=  995 fps=662 q=-1.0 size=    8574kB time=00:00:40.10 bitrate=1751.4kbits

查看执行结果,audio已经被转换

Stream #0:0: Video: h264 (High), yuv420p(progressive), 720x540 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 1k tbn, 50 tbc (default) (forced)
    Metadata:
      title           : CMCT@小五压制
      DURATION        : 00:42:08.003000000
Stream #0:1: Audio: aac (LC), 48000 Hz, 5.1, fltp (default) (forced)
    Metadata:
      title           : 国语
      ENCODER         : Lavc58.54.100 libfdk_aac
      DURATION        : 00:42:07.947000000

又回到用一行代码解决问题,执行所有文件转换,并保存到out目录下,执行前需要先删除上次生成的out目录

mkdir out && find . | grep mkv| sed 's#./##g' |xargs -n 1 -I {} ffmpeg  -i {}  -map 0:0 -map 0:1 -vcodec copy -acodec copy -c:a libfdk_aac -vbr 2  out/{}

视频处理完,继续在电视盒子上播放!视频和图像都OK!

 

全文结束

 

 

你可能感兴趣的:(FFMPEG,Brew,Shell)