对于我正在开发的应用程序,我需要avconv从链接流式传输指定的时间长度。我尝试使用-timelimit
无济于事。我究竟做错了什么?有一个更好的方法吗?为什么-timelimit
无效?
例如,请参阅下面的调用,该调用将一直运行,直到用ctrl-c终止。
stack@ThinkPad:~/app_dev$ avconv -timelimit 30 -i http://br-mp3-bayern2sued-m.akacast.akamaistream.net/7/731/256282/v1/gnl.akacast.akamaistream.net/br_mp3_bayern2sued_m stack_test.mp3
生成以下输出。
avconv version 9.18-6:9.18-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
built on Mar 16 2015 13:19:10 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
[mp3 @ 0x765100] Header missing
[mp3 @ 0x75f020] max_analyze_duration reached
[mp3 @ 0x75f020] Estimating duration from bitrate, this may be inaccurate
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, mp3, from 'http://br-mp3-bayern2sued-m.akacast.akamaistream.net/7/731/256282/v1/gnl.akacast.akamaistream.net/br_mp3_bayern2sued_m':
Duration: N/A, start: 0.000000, bitrate: 128 kb/s
Stream #0.0: Audio: mp3, 44100 Hz, stereo, s16p, 128 kb/s
Output #0, mp3, to 'stack_test.mp3':
Metadata:
TSSE : Lavf54.20.4
Stream #0.0: Audio: libmp3lame, 44100 Hz, stereo, s16p
Stream mapping:
Stream #0:0 -> #0:0 (mp3 -> libmp3lame)
Press ctrl-c to stop encoding
[mp3 @ 0x765100] Header missing
Error while decoding stream #0:0
[mp3 @ 0x7639e0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: -2255 >= -2255
答案 0 :(得分:2)
-t
和-timelimit
是different。更重要的是,您需要使用-t
作为输出选项,而不是输入选项。更新您的示例,以下内容应该有效(在ffmpeg上测试)。
ffmpeg -i http://br-mp3-bayern2sued-m.akacast.akamaistream.net/7/731/256282/v1/gnl.akacast.akamaistream.net/br_mp3_bayern2sued_m -t 30 stack_test.mp3