Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
Surfaceview 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: 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.
-
Download video from a url [on hold]
27 mai 2018, par Emilio MaingiI'm writing a program to download a video when given a link to the video. From my research i have learned that i am supposed to use ffmpeg to do the conversion and download. But my ffmpeg does not execute. I have tried shell_exec() and exec() but none of them seem to be working. Can somebody help me with some guidelines to get the videos downloadable from any video site like youtube, vimeo, twitch tv. I'll appreciate any ideas that will come through. Thanks
-
FFmpeg file not found exception
26 mai 2018, par Sagar HudgeI am getting following exception on video trimming.
video path :
/storage/emulated/0/Pictures/Instagram/Fast & Furious 7 - Get Low Extended Version Video.mp4
file name :
Fast & Furious 7 - Get Low Extended Version Video.mp4
and ffmpeg searching for only
Fast
in/storage/emulated/0/Pictures/Instagram/Fast: No such file or directory
I have found the issue ,it is causing due to the file name having spaces in between them you can check in above mentioned path and in exception.
after changing file name its working but changing name of every file from device its not the right way so how can I solve this exception
FAILED with output : WARNING: linker: /data/user/0/com.example.SeekBarActivity/files/ffmpeg has text relocations. This is wasting memory and prevents security hardening. Please fix. ffmpeg version n2.4.2 Copyright (c) 2000-2014 the FFmpeg developers built on Oct 7 2014 15:08:46 with gcc 4.8 (GCC) configuration: --target-os=linux --cross-prefix=/home/sb/Source-Code/ffmpeg- android/toolchain-android/bin/arm-linux-androideabi- --arch=arm -- cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/sb/Source- Code/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --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/sb/Source-Code/ffmpeg-android/ffmpeg-pkg-config -- prefix=/home/sb/Source-Code/ffmpeg-android/build/armeabi-v7a-neon --extra- cflags='-I/home/sb/Source-Code/ffmpeg-android/toolchain-android/include - U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector- all -mfpu=neon' --extra-ldflags='-L/home/sb/Source-Code/ffmpeg- android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='- lpng -lexpat -lm' --extra-cxxflags= libavutil 54. 7.100 / 54. 7.100 libavcodec 56. 1.100 / 56. 1.100 libavformat 56. 4.101 / 56. 4.101 libavdevice 56. 0.100 / 56. 0.100 libavfilter 5. 1.100 / 5. 1.100 libswscale 3. 0.100 / 3. 0.100 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 0.100 / 53. 0.100 /storage/emulated/0/Pictures/Instagram/Fast: No such file or directory
-
I'm trying to use FFmpeg with command prompt in my python program, but it doesnt execute [on hold]
26 mai 2018, par MilkToastI've tried to do it a bunch of different ways but each time it execute. The line works fine in the command prompt, but I cant get it to work from python.
check_output(r"ffmpeg -i C:\Users\jared\Desktop\Rev\videosnshit\howto.mp4 -vn -ar 44100 -ac 1 -b:a 32k -f wav audio.wav", shell=True)
// This is the bit that works fine in command prompt:
ffmpeg -i C:\Users\jared\Desktop\Rev\videosnshit\howto.mp4 -vn -ar 44100 -ac 1 -b:a 32k -f wav audio.wav
I'm probably being dumb, so any help would be great! thanks!
-
ffmpeg live webcam colorkey subtraction and dispaly feed on desktop (with subtracted color transparent/desktop see through visible))
26 mai 2018, par VijPurpose: I want to create instructional video lectures using laptop webcam and presentation slides. Here I should be visible in bottom right corner of desktop in small screen or full screen explaining slides. (like TV weather report).
What I seek: Is there any way to apply colorkey to live webcam video to subtract background (greenscreen) so that desktop is visible through the top webcam borderless video window.(Then record everything on desktop)
What I have done: I have been successful in overlaying colorkeyed live webcam video and X11grab :0.0 and saving the output in a video file.
ffmpeg -f x11grab -thread_queue_size 64 -video_size 1024X600 -framerate 30 -i :0.0 -f v4l2 -thread_queue_size 64 -video_size 320X180 -framerate 30 -i /dev/video0 -filter_complex '[1:v]colorkey=0x000000:0.1:0[ckout];[0:v][ckout] overlay=main_w-overlay_w:main_h-overlay_h:format=yuv444' -vcodec libx264 -preset ultrafast -qp 0 -pix_fmt yuv444p video.mp4
But this is not I want. Because this way I cannot see what actually is happening on desktop and where should I point on the slide (lack of instructional control).
I also successfully piped this composite output through ffplay [ - | ffplay -i -] but it creates a mirror in mirror effect so thus useless.
What I expect: I just want to apply ffmpge colorkey to the webcam feed /dev/video0 and display color subtracted output on desktop so that the subtracted region in the video player (ffplay/mplayer) should appear transparent and desktop should be visible (video player should preserve alpha channel and appear transparent in colorkeyed region). (weatherman effect).
Roughly I am looking for ffmpeg {-i /dev/video0} {colorkry[ckout]} {-| ffplay -i - } or { - | mplayer} -
Note: I know openbroadcaster can do this job, I tried to install it but it does not execute citing "Failed to initialize video. Your GPU may not be supported, or your graphics drivers may need to be updated." I have a old laptop 2GB RAM and Atom processor running Xubuntu 16.04. probably openbroadcaster cant support.
As I have successfully oberlayed colorkeyed webcam feed with X11grab (with maximum 50% cpu usage) I think it is easily possible to do live webcam colerkey subtraction with available resources.
Please give suggestions.