将ffmpeg整合到bash脚本中 [英] Incorporating ffmpeg in a bash script

查看:81
本文介绍了将ffmpeg整合到bash脚本中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常大的音频mp4文件,其中包含几首歌曲.

I have a very large audio mp4 file that contains several songs.

我生成了一个脚本,该脚本读取带有时间和歌曲名称的文本文件,并成功在3个变量中分配了开始时间,结束时间和歌曲标题.脚本成功回显变量并返回以下格式:

I have generated a script which reads a text file with the times and the song names and successfully assigns starttime, endtime and songtitle in 3 variables. The script successfully echoes the variables and returns the following format:

00:00:00 00:10:15 Song1
00:10:15 00:14:20 Song2

以此类推...

现在,我打算将此脚本与 ffmpeg 一起使用,并将大文件的每个部分裁剪为较小的音频文件.

Now I am intending to use this script with ffmpeg and crop each part of the big file into smaller audio files.

因此,脚本在 while 循环中输入变量后,会到达命令

The script thus, after feeding the variables in a while loop, it reaches to the command

ffmpeg -ss $START -t $END -i ${1} -acodec copy $SONGNAME.mp4

运行脚本后,会裁剪前两首歌曲,但随后整个过程就会停止

Once I run the script, the first two songs are cropped, but then the whole process stops with

Press [q] to stop, [?] for help
error parsing debug value
debug=0

我检查了生成的文件,它们正常播放,但是我没有办法知道为什么脚本在那里停止并且没有继续处理文件的其余部分(考虑到在脚本中我替换 ffmpeg的原因 echo 配合使用,脚本会完美地回显变量.)

I checked the generated files and they play ok, but there is no way for me to know why the script stopped there and did no proceed to the rest of the file (considering that when in the script I replace ffmpeg with echo, the script echoes the variables flawlessly).

换句话说,我不知道我的脚本 ffmpeg 或源音乐文件是否存在问题.

In other words I don't know if there is a problem in my script, ffmpeg, or the source music file.

推荐答案

在这种情况下,我会将参数 -nostdin 添加到 ffmpeg .

In this case I would add the argument -nostdin to ffmpeg.

这篇关于将ffmpeg整合到bash脚本中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆