Android端FFmpeg blend滤镜向下揭幕转场异常问题求助
Let's break down your issue and work through a solution. Your downward curtain transition works perfectly on Windows but misbehaves on the Samsung S4 running Android 4.4.2, and the log hints at pixel format compatibility problems. Here's what's going wrong and how to fix it:
Key Clues from Your Log
The repeated warning is the main red flag:
[swscaler @ 0x438292b0] deprecated pixel format used, make sure you did set range correctly
Your input JPEGs are decoded as yuvj420p—a full-range YUV format that older Android frameworks (like 4.4.2) struggle to handle reliably. On top of that, your FFmpeg version (n3.0.1, 2016) has known quirks with expression handling and ARM device compatibility.
Revised FFmpeg Command (Fixed for Android)
I've adjusted your command to address these compatibility gaps. Here's the updated version:
ffmpeg -loop 1 -t 1 -r 24 -i img001.jpg \ -loop 1 -t 1 -r 24 -i img002.jpg \ -loop 1 -t 1 -r 24 -i img003.jpg \ -loop 1 -t 1 -r 24 -i img004.jpg \ -loop 1 -t 1 -r 24 -i img005.jpg \ -filter_complex " [0:v]format=yuv420p[v0]; [1:v]format=yuv420p[v1]; [2:v]format=yuv420p[v2]; [3:v]format=yuv420p[v3]; [4:v]format=yuv420p[v4]; [v1][v0]blend=all_expr='if(lte(Y,(N*H)/24),A,B)'[b1v]; [v2][v1]blend=all_expr='if(lte(Y,(N*H)/24),A,B)'[b2v]; [v3][v2]blend=all_expr='if(lte(Y,(N*H)/24),A,B)'[b3v]; [v4][v3]blend=all_expr='if(lte(Y,(N*H)/24),A,B)'[b4v]; [v0][b1v][v1][b2v][v2][b3v][v3][b4v][v4]concat=n=9:v=1:a=0,format=yuv420p[v] " -map "[v]" -c:v libx264 -profile:v baseline -level 3.0 out_cover_top.mp4 -y
What Changed & Why
Standardized Pixel Format
- Added
format=yuv420pto each input stream. This converts the deprecatedyuvj420pformat to limited-range YUV420p, which Android 4.4.2 handles consistently. This eliminates the swscaler warnings and ensures uniform pixel data throughout the pipeline.
- Added
Stable Integer Arithmetic in Blend Expression
- Modified
N*H/24to(N*H)/24. Older FFmpeg builds on ARM have floating-point precision issues; wrapping the multiplication in parentheses forces integer math, making the Y-coordinate threshold calculation accurate for every frame of the transition.
- Modified
Android-Optimized Encoding
- Added
-c:v libx264 -profile:v baseline -level 3.0. The Samsung S4 natively supports H.264 Baseline Profile (Level 3.0), so this ensures the output video plays smoothly without decoding errors.
- Added
Consistent Frame Rate
- Added
-r 24to each input. This aligns the frame rate with your transition logic (24 frames per 1-second slide), so theNvariable in the blend expression maps exactly to the number of frames, making the animation smooth and predictable.
- Added
Extra Troubleshooting Tips
If you still run into issues:
- Update FFmpeg: Version 3.0.1 is outdated. Compile a newer static build (e.g., 4.4+ with ARM optimizations) — many filter and pixel format bugs have been fixed in later releases.
- Verify Image Consistency: Double-check that all input images are the exact same size (your log shows 480x480, which is ideal — mismatched sizes can break blending logic).
- Test with a Simplified Command: Try a two-image transition first to isolate the issue, then scale up to five images once that works.
内容的提问来源于stack exchange,提问作者tainguyen

