Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
Carrierwave video not being processsed before uploading to S3
12 décembre 2013, par CrampsI'm using Carrierwave, Carrierwave-video and Carrierwave-video-thumbnailer to process videos and make a thumbnail when they're uploaded. This was all working nicely while I was saving the files on my file system. However, now that I've added uploading to Amazon S3 using the carrierwave-aws gem, the videos are being uploaded to S3 without being processed first. It's as if the
process encode_video
andversion :thumb
are being skipped by the uploader.Here's what was working for me at first (before adding S3):
class VideoUploader < CarrierWave::Uploader::Base include CarrierWave::Video include CarrierWave::Video::Thumbnailer storage :file def store_dir "upload/path/" end process encode_video: [{ bunch of video options}] version :thumb do process thumbnail: [{ bunch of thumbnailer options }] def full_filename for_file png_name for_file, version_name end end def png_name for_file, version_name %Q{#{version_name}_#{for_file.chomp(File.extname(for_file))}.png} end
Now it's really just the same, except it's using
storage :aws
instead. -
ffmpeg - Use filter in android
12 décembre 2013, par kikuchiI'm trying to use the movie filter in my android project with ffmpeg. I use a fork of the guardian project : Cheers-dev
It use a recent version of ffmpeg (~15 days old atm). I added the option
--enable-filter=movie
to activate the filter.I use this command line in my android project :
ffmpeg -i input.mp4 -vf "movie=watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:main_h-overlay_h-10 [out]" -strict -2 outputvideo.mp4
It perfectly works with my desktop version on Debian Wheezy. But it's impossible to make it work on my Android. All other commands works.
Here the error when it fails :
No such filter: 'movie'
.I also tested with the option
-filter_complex
with a somewhat different error:$ ffmpeg -y -loglevel debug -i /storage/sdcard0/test/hsgjr_export.mp4 -i /storage/sdcard0/test/watermark.png -filter_complex "[0:v][1:v]overlay=main_w-overlay_w-10:main_h-overlay_h-10[out]" -map [out] -map 0:a -codec:a copy /storage/sdcard0/test/hsgjr_watermark.mp4 ffmpeg version N-58429-gccdfa3e Copyright (c) 2000-2013 the FFmpeg developers built on Dec 10 2013 01:12:39 with gcc 4.4.3 (GCC) configuration: --arch=arm --cpu=cortex-a8 --target-os=linux --enable-runtime-cpudetect --prefix=/data/data/info.guardianproject.ffmpeg/app_opt --enable-pic --disable-shared --enable-static --cross-prefix=/opt/android/ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi- --sysroot=/opt/android/ndk-r8/platforms/android-14/arch-arm --extra-cflags='-I../x264 -I/Android/cheers/android-ffmpeg/data/data/info.guardianproject.ffmpeg/app_opt/include -mfloat-abi=softfp -mfpu=neon' --extra-ldflags='-L../x264 -L/Android/cheers/android-ffmpeg/data/data/info.guardianproject.ffmpeg/app_opt/lib' --enable-version3 --enable-gpl --enable-yasm --enable-decoders --enable-encoders --enable-muxers --enable-demuxers --enable-parsers --enable-protocols --enable-filter=movie --enable-avresample --enable-libvorbis --disable-indevs --enable-indev=lavfi libavutil 52. 54.100 / 52. 54.100 libavcodec 55. 44.100 / 55. 44.100 libavformat 55. 21.101 / 55. 21.101 libavdevice 55. 5.100 / 55. 5.100 libavfilter 3. 91.100 / 3. 91.100 libavresample 1. 1. 0 / 1. 1. 0 libswscale 2. 5.101 / 2. 5.101 libswresample 0. 17.104 / 0. 17.104 libpostproc 52. 3.100 / 52. 3.100 Splitting the commandline. Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'. Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'. Reading option '-i' ... matched as input file with argument '/storage/sdcard0/test/hsgjr_export.mp4'. Reading option '-i' ... matched as input file with argument '/storage/sdcard0/test/watermark.png'. Reading option '-filter_complex' ... matched as option 'filter_complex' (create a complex filtergraph) with argument '"[0:v][1:v]overlay=main_w-overlay_w-10:main_h-overlay_h-10[out]"'. Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '[out]'. Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '0:a'. Reading option '-codec:a' ... matched as option 'codec' (codec name) with argument 'copy'. Reading option '/storage/sdcard0/test/hsgjr_watermark.mp4' ... matched as output file. Finished splitting the commandline. Parsing a group of options: global . Applying option y (overwrite output files) with argument 1. Applying option loglevel (set logging level) with argument debug. Applying option filter_complex (create a complex filtergraph) with argument "[0:v][1:v]overlay=main_w-overlay_w-10:main_h-overlay_h-10[out]". Successfully parsed a group of options. Parsing a group of options: input file /storage/sdcard0/test/hsgjr_export.mp4. Successfully parsed a group of options. Opening an input file: /storage/sdcard0/test/hsgjr_export.mp4. [mov,mp4,m4a,3gp,3g2,mj2 @ 0x1274cd0] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x1274cd0] ISO: File Type Major Brand: isom [mov,mp4,m4a,3gp,3g2,mj2 @ 0x1274cd0] File position before avformat_find_stream_info() is 1196725 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x1274cd0] All info found [mov,mp4,m4a,3gp,3g2,mj2 @ 0x1274cd0] File position after avformat_find_stream_info() is 30451 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/sdcard0/test/hsgjr_export.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf55.21.101 Duration: 00:00:00.96, start: 0.000000, bitrate: 9972 kb/s Stream #0:0(und), 1, 1/1200000: Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 1/2400000, 9830 kb/s, 25 fps, 25 tbr, 1200k tbn, 2400k tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und), 1, 1/48000: Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default) Metadata: handler_name : SoundHandler Successfully opened the file. Parsing a group of options: input file /storage/sdcard0/test/watermark.png. Successfully parsed a group of options. Opening an input file: /storage/sdcard0/test/watermark.png. [AVIOContext @ 0x12870f0] Statistics: 26515 bytes read, 0 seeks Input #1, image2, from '/storage/sdcard0/test/watermark.png': Duration: 00:00:00.04, start: 0.000000, bitrate: N/A Stream #1:0, 1, 1/25: Video: png, rgba, 400x170, 1/25, 25 tbr, 25 tbn, 25 tbc Successfully opened the file. Parsing a group of options: output file /storage/sdcard0/test/hsgjr_watermark.mp4. Applying option map (set input stream mapping) with argument [out]. Applying option map (set input stream mapping) with argument 0:a. Applying option codec:a (codec name) with argument copy. Successfully parsed a group of options. Opening an output file: /storage/sdcard0/test/hsgjr_watermark.mp4. [AVFilterGraph @ 0x127d5f0] No such filter: '"' Error configuring filters. [AVIOContext @ 0x127d2b0] Statistics: 67296 bytes read, 2 seeks
The output is better than the previous one but I think I'm missing something.
SOLUTION : I removed the quote from the filter_complex argument and it worked.
Here is the working command :
$ ffmpeg -y -i /storage/sdcard0/test/hsgjr_export.mp4 -i /storage/sdcard0/test/watermark.png -filter_complex [0:v][1:v]overlay=main_w-overlay_w-10:main_h-overlay_h-10[out] -map [out] -map 0:a -codec:a copy /storage/sdcard0/test/hsgjr_watermark.mp4
-
Android Encode h264 using libavcodec for ARGB
12 décembre 2013, par nmxprimeI have a stream of buffer content which actually contains 480x800 sized ARGB image[byte array of size 480*800*4]. i want to encode around 10,000s of similar images into a stream of h.264 at specified fps(12). this shows how to encode images into encoded video,but requires input to be yuv420.
Now i have ARGB images, i want to encode into CODEC_ID_H264 How to convert RGB from YUV420p for ffmpeg encoder? shows how to do it for rgb24, but how to do it for rgb32,meaning ARGB image data
how do i use libavcodec for this?
EDIT: i found How to convert RGB from YUV420p for ffmpeg encoder? But i don't understand.
From the 1st link, i come to know that AVFrame struct contains data[0],data1,data[2] which are filled with Y, U & V values.
In 2nd link, they showed how to use sws_scale to convert RGB24 to YUV420 as such
SwsContext * ctx = sws_getContext(imgWidth, imgHeight, AV_PIX_FMT_RGB24, imgWidth, imgHeight, AV_PIX_FMT_YUV420P, 0, 0, 0, 0); uint8_t * inData[1] = { rgb24Data }; // RGB24 have one plane int inLinesize[1] = { 3*imgWidth }; // RGB stride sws_scale(ctx, inData, inLinesize, 0, imgHeight, dst_picture.data, dst_picture.linesize)
Here i assume that rgb24Data is the buffer containing RGB24 image bytes.
So how i use this information for ARGB, which is 32 bit? Do i need manually to strip-off the alpha channel or any other work around ?
Thank you
-
What is the best way to write videos captured from webcam by OpenCV ?
12 décembre 2013, par T.S.I have started using OpenCV with python recently and upon using this method to write a video file I was not content as 10 seconds of video were resulting in 1GB files.
What is the recommended way to do it? Use external tools like ffmpeg is something considered good practice for this type of thing?
-
Add Timestamp to extracted thumbnail's name from a video file
12 décembre 2013, par Harish VaradaI have a requirement of generating thumbnails(camera change, slide change, scene change) from a videofile with it's timestamp(pos) included in the generated output thumbnails.
I used the following command to generate thumbnails:
ffmpeg -i input.mp4 -vf select="eq(pict_type\,I)" -vsync 0 -an keyframe-%06d.png
This command works absolutely fine for generating thumbnails (assume 15 thumbnails are generated) with names in sequence like: keyframe-000001.png, keyframe-000002.png, .... , keyframe-000015.png.
But, according to my requirement, I need the output thumbnail file names something like as follows:
keyframe-001426.png, keyframe-002769.png, .... , keyframe-014571.png where
001426 is the position of thumbnail keyframe-000001.png
002769 is the position of thumbnail keyframe-000002.png
014571 is the position of thumbnail keyframe-000015.png
Is there a way to achieve this in a single command.? Please help me out achieving this.