开发者

Ffmpeg fails to encode properly when setting -ar as an option

I am trying to encode a number of videos using Ffmpeg. Every video I have thrown at it encodes correctly except for 4, At this stage we have encoded over 170 videos without an issue.

I've managed to work out i开发者_开发技巧t is failing due to the 4 videos not having an audio frequency in the audio track (Or one not set).

For example, This is the output I get when I inspect a "good" video -

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'good_video.mov':
Metadata:
major_brand     : qt  
minor_version   : 537199360
compatible_brands: qt  
Duration: 00:01:57.14, start: 0.000000, bitrate: 2017 kb/s
Stream #0.0(eng): Video: h264, yuv420p, 1280x720, 1705 kb/s, 25 fps, 25 tbr, 2500 tbn, 5k tbc
Stream #0.1(eng): Audio: aac, 44100 Hz, stereo, s16, 308 kb/s
Stream #0.2(eng): Data: tmcd / 0x64636D74`

And this is the output I get when I inspect a "bad" video -

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'bad_video.mov':
Metadata:
major_brand     : qt  
minor_version   : 537199360
compatible_brands: qt  
Duration: 00:02:57.26, start: 0.000000, bitrate: 3006 kb/s
Stream #0.0(eng): Video: h264, yuv420p, 1280x720, 2902 kb/s, 25 fps, 25 tbr, 2500 tbn, 5k tbc
Stream #0.1(eng): Audio: aac, stereo, s16, 99 kb/s
Stream #0.2(eng): Data: tmcd / 0x64636D74

As you can see the "bad" video does not have an audio frequency against it. This appears to be causing my issue. If I try to encode the "bad" video I get the following error -

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'bad_video.mov':
Metadata:
major_brand     : qt  
minor_version   : 537199360
compatible_brands: qt  
Duration: 00:02:57.26, start: 0.000000, bitrate: 3006 kb/s
Stream #0.0(eng): Video: h264, yuv420p, 1280x720, 2902 kb/s, 25 fps, 25 tbr, 2500 tbn, 5k tbc
Stream #0.1(eng): Audio: aac, stereo, s16, 99 kb/s
Stream #0.2(eng): Data: tmcd / 0x64636D74
[libx264 @ 0x10180d400]using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
[libx264 @ 0x10180d400]profile Constrained Baseline, level 3.1
[libx264 @ 0x10180d400]264 - core 114 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=0 ref=5 deblock=1:0:0 analyse=0x1:0x111 me=umh subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 constrained_intra=0 bframes=0 weightp=0 keyint=30 keyint_min=16 scenecut=40 intra_refresh=0 rc_lookahead=30 rc=abr mbtree=1 bitrate=1500 ratetol=2.7 qcomp=0.60 qpmin=10 qpmax=51 qpstep=4 ip_ratio=1.41 aq=1:1.00
[libfaac @ 0x10180da00]libfaac doesn't support this output format!
Output #0, mp4, to 'bad_video_encoded.mp4':
Stream #0.0(eng): Video: libx264, yuv420p, 1280x720, q=10-51, 1500 kb/s, 90k tbn, 25 tbc
Stream #0.1(eng): Audio: libfaac, stereo, s16, 64 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Error while opening encoder for output stream #0.1 - maybe incorrect parameters such as bit_rate, rate, width or height

I am attempting to encode with the following command -

ffmpeg -i bad_video.mov -b 1500k -vcodec libx264 -vpre slow -vpre baseline -g 30 -y bad_video_encoded.mp4

I also tried with -

ffmpeg -i bad_video.mov -b 1500k -vcodec libx264 -vpre slow -vpre baseline -acodec libfaac -ar 44100 -g 30 -y bad_video_encoded.mp4

But this drops all the frames and only encode the audio. All of the video is coming from the same source.

Any ideas where we are going wrong?

Thanks.


I don't know why Ffmpeg is having trouble with this, but from using it I know it's quirky. It looks like some of the metadata is missing from the bad video. I suggest running FLVMDI on the file, which will add the necessary metadata, and then rerun Ffmpeg on it. This step helped me in some cases.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜