Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
Video rotated using Android ffmpeg Library
12 septembre 2014, par Adroid FreakI'm using Android ffmpeg Library, The library is working fine, the only issue I'm having is that the video is rotated. The original video is rotated by 90 degree, I tried many options by adding them to the library function below, the commented code is a sample of what I tried, I tried many other options but none of them is working.
Anyone of you guys got it to work?
public void processVideo(Clip in, Clip out, boolean enableExperimental, ShellCallback sc) throws Exception { ArrayList
cmd = new ArrayList (); cmd.add(mFfmpegBin); cmd.add("-y"); if (in.format != null) { cmd.add(Argument.FORMAT); cmd.add(in.format); } if (in.videoCodec != null) { cmd.add(Argument.VIDEOCODEC); cmd.add(in.videoCodec); } if (in.audioCodec != null) { cmd.add(Argument.AUDIOCODEC); cmd.add(in.audioCodec); } cmd.add("-i"); cmd.add(new File(in.path).getCanonicalPath()); if (out.videoBitrate > 0) { cmd.add(Argument.BITRATE_VIDEO); cmd.add(out.videoBitrate + "k"); } if (out.width > 0) { cmd.add(Argument.SIZE); cmd.add(out.width + "x" + out.height); } if (out.videoFps != null) { cmd.add(Argument.FRAMERATE); cmd.add(out.videoFps); } if (out.videoCodec != null) { cmd.add(Argument.VIDEOCODEC); cmd.add(out.videoCodec); } if (out.videoBitStreamFilter != null) { cmd.add(Argument.VIDEOBITSTREAMFILTER); cmd.add(out.videoBitStreamFilter); } if (out.videoFilter != null) { cmd.add("-vf"); cmd.add(out.videoFilter); } if (out.audioCodec != null) { cmd.add(Argument.AUDIOCODEC); cmd.add(out.audioCodec); } if (out.audioBitStreamFilter != null) { cmd.add(Argument.AUDIOBITSTREAMFILTER); cmd.add(out.audioBitStreamFilter); } if (out.audioChannels > 0) { cmd.add(Argument.CHANNELS_AUDIO); cmd.add(out.audioChannels+""); } if (out.audioBitrate > 0) { cmd.add(Argument.BITRATE_AUDIO); cmd.add(out.audioBitrate + "k"); } if (out.format != null) { cmd.add("-f"); cmd.add(out.format); } if (enableExperimental) { cmd.add("-strict"); cmd.add("-2");//experimental } // cmd.add("-metadata:s:v rotate=\"0\""); // cmd.add("rotate=\"0\""); cmd.add(new File(out.path).getCanonicalPath()); execFFMPEG(cmd, sc); } This is how I'm using it btw,
FfmpegController fc = new FfmpegController(this, fileTmp); clip_out.videoFps = "30"; clip_out.width = 480; clip_out.height = 320; clip_out.videoCodec = "mpeg4"; clip_out.audioCodec = "copy"; clip_out.videoBitrate = 450; fc.processVideo(clip_in, clip_out, false, new ShellUtils.ShellCallback()
-
FFmpeg av_guess_format returns NULL
12 septembre 2014, par KageI'm following the example code here: http://cekirdek.pardus.org.tr/~ismail/ffmpeg-docs/output-example_8c-source.html
My code is as follows:
fmt = av_guess_format(NULL, filename, NULL); if (!fmt) { LOGE(1,"Could not deduce output format from file extension: using MPEG.\n"); fmt = av_guess_format("mp4", NULL, NULL); } if (!fmt) { LOGE(1, "Could not find suitable output format\n"); exit(1); }
The two times that I call av_guess_format, it is returning NULL both times. I am calling both av_register_all() and avcodec_register_all() beforehand.
Any ideas as to why this is returning NULL?
Thanks in advance.
-
Adding a bitmap over video using ffmpeg for android
11 septembre 2014, par AlinI am stuck in this area which I am not comfortable at all to work in.
Here is what I did so far:
- Made an Ubuntu VirtualBox machine
- Downloaded latest ffmpeg version which is 2.3.3
- Compiled ffmpeg to be compatible with armv7-a so in the end I get two folders: include and lib. In include I have the headers and in libs the *.so files (just as in http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/)
I have created a new android project and made a jni folder and this is how far I went... Even this, with all the struggle being new to linux and compiling took me almost a week to reach.
Adding a watermark in ffmpeg I believe it is done on libavfilter ? I have to dig on this matter, however the original ffmpeg I need to translate into my project is:
ffmpeg -i input.avi -i logo.png -filter_complex 'overlay=10:main_h-overlay_h-10' output.avi
As far as I am studying now I need to do inside jni:
- create a add_watermark.c file in which I need to somehow call the function that does the filter overlay call
create Android.mk to load this and the ffmpeg needed libraries
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := add-watermark
LOCAL_SRC_FILES := add-watermark.c
LOCAL_LDLIBS := -llog -ljnigraphics -lz
LOCAL_SHARED_LIBRARIES := libavformat libavcodec libswscale libavutil
include $(BUILD_SHARED_LIBRARY)
$(call import-module,ffmpeg-2.3.3/android/armv7-a)
create Application.mk
APP_ABI := armeabi-v7a
APP_PLATFORM := android-8
run ndk-build and use the generated libraries in my android project.
I really need help on continuing, so every answer is received with great attention and pleasure.
Later Edit: Would it be possible to somehow build ffmpeg.exe as a library and call its main with the exact same parameters as the original exe ? I do not want to run ffmpeg as a standalone executable, but have it integrated within the project. Something like http://www.roman10.net/how-to-port-ffmpeg-the-program-to-androidideas-and-thoughts/ What downsides would this approach have ?
-
ffmpeg to rip mp3 from mp4 in ruby
11 septembre 2014, par RichardCTrying to make basic Ruby script utilising ffmpeg to download a video from Youtube and then rip the mp3 from that video. Problem is each time the script fails when trying to separate the two, even though the command themselves run fine outside of the. I think the issue is that Ruby is treating the video as a string, but I'm not sure.
def input #print "Enter Video URL: " #@target_video = gets #@target_video ||= '' #@target_video.chomp @target_video = 'https://www.youtube.com/watch?v=bYG1qccSUAw' end def grab #@video = `viddl-rb #{@target_video}` `viddl-rb #{@target_video}` end def rip `ffmpeg -i #{grab} new.mp3` end input rip
I tested it in irb and when I tried
@video.class
it returnedstring
, I think this is where it's going wrong but I'm not certain. The video does download successfully but fails on teh rip.Output and error:
ruby youtube_downloader.rb % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 30.4M 100 30.4M 0 0 2580k 0 0:00:12 0:00:12 --:--:-- 2683k ffmpeg version 2.3.3 Copyright (c) 2000-2014 the FFmpeg developers built on Aug 25 2014 19:47:15 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) configuration: --prefix=/usr/local/Cellar/ffmpeg/2.3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid libavutil 52. 92.100 / 52. 92.100 libavcodec 55. 69.100 / 55. 69.100 libavformat 55. 48.100 / 55. 48.100 libavdevice 55. 13.102 / 55. 13.102 libavfilter 4. 11.100 / 4. 11.100 libavresample 1. 3. 0 / 1. 3. 0 libswscale 2. 6.100 / 2. 6.100 libswresample 0. 19.100 / 0. 19.100 libpostproc 52. 3.100 / 52. 3.100 Loading: No such file or directory sh: line 1: Plugins: command not found sh: line 2: Will: command not found sh: line 3: Analyzing: command not found sh: line 4: Using: command not found sh: line 5: [YOUTUBE]: command not found sh: line 6: [YOUTUBE]: command not found sh: line 7: Using: command not found sh: line 8: Download: command not found sh: line 9: Error:: command not found sh: line 11: Backtrace:: command not found sh: -c: line 12: syntax error near unexpected token `:27:in' sh: -c: line 12: `(eval):27:in `initialize''
-
image sequence to Video. Faster Way to Render "Hold" frames in FFMPEG (without duplicating image)
11 septembre 2014, par dprogramzI'm working on a project that converts a Flash Movie with dynamic input to Apple Animation Codec.
It's to generate messaging, so there is some animation, then the message holds, then animation resumes, etc. The hold times are user variable.
I'm first converting the SWF to PNGs by sending a bitstream via the actionscript3 PNGEncoder library, and using a PHP script to save the bitstream to the server as a series of temp png files. This is working very fast.
from flash ill get an image sequence like this:
frame000.png-frame014.png
frame0200.png-frame250.png
frame350.png-frame400.png
frames 15-199 are all the same image holding. I'm not sending bitstreams for the holding images to save bandwidth and time, it would be redundant to send the same image file 185 times. Right now I am copying frame14.png with incrementing file numbers. I have to do this for each instance there is a hold frame.
After all the hold frame holes are filled I then run FFMPEG on the complete image sequence to generate the video.
Is there any faster way to do this? The longer the hold (which is variable by the user) the longer it takes to render. I understand that there will be some extra render time, but it's a repeated image and in other conversion programs does not take nearly as long. Or is my current way of doing it the only way in this instance?
When rendering out of a program like after effects, the animation codec seems to dynamically adjust the frame rate for hold frames.
Thanks for the help and insight!!