» 您尚未登录:请 登录 | 注册 | 标签 | 帮助 | 小黑屋 |


 24 12
发新话题
打印

[电脑] [勤劳的人看]我是不是有作码农的潜质? 原创Linux下批量快速转mp4的脚本

原帖
http://ubuntuforums.org/showthread.php?t=2017284


Hello
I'm a ubuntu user and a Mac / iDevice / iTunes user.
Because of the restriction of iTunes, you can't play divx or mkv files in iPhone / iPod / or iPad. even Xboxs / PS3
由于 各种设备基本都只能播放 MP4 所以我做了一个脚本批量转换

so you need to convert files. and a lots of files.
most convertor sucks. they are slow!
大多数转换工具都是 傻傻的转换 不管源文件如何 就算能放的部分也转换一次 浪费时间
actually you can make it faster.
如果不转换那个部分 转换就会很快

you know: video files have 视频文件基本由
container 容器: like mp4 mkv avi (change container is superfast) 比如 mp4 mkv avi (换容器好比换杯子 超快)
video视频: like h.264 divx, (change video format is superslow) 比如 h.264 divx, 等 换视频=超级慢
audio音频: like mp3 aac ac3 5.1 dts (change audio format is fast) 比如 mp3 ac3 dts aac flac (换音频还是比较快的)

Now lots of mkvs now encoded in H.264 that means you don't need to re-encode the video part. that save a lots of time!
现在很多 mkv 都是 h.264 的视频 也就是说 视频可以不转换 这样转换就很快了
unlike other tools I want something can decide what to convert what to copy automaticlly.
不像大多数的工具 这个脚本自动检测 啥要转 啥不要转

So I start to learn shellscript and here is my first shell script
所以我自学了 Unix Shell 脚本, 这是我第一个脚本


How to use: 如何使用
it come's with 2 files 里面有 2 个文件
ffbc.sh
ffbc_atv.sh

ffbc.sh is for all device but it will convert AC3 5.1 audio into aac 2 channel.
ffbc.sh 是万能的 但它会把 杜比 5.1 的音频换成 AAC 立体声

ffbc_atv.sh is for Apple TV it won't convert AC3 5.1 audio but copy it into new file because APPLE TV can play/passthrought AC3 5.1 audio
ffbc_atv.sh 是为 Apple TV 设计的 它会保留 杜比 5.1 音频 因为 Apple TV 可以透穿 5.1 给功放解码.

0. make sure you have ffmpeg with libfaac and x264 installed. 你必须装有 ffmpeg x264 和 libfaac
1. put all video files into a folder (File name MUST NOT have Spaces) 建立一个目录吧要转换的文件仍入 文件名不能有空格 最好不要是中文
2. make sure you have rights for write into the folder 确认你对目录有写的权限
3. cd the folder contain the scripts. 进入脚本所在目录
4. type the command 打命令

like: 例子

Code:
sh ffbc.sh mp4 /home/username/video
this will start to convert all video files in /home/username/video into mp4 format which iDevices can play.
这个命令会转换 /home/username/video 下所有视频文件 到 mp4 封装的 h.264 编码 aac 编码的 视频格式. 也就是标准的 mp4 所有设备都能播放

if you want to covert into mkv for further process try
如果你想暂时转换 mkv 之后容易编辑 那么
Code:
sh ffbc.sh mkv /home/username/video
this will start to convert all video files in /home/username/video into mkv with H.264 video and aac audio.
这个命令会转换 /home/username/video 下所有视频文件 到 mkv 封装的 h.264 编码 aac 编码的 视频格式. 有些合成器对 mp4 支持不好 比如 mp4tools.

5. find new file in output folder
之后在 文件目录里会多出一个 output 目录 输出结果在那里...

[ 本帖最后由 beterhans 于 2012-7-5 15:34 编辑 ]
附件: 您所在的用户组无法下载或查看附件


本帖最近评分记录
  • zzzeven 激骚 +1 最骚 Rated by wap for mark 2012-10-7 16:42
  • nonoh 激骚 +1 最骚 Rated by wap for mark 2012-10-7 08:04

TOP

posted by wap, platform: iPhone

不明觉历,顶!



TOP

也就是说这两个是lz写的?
ffbc.sh
ffbc_atv.sh
lz能分享一下这脚本怎么写出来的么?如果能做上界面岂不是更好?


TOP

引用:
原帖由 realbobo 于 2012-7-5 15:59 发表
也就是说这两个是lz写的?
ffbc.sh
ffbc_atv.sh
lz能分享一下这脚本怎么写出来的么?如果能做上界面岂不是更好?
我参考了 这几本书
Advanced Bash-Scripting Guide
Regular Expression Syntax
Google 了 sed 的使用方法.
Google 了 ffmpeg 的使用方法

但是我不会任何正经的开发编程  所以 GUI 开发肯定不会...
不过 windows 下是有类似工具 GUI 的 有人发过 但是我家主用台式机是 Ubuntu 所以自学了.

[ 本帖最后由 beterhans 于 2012-7-5 16:06 编辑 ]

TOP

posted by wap, platform: SAMSUNG (Galaxy S II)

恩恩有Windows版么  这种事自己瞎搞过  比如只转画面 或者声音

TOP

不觉明厉

TOP

引用:
原帖由 yangjuniori 于 2012-7-5 16:05 发表
posted by wap, platform: SAMSUNG (Galaxy S II)

恩恩有Windows版么  这种事自己瞎搞过  比如只转画面 或者声音
http://club.tgfcer.com/viewthrea ... 6&highlight=mp4
http://club.tgfcer.com/viewthrea ... 2&highlight=mp4

TOP

膜拜有耐心和恒心的人。以前想做,写了两行就懒了……

TOP

脚本写得好适合当运维

TOP

posted by wap, platform: iPhone

应该是一个对写程序挺感兴趣的人。如果快30了的话就算了。

TOP

posted by wap, platform: SAMSUNG (i917)

真有心啊,虽然我是win控。但还是佩服一下

TOP

posted by wap, platform: UC

能比离线转码快吗??

TOP

发现这个不是万能的
家里的 ffmpeg 比较新 居然命令格式不一样

TOP

posted by wap, platform: iPhone

现在大部分bdrip都是DTS的

TOP

蛮不错的
兴趣最重要
shell非常有意思

TOP

 24 12
发新话题
     
官方公众号及微博