Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
How is video decoding corruption debugged ?
20 novembre 2013, par TopGunCoderI just started working for a new company and my new role demands that I help debug the video corruption that they are receiving through decoding frames. As much as I intend on digging down deep into the code and looking into the specifics of my problem, it made me think about video debugging in general.
Since handling videos is very new to me, the whole process seems pretty complex and it seems there are a lot of places for corruption to present itself. The way I see it there is at least three places where corruption could pop up (barring memory corruption from the machine):
- Transporting the data before it is decoded
- decoding implementation that perpetuates corruption once it is encountered, or is all together incorrect (Which seems to be my problem)
- Transportation to the monitor(which seems unlikely but possible)
So what i'm really curious about is if/how people debug their video streams to determine the location of any potential corruption they are encountering. I'm sure there is no sure fire method but I am curious to see what problems are even possible and how they can be identified and triaged.
P.S. - I'm not sure of the differences between different decoding methods but, if this question seems too vague maybe it helps to mention I am using
ffmpeg
andavcodec_decode_video2
for the decoding. -
OS X Mavericks broken OpenCV VideoCapture frame numbers ?
20 novembre 2013, par MattPFresh install of Mavericks, managed to install ffmpeg via homebrew and compile the latest OpenCV at time of writing. My code is written in Python (though this shouldn't affect this issue) and basically navigates a video file using the
VideoCapture
class with the properties set frame position and get current position.The issue is, on prior versions of OS X, various Linux and Windows boxes, this works without issue. Each frame number is of the format i.0, where i is the current frame number (why it is a float anyway is confusing, alas it's how OpenCV gives it back). However, on this setup I get frame progressions like:
0.0 -> 1.3972597329753 -> 2.999999999 -> 3.9999999 -> 5.0 -> 6.252323552
This makes using the properties for getting / setting the current frame position impossible and, as one would imagine, causes the automated playback thereof to fail. I can only assume ffmpeg is reporting things odd such that OpenCV is incorrectly calculating frames, but have been unable to rectify this.
Has anyone any insight into the problem, and/or possible solution? Thanks.
-
Android FFmpeg sometimes works and sometimes crashes
20 novembre 2013, par Pawel CalaI compiled FFmpeg for Android ( https://gitorious.org/android-ffmpeg ) but when I'm trying to do some operations ( f.e filters cropping, transpose, trim etc ) it crashes in 5 on 10 cases. Error logs are not the same so I assume that it might be caused by memory issues. I'm using OSX, NDK android-ndk-r9b : darwing x86_64. Native ffmpeg method is passing args to ffmpeg.c main method. It's executed in AsyncTask in Activity. Thanks in advance
EDIT: I forgot to mention that programs algorithm runs like that: Press Button - > Open Camera Intent - > Start recording - > After recording copy file to project folder ( on SD card ) - > Open edit activity + Start asynctask
EDIT2: Tested on HTC ONE with different video resolutions
Version and config of ffmpeg
11-20 12:15:23.001: I/ff-log(19091): ffmpeg version 0.10.2.git 11-20 12:15:23.001: I/ff-log(19091): Copyright (c) 2000-2012 the FFmpeg developers 11-20 12:15:23.001: I/ff-log(19091): built on Nov 20 2013 12:12:46 with gcc 4.6 20120106 (prerelease) 11-20 12:15:23.001: I/ff-log(19091): configuration: --target-os=linux --cross-prefix=arm-linux-androideabi- --arch=arm --cpu=armv7-a --disable-ffplay --disable-ffserver --disable-network --disable-avdevice --enable-protocol=file --enable-hwaccel=mpeg4_vaapi --enable-hwaccel=h264_vaapi --sysroot=/Users/dpc/Developer/android-ndk-r9b/platforms/android-9/arch-arm --disable-decoder=h264_vdpau --prefix=build/armv7-a --disable-asm --enable-small --disable-everything --enable-decoder=mjpeg --enable-parser=mjpeg --enable-muxer=mp4 --enable-muxer=h264 --enable-muxer=h263 --enable-muxer=yuv4mpegpipe --enable-muxer=mov --enable-demuxer=mpegvideo --enable-demuxer=mjpeg --enable-demuxer=image2 --enable-demuxer=mp4 --enable-demuxer=aac --enable-demuxer=ac3 --enable-demuxer=mp3 --enable-demuxer=yuv4mpegpipe --enable-demuxer=mov --enable-decoder=mpegvideo --enable-decoder=mpeg4 --enable-decoder=mp3 --enable-decoder=ac3 --enable-decoder=aac --enable-decoder=h264 --enable-decoder=h263 --enable-decoder=rawvideo --enable-decoder=yuv4 --enable-decoder=png --enable
Sample comand:
1-20 12:15:22.991: I/FFMPEG(19091): CMD:-i file:/storage/emulated/0/.project/videos/mac_video_tmp.mp4 -vf crop=1079:1079:0:420 -vcodec mpeg4 -sameq -acodec copy file:/storage/emulated/0/.project/videos/croppedVid.mp4
Some output errors:
1st type:
11-20 12:15:23.011: I/ff-log(19091): libavutil 51. 46.100 / 51. 46.100 11-20 12:15:23.011: I/ff-log(19091): libavcodec 54. 14.101 / 54. 14.101 11-20 12:15:23.011: I/ff-log(19091): libavformat 54. 3.100 / 54. 3.100 11-20 12:15:23.011: I/ff-log(19091): libavfilter 2. 70.100 / 2. 70.100 11-20 12:15:23.011: I/ff-log(19091): libswscale 2. 1.100 / 2. 1.100 11-20 12:15:23.011: I/ff-log(19091): libswresample 0. 11.100 / 0. 11.100 11-20 12:15:23.011: I/ff-log(19091): before parsing options 11-20 12:15:23.011: I/ff-log(19091): before parsing options 11-20 12:15:23.011: I/ff-log(19091): parse options 11-20 12:15:23.011: I/ff-log(19091): prepare app arguments !!! NOT defined(_WIN32) && !defined(__MINGW32CE__) ! 11-20 12:15:23.011: I/ff-log(19091): after prepare app arguments 11-20 12:15:23.011: I/ff-log(19091): ffurl_open: file:/storage/emulated/0/.project/videos/mac_video_tmp.mp4, 1 11-20 12:15:23.011: I/ff-log(19091): ffurl_alloc: file:/storage/emulated/0/.project/videos/mac_video_tmp.mp4, 1 11-20 12:15:23.011: I/ff-log(19091): ffurl_alloc: file 11-20 12:15:23.011: I/ff-log(19091): ffurl_open alloc: 0 11-20 12:15:23.011: I/ff-log(19091): ffurl_connect 11-20 12:15:23.011: I/ff-log(19091): ffurl_open connect: 0 11-20 12:15:23.011: I/ff-log(19091): Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100 11-20 12:15:23.011: I/ff-log(19091): ISO: File Type Major Brand: isom 11-20 12:15:23.021: I/ff-log(19091): File position before avformat_find_stream_info() is 8458240 11-20 12:15:23.041: A/libc(19091): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 19091 (t.android.utils)
Second type:
11-20 12:17:04.800: I/ff-log(19632): libavutil 51. 46.100 / 51. 46.100 11-20 12:17:04.800: I/ff-log(19632): libavcodec 54. 14.101 / 54. 14.101 11-20 12:17:04.800: I/ff-log(19632): libavformat 54. 3.100 / 54. 3.100 11-20 12:17:04.800: I/ff-log(19632): libavfilter 2. 70.100 / 2. 70.100 11-20 12:17:04.800: I/ff-log(19632): libswscale 2. 1.100 / 2. 1.100 11-20 12:17:04.800: I/ff-log(19632): libswresample 0. 11.100 / 0. 11.100 11-20 12:17:04.800: I/ff-log(19632): before parsing options 11-20 12:17:04.800: I/ff-log(19632): before parsing options 11-20 12:17:04.800: I/ff-log(19632): parse options 11-20 12:17:04.800: I/ff-log(19632): prepare app arguments !!! NOT defined(_WIN32) && !defined(__MINGW32CE__) ! 11-20 12:17:04.800: I/ff-log(19632): after prepare app arguments 11-20 12:17:04.800: I/ff-log(19632): opt_output_file ܞ�f��f��f��f���flated/0/.project/videos/mac_video_tmp.mp4 11-20 12:17:04.800: I/ff-log(19632): ffurl_alloc: ܞ�f��f��f��f���flated/0/.project/videos/mac_video_tmp.mp4, 0 11-20 12:17:04.800: I/ff-log(19632): ffurl_alloc: file 11-20 12:17:04.800: I/ff-log(19632): ffurl_open: ܞ�f��f��f��f���flated/0/.project/videos/mac_video_tmp.mp4, 2 11-20 12:17:04.800: I/ff-log(19632): ffurl_alloc: ܞ�f��f��f��f���flated/0/.project/videos/mac_video_tmp.mp4, 2 11-20 12:17:04.800: I/ff-log(19632): ffurl_alloc: file 11-20 12:17:04.800: I/ff-log(19632): ffurl_open alloc: 0 11-20 12:17:04.800: I/ff-log(19632): ffurl_connect 11-20 12:17:04.800: I/ff-log(19632): ffurl_open connect: -2 11-20 12:17:04.800: I/ff-log(19632): ffurl_open FAIL 11-20 12:17:04.800: I/ff-log(19632): ܞ�f��f��f��f���flated/0/.project/videos/mac_video_tmp.mp4: No such file or directory
( CHARSER IS AS IT'S IN OUTPUT LOGCAT )
3rd type:
11-20 12:18:23.243: I/ff-log(19867): libavutil 51. 46.100 / 51. 46.100 11-20 12:18:23.243: I/ff-log(19867): libavcodec 54. 14.101 / 54. 14.101 11-20 12:18:23.243: I/ff-log(19867): libavformat 54. 3.100 / 54. 3.100 11-20 12:18:23.243: I/ff-log(19867): libavfilter 2. 70.100 / 2. 70.100 11-20 12:18:23.243: I/ff-log(19867): libswscale 2. 1.100 / 2. 1.100 11-20 12:18:23.243: I/ff-log(19867): libswresample 0. 11.100 / 0. 11.100 11-20 12:18:23.243: I/ff-log(19867): before parsing options 11-20 12:18:23.243: I/ff-log(19867): before parsing options 11-20 12:18:23.243: I/ff-log(19867): parse options 11-20 12:18:23.243: I/ff-log(19867): prepare app arguments !!! NOT defined(_WIN32) && !defined(__MINGW32CE__) ! 11-20 12:18:23.243: I/ff-log(19867): after prepare app arguments 11-20 12:18:23.243: I/ff-log(19867): Unknown decoder '��f(' 11-20 12:18:23.243: I/ff-log(19867): exit_program 1 11-20 12:18:23.243: I/ff-log(19867): exit_program 1 11-20 12:18:23.243: I/ff-log(19867): exit_program 2 11-20 12:18:23.253: A/libc(19867): @@@ ABORTING: invalid address or address of corrupt block 0x1d3422d passed to dlfree 11-20 12:18:23.253: A/libc(19867): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 20393 (AsyncTask #2)
4th type:
11-20 12:20:07.214: I/ff-log(20660): libavutil 51. 46.100 / 51. 46.100 11-20 12:20:07.214: I/ff-log(20660): libavcodec 54. 14.101 / 54. 14.101 11-20 12:20:07.214: I/ff-log(20660): libavformat 54. 3.100 / 54. 3.100 11-20 12:20:07.214: I/ff-log(20660): libavfilter 2. 70.100 / 2. 70.100 11-20 12:20:07.214: I/ff-log(20660): libswscale 2. 1.100 / 2. 1.100 11-20 12:20:07.214: I/ff-log(20660): libswresample 0. 11.100 / 0. 11.100 11-20 12:20:07.214: I/ff-log(20660): before parsing options 11-20 12:20:07.214: I/ff-log(20660): before parsing options 11-20 12:20:07.214: I/ff-log(20660): parse options 11-20 12:20:07.214: I/ff-log(20660): prepare app arguments !!! NOT defined(_WIN32) && !defined(__MINGW32CE__) ! 11-20 12:20:07.214: I/ff-log(20660): after prepare app arguments 11-20 12:20:07.214: I/ff-log(20660): Unknown decoder '' 11-20 12:20:07.214: I/ff-log(20660): exit_program 1 11-20 12:20:07.214: A/libc(20660): Fatal signal 11 (SIGSEGV) at 0x2d007165 (code=1), thread 21017 (AsyncTask #2)
-
Properly open audio files with libav/ffmpeg
20 novembre 2013, par HyndrixI am trying to decode audio samples from various file formats using ffmpeg. Therefore I have started some experimenting based on the code in this discussion: How to decode audio via FFmpeg in Android . I use the latest FFMPEG release (1.0) and compile it using https://github.com/halfninja/android-ffmpeg-x264
AVFormatContext * pFormatCtx; avcodec_register_all(); av_register_all(); int lError; if ((lError = avformat_open_input(&pFormatCtx, filename, NULL, 0)) != 0) { LOGE("Error open source file: %d", lError); return; } if ((lError = avformat_find_stream_info(pFormatCtx, 0)) < 0) { LOGE("Error find stream information: %d (Streams: %d)", lError, pFormatCtx->nb_streams); return; } LOGE("audio format: %s", pFormatCtx->iformat->name); LOGE("audio bitrate: %d", pFormatCtx->bit_rate); audioStreamIndex = av_find_best_stream(pFormatCtx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0); //if (audioStreamIndex < 0 || audioStreamIndex >= pFormatCtx->nb_streams) // audioStreamIndex = 0; LOGE("Stream: %d (total: %d)", audioStreamIndex, pFormatCtx->nb_streams); LOGE("audio codec: %s", codec->name);
FFMPEG is compiled using enable-decoder=mp1/mp2/mp3/ogg/vorbis/wav/aac/theora and without any external libraries (e.g. libmp3lame, libtheora, etc.)
Opening of mp3 and wav files works without problems producing the following output for instance for mp3:
audio format: mp3
audio bitrate: 256121
stream: 0 (total: 1)
audio codec: mp3
But when I try to open an ogg file I get this:
Error find stream information: -1 (Streams: 1)
When I manually set
audioStreamIndex=0
and comment out the return statement:Error find stream information: -1 (Streams: 1)
audio format: mp3
audio bitrate: 0
stream: 0 (total: 1)
audio codec: mp3
For m4a (AAC) I get this:
audio format: mp3
audio bitrate: 288000
stream: 0 (total: 1)
audio codec: mp1
but later it fails in
avcodec_decode_audio3
.I also tried to manually force a format without success:
AVInputFormat *pForceFormat= av_find_input_format("ogg"); if ((lError = avformat_open_input(&pFormatCtx, filename, pForceFormat, 0)) // continue
Is there something wrong with the loading code which makes it only work with mp3 and wav and fails for other formats?
Regards,
-
( C# / VB FFMPEG Wrapper ) How can I parse progress of conversion video to audio ?
20 novembre 2013, par Alaa AlrifaieI'd try to become specific as much as I can .
I searched a lot to find a good .net wrapper for FFMPEG, the best was VB FFmpeg Wrapper
I'm so bad at using VB.net, and the problem was that I want to use this library in a C# project but I couldn't convert the example program I found from VB.net to C# correctly .
So, I've edited my C# application, so it writes input video file path to a temporary .txt file .. then run the "Converter" ( Which is written in VB ) !
The code of my "Converter" :
Imports System Imports System.IO Public Class Form1 Public WithEvents MediaConverter As New FFLib.Encoder Private Sub ConOut(ByVal prog As String, ByVal tl As String) Handles MediaConverter.Progress OperationPrgrss.Value = prog Application.DoEvents() End Sub Private Sub stat(ByVal status) Handles MediaConverter.Status StatusLbl.Text = status Application.DoEvents() End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Try Using PathFinder As New StreamReader("_temp.txt") Dim SrcPath As String SrcPath = PathFinder.ReadLine() PathTxtBox.Text = SrcPath End Using Catch ex As Exception MessageBox.Show("The file couldn't be read : " & Environment.NewLine & ex.Message) End Try End Sub Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown MediaGenerator.RunWorkerAsync() End Sub Private Sub MediaGenerator_DoWork(sender As Object, e As ComponentModel.DoWorkEventArgs) Handles MediaGenerator.DoWork MediaConverter.OverWrite = False MediaConverter.SourceFile = PathTxtBox.Text MediaConverter.Format = MediaConverter.Format_MP3 MediaConverter.AudioCodec = MediaConverter.AudioCodec_mp3 MediaConverter.Video_Codec = MediaConverter.Vcodec_NONE MediaConverter.Threads = 0 MediaConverter.OverWrite = True Dim OutputFldr As String = AppDomain.CurrentDomain.BaseDirectory & "MP3Files\\" MediaConverter.OutputPath = OutputFldr MediaConverter.AnalyzeFile() MediaConverter.Encode() End Sub End Class
What I'm trying to do is converting a video file [ sometime it's WEBM, FLV, MP4 or 3GP ], and the above code does it successfully, but the problem is when using :
MediaConverter.Video_Codec = MediaConverter.Vcodec_NONE
the progress bar doesn't work, it's value remains 0 ! & When I use any Video codec it works perfectly [ the progress bar ], but the created MP3 file won't work ever with any media player, or in Smartphone & Tv's .. etc ;
...
So, what's the problem ?! and how can I solve it ? I tried a lot to change some functions in the wrapper library source, but as I mentioned before ... I'm just a newbie @ VB.net :\