Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
can hls play fragment mp4 formed by rtp data
26 mai 2017, par hui zhangI have a rtp stream, and I record it to several fragment mp4(fmp4) files divide by I-Frame. (I first record it as mp4, and set the right pts. then use ffmpeg transform it to fragment to fmp4 )
ffmpeg -re -i infile.ext -f mp4 -movflags frag_keyframe+empty_moov output.mp4)
I want to play these fmp4 in hls, I set the m3u8 file manually. And try to play, browser get the fmp4 file successfully. But not able to played on browser.
I don't know where is wrong? Could any one help me ? -
FFMPEG Audio/Video out of sync after transcoding video in segments
25 mai 2017, par IdanMy system transcodes videos in a very specific way.
- separating the video and the audio
- transcoding the audio stream
- segmenting the video
- transcoding each of the segments of the video
- concat all segments back to 1 video
- merging the new transcoded video and audio back together
While at 99% of the times the process works as it should and the result is a valid video+audio file. in 1% of the times, I get the video and audio out of sync.
When investigated the issue I noticed that the sync issue appears in a specific segment/s. Meaning, if the video was sliced into 100 segments, the sync can be ok for the first 50 segments, then something happens and the audio or video gets an offset and goes out of sync. It can occur in any number of segments in one video.
I guess it's something to do with timestamps getting lost in the process and segments changing their length in the process but I have no idea how I can overcome it. Open for suggestions.
The commands I use for each step (paths were shorten and may not match, not real issue there):
Segmenting the video:
ffmpeg -fflags +genpts -i $INPUT_FILE -c copy -map 0:0 -flags -global_header -segment_time 10 -break_non_keyframes 0 -reset_timestamps 1 -segment_list segments.list -segment_list_type ffconcat -write_empty_segments 0 -segment_format mp4 -f segment seg-%d.mp4
Transcoding audio:
ffmpeg -i $INPUT_FILE -vn -c:a aac -threads 1 -ac 2 -b:a 125588 audio.mp4
Transcoding each of the segments:
ffmpeg -y -i $f -an -vcodec libx264 -threads 4 -r 30 -pix_fmt yuv420p -crf 20 -preset:v fast -profile:v main -level:v 4.1 transcoded/$f
Concat segments:
ffmpeg -y -f concat -i segments.list -c copy -movflags +faststart file_video.mp4
Combine video and audio:
ffmpeg -y -i file_video.mp4 -i file_audio.mp4 -c copy -shortest file_out.mp4
-
Concatenating audio blobs
25 mai 2017, par Abhijay GhildyalI tried concatenating audio blobs using Web RTC experiment by Muaz Khan, but when I play the concatenated audio, the HTML audio element does not show the full length of the audio file and also if you download and play, the issue will persist. I used ffmpeg to concate these blobs, though is there a way which can be used for concatenating audio blobs using the Web RTC js experiment by Muaz Khan. A similar attempt which also did not work out : Combine two audio blob recordings
-
FFmpeg mp4 encoder for html-android
25 mai 2017, par Dell WatsonHello I'm trying to put video .mp4 auto-captured by my webcam using ffmpeg into HTML (running ffmpeg in desktop-linux), and then activated my localhost so my android will able to see it.
the video.mp4 was able to run in linux, and in html-desktop.
the video in my android-browser(html-android) WAS ABLE to play too BUT it's
all white
and pixels error, so it's a fail.I thought because android has difference surface because in my desktop it runs perfectly, then i keep searching and trying with ogv/webm.
In the end, I just use a downloaded another mp4 and it runs perfectly tho. now I think the problem was coming from my mp4-webcam created by ffmpeg(run in cmd)
I compare a mp4-webcam vs mp4-downloaded
5sec vs 1min,
Data-rate: 16477kbps vs 613kbps
framerate: 30frm/s vs 23frm/s
size: 9MB vs 5 MB
even tho it's only 5sec video by webcam, it still has larger data than a 1min video-downloaded maybe it was because without conversion.
but the question, is that the reason of the problem ? android-html(google chrome) wasn't able to display and make a dead pixels since in desktop it runs. it shouldn't be the problem right ?
I really need to transfer webcam-record into android-surface (my web-app).
I have no idea to fix it, any advice ? I've been searching a lot. Maybe there was another problem I do not know yet.
EDIT: my cmd ffmpeg run : ffmpeg -y -f v4l2 -i /dev/video1 -codec:v libx264 -qp 0 -t 0:00:05 hss.mp4
EDIT 2: my 2nd thought because ffmpeg encoder that I used(libx264) isnot support for android. but i still no idea
-
Muting ffmpeg warnings when loading video
25 mai 2017, par cbuchartI'm using OpenCV to process a set of MPEG videos. For some of them following warning is displayed when reading a frame or seeking (it is printed by the ffmpeg library).
[mpeg2video @ 026b0d20] warning: first frame is no keyframe
The thing is that such messages are printed together other valid output of my application and they are bothering final users. Is there any way to suppress such warning messages programmatically, other than re-coding the videos with an external tool?
I'm already muting the standard output and error, as well as using a custom (dummy) OpenCV error handler. Below a MCVE for testing.
PS: I understand the warning and actually the full project handles those scenarios so videos are correctly read.
Example code to reproduce the problem
#include
#include core/core.hpp> #include highgui/highgui.hpp> int handleError(int status, const char* func_name, const char* err_msg, const char* file_name, int line, void* userdata) { return 0; } int main() { std::cout << "Start!" << std::endl; cv::VideoCapture reader; if (!reader.open("Sample.mpg")) { std::cout << "Failed opening video" << std::endl; return 0; } cv::redirectError(handleError); std::cout.setstate(std::ios_base::failbit); std::cout << "std::cout mute test..." << std::endl; // OK, muted std::cerr.setstate(std::ios_base::failbit); std::cerr << "std::cerr mute test..." << std::endl; // OK, muted cv::Mat tmpImage; try { tmpImage = tmpImage * tmpImage; // OK, OpenCV error muted } catch (...) {} // Here the warning is printed reader.read(tmpImage); std::cout.clear(); std::cerr.clear(); std::cout << "Finished!" << std::endl; return 0; } The
Sample.mpg
video can be downloaded from the Internet Archive: https://archive.org/download/ligouHDR-HC1_sample1/Sample.mpgThis is the current output of the program:
I'm using VS 2010 and OpenCV 2.4.10. Following DLLs are the only ones with the executable (no other OpenCV-related DLL is reachable in the PATH).
- opencv_core2410.dll
- opencv_ffmpeg2410.dll
- opencv_highgui2410.dll