Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
To create an android app where I am able to add color filters to a recorded video
27 novembre 2014, par Ramesh KannanI'm trying to create an app where I am able to add color filters to a recorded video.
I've done research and I can't piece it all together. I've looked into using OpenCV to record a video. The problem is, when I use the sample APK in OpenCV it trigger out the camera and color effects are applied simultaneously then stored as a picture but what I need is after recording the video to apply color effects in the preview mode. I don't know how to implement OpenCV in my android application.
I've also heard about "ffmpeg" which is an open-source platform for recording, converting, playing and streaming video and audio but I didn't get any idea to implement it to my project.
Lastly, I've looked into OpenCV. Tried using OpenCV, but I haven't had much either.
Do you have steps / procedures / code / example on integrating video filters (FFMPEG) on Android for the following needs.
- I used to record the video,
- then dividing it as frames and apply filters.
-
Android scale video faster like whatsapp [on hold]
27 novembre 2014, par user2740131I have tried FFMPEG to scale my video via following command.
"ffmpeg -i -vcodec libx264 -vprofile high -preset ultrafast -b:v 1000k -maxrate 1000k -bufsize 2000k -vf scale=-1:360 -threads 0 -acodec aac -strict experimental -ab 96k
But it takes very long time. to scale 1 minuit full HD video it take more then 4 minuits. I need to make it faster like whatsapp. it takes some second to reduce video size.
-
What would be the best strategy to take a RTP stream and send it to an RTMP server ?
27 novembre 2014, par matiasinsaurraldeI'm receiving a RTP/UDP from a hardware encoder, I have tried ffmpeg, so it takes this input and outputs the stream as FLV (it's being sent to NGINX, nginx-rtmp-module). However I'm not able to play the stream smoothly once it's received by nginx, some frames are broken or lost, etc.
I think that my CPU is too slow for this format change (FLV) and/or ffmpeg is missing a lot of RTP packets. Any ideas?
-
Create thumbnail from video using ffmpeg
27 novembre 2014, par hiteshI need to create a thumbnail from video while uploading it to CDN.
I have been searching for this found this but I am not able to get the screen shot even after following steps.
I am using jwplayer for playing video
Can someone help me to create thumbnail while uploading video using ffmpeg
-
Image to MPEG on Linux works, same code on Android = green video
27 novembre 2014, par JScoobyCedEDIT
I have check the execution and found that the error is not (yet) at the swscale point. My current issue is that the JPG image is not found:
No such file or directory
when doing theavformat_open_input(&pFormatCtx, imageFileName, NULL, NULL);
Before you tell me I need to register anything, I can tell I already did (I updated the code below).
I also added the Android permission to access the external storage (I don't think it is related to Android since I can already write to the /mnt/sdcard/ where the image is also located)
END EDITI have been through several tutorials (including the few posted from SO, i.e. http://dranger.com/ffmpeg/, how to compile ffmpeg for Android...,been through dolphin-player source code). Here is what I have:
. Compiled ffmpeg for android
. Ran basic tutorials using NDK to create a dummy video on my android device
. been able to generate a MPEG2 video from images on Ubuntu using a modified version of dummy video code above and a lot of Googling
. running the new code on Android device gives a green screen video (duration 1 sec whatever the number of frames I encode)I saw another post about iPhone in a similar situation that mentioned the ARM processor optimization could be the culprit. I tried a few ldextra-flags (-arch armv7-a and similar) to no success.
I include at the end the code that loads the image. Is there something different to do on Android than on linux? Is my ffmpeg build not correct for Android video encoding?
void copyFrame(AVCodecContext *destContext, AVFrame* dest, AVCodecContext *srcContext, AVFrame* source) { struct SwsContext *swsContext; swsContext = sws_getContext(srcContext->width, srcContext->height, srcContext->pix_fmt, destContext->width, destContext->height, destContext->pix_fmt, SWS_FAST_BILINEAR, NULL, NULL, NULL); sws_scale(swsContext, source->data, source->linesize, 0, srcContext->height, dest->data, dest->linesize); sws_freeContext(swsContext); } int loadFromFile(const char* imageFileName, AVFrame* realPicture, AVCodecContext* videoContext) { AVFormatContext *pFormatCtx = NULL; avcodec_register_all(); av_register_all(); int ret = avformat_open_input(&pFormatCtx, imageFileName, NULL, NULL); if (ret != 0) { // ERROR hapening here // Can't open image file. Use strerror(AVERROR(ret))) for details return ERR_CANNOT_OPEN_IMAGE; } AVCodecContext *pCodecCtx; pCodecCtx = pFormatCtx->streams[0]->codec; pCodecCtx->width = W_VIDEO; pCodecCtx->height = H_VIDEO; pCodecCtx->pix_fmt = PIX_FMT_YUV420P; // Find the decoder for the video stream AVCodec *pCodec = avcodec_find_decoder(pCodecCtx->codec_id); if (!pCodec) { // Codec not found return ERR_CODEC_NOT_FOUND; } // Open codec if (avcodec_open(pCodecCtx, pCodec) < 0) { // Could not open codec return ERR_CANNOT_OPEN_CODEC; } // AVFrame *pFrame; pFrame = avcodec_alloc_frame(); if (!pFrame) { // Can't allocate memory for AVFrame return ERR_CANNOT_ALLOC_MEM; } int frameFinished; int numBytes; // Determine required buffer size and allocate buffer numBytes = avpicture_get_size(PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height); uint8_t *buffer = (uint8_t *) av_malloc(numBytes * sizeof (uint8_t)); avpicture_fill((AVPicture *) pFrame, buffer, PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height); AVPacket packet; int res = 0; while (av_read_frame(pFormatCtx, &packet) >= 0) { if (packet.stream_index != 0) continue; ret = avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet); if (ret > 0) { // now, load the useful info into realPicture copyFrame(videoContext, realPicture, pCodecCtx, pFrame); // Free the packet that was allocated by av_read_frame av_free_packet(&packet); return 0; } else { // Error decoding frame. Use strerror(AVERROR(ret))) for details res = ERR_DECODE_FRAME; } } av_free(pFrame); // close codec avcodec_close(pCodecCtx); // Close the image file av_close_input_file(pFormatCtx); return res; }
Some ./configure options:
--extra-cflags="-O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 -mfloat-abi=softfp -mfpu=vfp -marm -march=armv7-a -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE"
--extra-ldflags="-Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib -lc -lm -ldl -llog"
--arch=armv7-a --enable-armv5te --enable-armv6 --enable-armvfp --enable-memalign-hack