运行FFmpeg命令后无法播放的视频 [英] Unplayable video after running FFmpeg command
问题描述
去年我问了这个问题.我解决了我遇到的问题,并实现了将图像与视频(而不是两个图像)合并的相同逻辑.它正在Android上运行.
I asked this question last year. I resolved the issue I had and I implemented the same logic for merging an image with a video, instead of two images. This is running on Android.
这是我当前正在使用的命令:
Here is the command I'm using currently:
"-i", mFilePath, "-i", drawingPath, "-filter_complex", "[0:v]scale=iw*sar:ih,setsar=1,pad='max(iw\\,2*trunc(ih*47/80/2))':'max(ih\\,2*trunc(ow*80/47/2))':(ow-iw)/2:(oh-ih)/2[v0];[1:v][v0]scale2ref[v1][v0];[v0][v1]overlay=x=(W-w)/2:y=(H-h)/2[v]", "-map", "[v]", "-map", "0:a", "-c:v", "libx264", "-preset", "ultrafast", "-r", outputFPS, outputPath}
47/80/2
是通过获取设备的屏幕尺寸- 1128 x 1920
来计算的.
47/80/2
is calculated by getting a device's screen dimensions - 1128 x 1920
.
在某些设备上运行该视频时,它会导致无法播放视频.
When running this on certain devices, it results in an unplayable video.
但是运行以下命令可以很好地工作:
But running the following command works perfectly fine:
"-i", mFilePath, "-crf", "18", "-c:v", "libx264", "-preset", "ultrafast", outputPath};
我认为问题在于正在应用过滤器?
I think the issue is with the filter being applied?
我比较了在两个不同的设备上运行第一个命令的情况.
I compared running the first command on two different devices.
- 在第一台设备(三星J7 Pro)上,我能够成功运行命令并随后播放视频.我在两个设备上都测试了输出,并且可以正常工作.
- 在第二台设备(Sony Xperia Tablet Z)上,我能够成功运行命令,但无法播放视频.我在这两种设备上测试了输出,但都不在其中任何一个上播放.它确实可以在我的计算机上播放.
我将原始视频与不运行的视频进行了比较,而没有过滤器的视频进行了比较,唯一的区别是,我无法访问的配置文件是 Baseline@L4.2
,而没有过滤器配置文件的是 Baseline@L4.0
.原始视频配置文件是 High@L4.0
.
I compared the original video with the one not working and the one without a filter and the only difference I could find is that the one that is not working profile is Baseline@L4.2
and the one without a filter profile is Baseline@L4.0
. The original video profile is High@L4.0
.
此处是所有视频.原始的,一个没有过滤器的(有效)和一个有过滤器的(无效).
Here are all the videos. The original, the one without a filter (working) and the one with the filter(no working).
我不知道为什么会这样?任何帮助将不胜感激.
I have no idea why this is happening? Any help would be appreciated.
这是请求的实际日志:
"-i", "/storage/emulated/0/Android/data/com.my.package/files/CameraTemp/2020_05_24_09_17_53.mp4", "-i", "/storage/emulated/0/Android/data/com.my.package/files/MyVideos/tempShapes.png", "-filter_complex", "[0:v]scale=iw*sar:ih,setsar=1,pad='max(iw\\,2*trunc(ih*47/80/2))':'max(ih\\,2*trunc(ow*80/47/2))':(ow-iw)/2:(oh-ih)/2[v0];[1:v][v0]scale2ref[v1][v0];[v0][v1]overlay=x=(W-w)/2:y=(H-h)/2[v]", "-map", "[v]", "-map", "0:a", "-c:v", "libx264", "-preset", "ultrafast", "-r", "30", "/storage/emulated/0/Android/data/com.my.package/files/MyVideos/video with line.mp4"
这是完整的日志:
ffmpeg version n4.0-39-gda39990 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.9.x (GCC) 20150123 (prerelease)
configuration: --target-os=linux --cross-prefix=/root/bravobit/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/root/bravobit/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-ffprobe --enable-libopus --enable-libvorbis --enable-libfdk-aac --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-libvpx --enable-libass --enable-yasm --enable-pthreads --disable-debug --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-linux-perf --disable-doc --disable-shared --enable-static --enable-runtime-cpudetect --enable-nonfree --enable-network --enable-avresample --enable-avformat --enable-avcodec --enable-indev=lavfi --enable-hwaccels --enable-ffmpeg --enable-zlib --enable-gpl --enable-small --enable-nonfree --pkg-config=pkg-config --pkg-config-flags=--static --prefix=/root/bravobit/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/root/bravobit/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/root/bravobit/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-cxxflags=
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/Android/data/com.my.package/files/CameraTemp/2020_05_24_09_17_53.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2020-05-24T08:18:02.000000Z
Duration: 00:00:01.64, start: 0.000000, bitrate: 20750 kb/s
Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p, 1920x1080, 18056 kb/s, SAR 1:1 DAR 16:9, 29.70 fps, 29.67 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2020-05-24T08:18:02.000000Z
handler_name : VideoHandle
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 155 kb/s (default)
Metadata:
creation_time : 2020-05-24T08:18:02.000000Z
handler_name : SoundHandle
Input #1, png_pipe, from '/storage/emulated/0/Android/data/com.my.package/files/MyVideos/tempShapes.png':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: png, rgba(pc), 1920x1128, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 (h264) -> scale (graph 0)
Stream #1:0 (png) -> scale2ref:default (graph 0)
overlay (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
frame= 0 fps=0.0 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbits/s speed=N/A
frame= 0 fps=0.0 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbits/s speed=N/A
[libx264 @ 0xb83fc8a0] using SAR=1/1
[libx264 @ 0xb83fc8a0] using cpu capabilities: ARMv6 NEON
[libx264 @ 0xb83fc8a0] profile Constrained Baseline, level 4.2
[libx264 @ 0xb83fc8a0] 264 - core 152 r2851M ba24899 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=2 keyint_min=1 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
Output #0, mp4, to '/storage/emulated/0/Android/data/com.my.package/files/MyVideos/video with line.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
encoder : Lavf58.12.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1128 [SAR 1:1 DAR 80:47], q=-1--1, 29 fps, 14848 tbn, 29 tbc (default)
Metadata:
encoder : Lavc58.18.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2020-05-24T08:18:02.000000Z
handler_name : SoundHandle
encoder : Lavc58.18.100 aac
frame= 1 fps=0.4 q=0.0 size= 0kB time=00:00:01.01 bitrate= 0.4kbits/s speed=0.397x
frame= 5 fps=1.6 q=0.0 size= 0kB time=00:00:01.01 bitrate= 0.4kbits/s speed=0.33x
frame= 9 fps=2.5 q=24.0 size= 256kB time=00:00:01.01 bitrate=2075.0kbits/s speed=0.28x
frame= 13 fps=3.1 q=25.0 size= 1024kB time=00:00:01.01 bitrate=8298.9kbits/s speed=0.243x
frame= 18 fps=3.8 q=29.0 size= 2048kB time=00:00:01.01 bitrate=16597.5kbits/s speed=0.214x
frame= 21 fps=3.9 q=25.0 size= 2560kB time=00:00:01.01 bitrate=20746.7kbits/s speed=0.19x
frame= 23 fps=3.9 q=25.0 size= 2816kB time=00:00:01.01 bitrate=22821.4kbits/s speed=0.173x
frame= 26 fps=4.0 q=29.0 size= 3584kB time=00:00:01.01 bitrate=29045.3kbits/s speed=0.156x
Past duration 0.617577 too large
Past duration 0.639641 too large
frame= 28 fps=3.9 q=29.0 size= 3840kB time=00:00:01.01 bitrate=31119.9kbits/s speed=0.142x
Past duration 0.665230 too large
frame= 29 fps=3.8 q=25.0 size= 3840kB time=00:00:01.01 bitrate=31119.9kbits/s speed=0.132x
Past duration 0.690834 too large
Past duration 0.711281 too large
Past duration 0.736885 too large
frame= 32 fps=3.9 q=29.0 size= 4608kB time=00:00:01.01 bitrate=37343.8kbits/s speed=0.123x
Past duration 0.762474 too large
Past duration 0.783577 too large
Past duration 0.807564 too large
frame= 35 fps=3.9 q=25.0 size= 4864kB time=00:00:01.01 bitrate=39418.4kbits/s speed=0.112x
Past duration 0.831551 too large
Past duration 0.855537 too large
frame= 37 fps=3.5 q=25.0 size= 5376kB time=00:00:01.01 bitrate=43567.7kbits/s speed=0.0968x
Past duration 0.879524 too large
Past duration 0.903511 too large
frame= 39 fps=3.4 q=25.0 size= 5376kB time=00:00:01.06 bitrate=41196.6kbits/s speed=0.0927x
Past duration 0.927498 too large
Past duration 0.951500 too large
frame= 41 fps=3.4 q=25.0 size= 5376kB time=00:00:01.13 bitrate=38700.0kbits/s speed=0.0931x
frame= 41 fps=3.2 q=25.0 size= 5376kB time=00:00:01.13 bitrate=38700.0kbits/s speed=0.0886x
frame= 41 fps=3.1 q=25.0 size= 5888kB time=00:00:01.43 bitrate=33554.2kbits/s speed=0.108x
Past duration 0.975487 too large
frame= 45 fps=3.2 q=26.0 size= 6656kB time=00:00:01.60 bitrate=33905.4kbits/s speed=0.114x
frame= 45 fps=3.0 q=-1.0 Lsize= 8158kB time=00:00:01.65 bitrate=40480.7kbits/s speed=0.11x
video:8127kB audio:28kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.032895%
[libx264 @ 0xb83fc8a0] frame I:23 Avg QP:24.70 size:337646
[libx264 @ 0xb83fc8a0] frame P:22 Avg QP:29.00 size: 25250
[libx264 @ 0xb83fc8a0] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 @ 0xb83fc8a0] mb P I16..4: 0.4% 0.0% 0.0% P16..4: 43.6% 0.0% 0.0% 0.0% 0.0% skip:56.0%
[libx264 @ 0xb83fc8a0] coded y,uvDC,uvAC intra: 90.0% 84.7% 58.1% inter: 20.1% 6.2% 0.1%
[libx264 @ 0xb83fc8a0] i16 v,h,dc,p: 25% 28% 28% 20%
[libx264 @ 0xb83fc8a0] i8c dc,h,v,p: 39% 25% 20% 16%
[libx264 @ 0xb83fc8a0] kb/s:42901.20
[aac @ 0xb83d7d10] Qavg: 3517.779
推荐答案
我猜这些设备拒绝播放4.0级以上的内容.1920x1128将超过4.0级.设置 -level
将无济于事,因为它仍然会超过该级别,并且您会收到类似于 frame MB size(120x69)>的警告.上限(8192)
.
I guess these devices refuse to play anything over level 4.0. 1920x1128 will exceed level 4.0. Setting -level
won't help because it will still exceed the level and you'll get a warning similar to frame MB size (120x69) > level limit (8192)
.
Detailed specifications regarding playback support are often hard to find, if they are available at all, but Samsung only states that the Galaxy J7 Pro "Video Playing Resolution: FHD (1920 x 1080)@60fps". I didn't check the Sony Xperia Tablet Z, but since it is from 2012 I wouldn't doubt it is in a similar situation.
这不是您要找的答案,但您可能会被限制为1920x1080或更小.当然我可能是错的.如果您可以找到更详细和有用的信息,请确保使用的是最新的可用操作系统版本,并参考设备规格.
This wasn't the answer you were looking for, but you may be limited to 1920x1080 or lower. Of course I may be wrong. Make sure you're using the latest available OS version and refer the device specs if you can find something more detailed and informative.
这篇关于运行FFmpeg命令后无法播放的视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!