旋转视频 - 无法为输出文件 #0 写入 header(编解码器参数不正确?)
Rotate Video- Could not write header for output file #0 (incorrect codec parameters ?)
我正在使用下面的命令来旋转视频-
{"-y", "-ss", "" + startMs / 1000, "-t", "" + (endMs - startMs) / 1000, "-i", inputPath, "-vf", "transpose=" + type,"-c:a", "copy", outputPath}
我在 Android Oreo-
中收到以下失败消息
"ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers\n
built with gcc 4.8 (GCC)\n configuration: --target-os=linux
--cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi-
--arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot
--enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib
-Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=\n libavutil 55. 17.103 / 55. 17.103\n libavcodec 57. 24.102 / 57. 24.102\n libavformat 57. 25.100 /
57. 25.100\n libavdevice 57. 0.101 / 57. 0.101\n libavfilter 6. 31.100 / 6. 31.100\n libswscale 4. 0.100 / 4. 0.100\n libswresample 2. 0.101 / 2. 0.101\n libpostproc 54. 0.100 /
54. 0.100\nInput #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/Download/dolbycanyon.3gp':\n Metadata:\n
major_brand : 3gp4\n minor_version : 512\n
compatible_brands: isomiso23gp4\n Duration: 00:00:38.07, start:
0.006250, bitrate: 402 kb/s\n Stream #0:0(und): Video: h263 (s263 / 0x33363273), yuv420p, 704x576 [SAR 12:11 DAR 4:3], 384 kb/s, 29.97
fps, 29.97 tbr, 30k tbn, 29.97 tbc (default)\n Metadata:\n
handler_name : VideoHandler\n Stream #0:1(und): Audio: amr_nb
(samr / 0x726D6173), 8000 Hz, mono, flt, 12 kb/s (default)\n
Metadata:\n handler_name : SoundHandler\n[libx264 @
0xf64e5400] using SAR=11/12\n[libx264 @ 0xf64e5400] using cpu
capabilities: none!\n[libx264 @ 0xf64e5400] profile High, level
3.1\n[libx264 @ 0xf64e5400] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options:
cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1
psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1
8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2
threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1
interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2
b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250
keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf
mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40
aq=1:1.00\n[mp4 @ 0xf64a8600] Could not find tag for codec amr_nb in
stream #1, codec not currently supported in container\nOutput #0, mp4,
to '/storage/emulated/0/Movies/rotate_video4.mp4':\n Metadata:\n
major_brand : 3gp4\n minor_version : 512\n
compatible_brands: isomiso23gp4\n encoder : Lavf57.25.100\n
Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021),
yuv420p, 576x704 [SAR 11:12 DAR 3:4], q=-1--1, 29.97 fps, 30k tbn,
29.97 tbc (default)\n Metadata:\n handler_name : VideoHandler\n encoder : Lavc57.24.102 libx264\n Side
data:\n unknown side data type 10 (24 bytes)\n Stream
0:1(und): Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, 12 kb/s (default)\n Metadata:\n handler_name : SoundHandler\nStream
mapping:\n Stream #0:0 -> #0:0 (h263 (native) -> h264 (libx264))\n
Stream #0:1 -> #0:1 (copy)\nCould not write header for output file #0
(incorrect codec parameters ?): Invalid argument\n"
为什么会出现此错误,我该如何解决?
MP4 不正式支持 amr_nb 音频。无论如何要强制它,
{"-y", "-ss", "" + startMs / 1000, "-t", "" + (endMs - startMs) / 1000, "-i", inputPath, "-vf", "transpose=" + type,"-c:a", "copy", "-atag","samr", outputPath}
但建议您改为保存为 .3gp。
或者,您可以通过删除 "-c:a", "copy"
来重新编码音频
我正在使用下面的命令来旋转视频-
{"-y", "-ss", "" + startMs / 1000, "-t", "" + (endMs - startMs) / 1000, "-i", inputPath, "-vf", "transpose=" + type,"-c:a", "copy", outputPath}
我在 Android Oreo-
中收到以下失败消息"ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers\n built with gcc 4.8 (GCC)\n configuration: --target-os=linux --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=\n libavutil 55. 17.103 / 55. 17.103\n libavcodec 57. 24.102 / 57. 24.102\n libavformat 57. 25.100 / 57. 25.100\n libavdevice 57. 0.101 / 57. 0.101\n libavfilter 6. 31.100 / 6. 31.100\n libswscale 4. 0.100 / 4. 0.100\n libswresample 2. 0.101 / 2. 0.101\n libpostproc 54. 0.100 / 54. 0.100\nInput #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/Download/dolbycanyon.3gp':\n Metadata:\n
major_brand : 3gp4\n minor_version : 512\n
compatible_brands: isomiso23gp4\n Duration: 00:00:38.07, start: 0.006250, bitrate: 402 kb/s\n Stream #0:0(und): Video: h263 (s263 / 0x33363273), yuv420p, 704x576 [SAR 12:11 DAR 4:3], 384 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 29.97 tbc (default)\n Metadata:\n
handler_name : VideoHandler\n Stream #0:1(und): Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, flt, 12 kb/s (default)\n
Metadata:\n handler_name : SoundHandler\n[libx264 @ 0xf64e5400] using SAR=11/12\n[libx264 @ 0xf64e5400] using cpu capabilities: none!\n[libx264 @ 0xf64e5400] profile High, level 3.1\n[libx264 @ 0xf64e5400] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00\n[mp4 @ 0xf64a8600] Could not find tag for codec amr_nb in stream #1, codec not currently supported in container\nOutput #0, mp4, to '/storage/emulated/0/Movies/rotate_video4.mp4':\n Metadata:\n
major_brand : 3gp4\n minor_version : 512\n
compatible_brands: isomiso23gp4\n encoder : Lavf57.25.100\n Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 576x704 [SAR 11:12 DAR 3:4], q=-1--1, 29.97 fps, 30k tbn, 29.97 tbc (default)\n Metadata:\n handler_name : VideoHandler\n encoder : Lavc57.24.102 libx264\n Side data:\n unknown side data type 10 (24 bytes)\n Stream 0:1(und): Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, 12 kb/s (default)\n Metadata:\n handler_name : SoundHandler\nStream mapping:\n Stream #0:0 -> #0:0 (h263 (native) -> h264 (libx264))\n Stream #0:1 -> #0:1 (copy)\nCould not write header for output file #0 (incorrect codec parameters ?): Invalid argument\n"
为什么会出现此错误,我该如何解决?
MP4 不正式支持 amr_nb 音频。无论如何要强制它,
{"-y", "-ss", "" + startMs / 1000, "-t", "" + (endMs - startMs) / 1000, "-i", inputPath, "-vf", "transpose=" + type,"-c:a", "copy", "-atag","samr", outputPath}
但建议您改为保存为 .3gp。
或者,您可以通过删除 "-c:a", "copy"