Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
Surfaceview/TextureView for subtitles alpha does not work
27 mai 2018, par user654628Goal: trying to build video player with subtitles for android. Video can be low resolution but the subtitles should be resolution of phone (such that if video is 720p, the subtitles should render to screen size say 1080p).
Issue: Render on Textureview or Surfaceview is not see through where you could get it to blend with the background views. I am using FFMPEG to render a frame at say 720p but phone device is 1080p. I need to display subtitles that are different resolution than the subtitles resolution so pixel blending is difficult.
I first tried to scale the frame (AVFrame) with sws_convert but each frame took 80ms so that is not an option (since it is running software).
Then I tried two surface views, one for the video and one for subtitles where video would be 720p and subtitles SurfaceView is 1080p, then the video scales up to the phone size. The issue here is that the subtitles are not translucent. Black opacity 0 would be transparent but white with alpha 0 is still white. Why is this?
//Code from Java, the view that extends FrameLayout public VideoView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mVideoSurface = new SurfaceView(context); mSubtitlesSurface = new SurfaceView(context); addView(mVideoSurface); addView(mSubtitlesSurface); mVideoSurface.getHolder().addCallback(mSurfaceCallback); mSubtitlesSurface.getHolder().addCallback(mSurfaceCallback); mSubtitlesSurface.setZOrderMediaOverlay(true); mSubtitlesSurface.getHolder().setFormat(PixelFormat.TRANSLUCENT); //etc }
Eventually I tried as a test to render a square to the subtitle surface view (C++)
// Render the video frame, now render the subtitle frame ANativeWindow_Buffer buffer; ANativeWindow_setBuffersGeometry(subWindow, width, height, WINDOW_FORMAT_RGBA_8888); if ((ret = ANativeWindow_lock(subWindow, &buffer, NULL)) < 0) { return ret; } for (int j = height/2; j < height/2 + 100; j++) { for (int i = width/2; i < width/2 + 100; i++) { uint8_t * d = (uint8_t*)buffer.bits + j * (buffer.stride * 4) + i * 4; d[0] = 0xff; d[1] = 0xff; d[2] = 0xFF; d[3] = 0; /* alpha */ } } ANativeWindow_unlockAndPost(subWindow);
So above code should render a white square in the image with 0 alpha (so should be invisible), but it is shown. If I change it to yellow with alpha 0 it will be visible but not the correct color. If I change to white with 1 alpha, it is white and opaque. If I use black with alpha 0xCC, it is invisible, only if alpha is 0xFF then it is visible as black. Seems to have no translucency even though I added it to the SurfaceHolder. Why is it like this? I can add more code if needed.
Is my only option to do what I want to render frame as a texture in OpenGL and (GLSurfaceView), resize the image to phone resolution and blend the alpha subtitles onto the frame as a texture?
Thanks in advance.
-
ffmpeg on ubuntu - how to stop recording the video ?
27 mai 2018, par DcbnvnI use program ffmpeg to record video from screen:
ffmpeg -f x11grab -r 15 -s 1280x1024 -i :1 -vcodec h264 -crf 30 -fs 600000 -y myvideo.mp4 -nostdin -nostats < /dev/null > /dev/null 2>&1 &
I set option -fs (from help: -fs limit_size set the limit file size in bytes)
The recording is executing in background
My question is - Is there any command in ffmpeg, that allows to stop recording ? I call ffmpeg from bash script and after that I invoke other script, so I need to stop recording exactly after second script executed.
-
FFMPEG video cropping is too slow
27 mai 2018, par daliI am using WritingMinds library to execute this ffmpeg command:
-y -i /data/user/0/ae.alphaapps.rombeye/cache/1527414847451.mp4 -vf crop=720:880:0:196 -threads 16 -preset ultrafast -strict -2 -c:v libx264 -c:a copy /storage/emulated/0/.temp/15274148557981952135171779784555.mp4
my main goal is to crop a 720p resolution video as fast as possible, but it's taking about 6 minutes for a 5 minutes video. Is it normal at this rate? and would it be any way to make it faster? Is there any other solution that make video cropping faster?
-
FFmpeg concat video command error
27 mai 2018, par Akash RatanparaI got following error while trying to concat two videos using ffmpeg command in my android application.
Error:
"Input link in1:v0 parameters (size 1920x1080, SAR 1:1) do not match the corresponding output link in0:v0 parameters (1280x720, SAR 1:1)"
Please help how to resolve this error.
-
FFMPEG video cropping on android is too slow
27 mai 2018, par daliI am using WritingMinds library to execute this ffmpeg command:
-y -i /data/user/0/ae.alphaapps.rombeye/cache/1527408886988.mp4 -vf crop=720:880:0:196 -threads 16 -c:v libx264 -maxrate 1984k -bufsize 3968k -ac 2 -vf format=yuv420p -g 60 -c:a aac -b:a 128k -ar 44100 -movflags +faststart -profile:v baseline -level 3.1 -crf 28 -preset ultrafast -strict -2 /storage/emulated/0/.temp/1527408887235-3802129611483385187.mp4
my main goal is to crop a 720p resolution video as fast as possible, but it's taking about 6 minutes for a 5 minutes video. Is it normal at this rate? and would it be any way to make it faster? Is there any other solution that make video cropping faster?