Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
How to execute commands on a bat file from c++
2 avril 2015, par AK47I'm working in a c++ project and I need to call ffmpeg command prompt(ff-promt) from my c++ code and execute commands on that bat command line. I have already opened the window. but not functioning the command running on that bat window. Can anyone please guide me how to do it. for opening I have used following command
FILE *bat = _popen("ffmpeg-2.5.2-win64-static\\ff-prompt", "w");
I used following command to write the command on that and enter
fprintf(bat, "ffmpeg -i Sample.avi -vn -ar 44100 -ac 2 -ab 192k -f mp3 Sample.mp3\r");
please guide me soon. Thanks
-
FFMPEG : encode x265, container mpeg2 ts, stream-STARTCODE MISSING
2 avril 2015, par rwdy15I am trying to encode a video with FFMPEG x265, put it into MPEG2 TS and then stream it over UDP. Then receive on another PC and save it. Perform PSNR.
The encoding works fine, but when I try to stream I get the error:
[mpegts @ 00000000050b0520] HEVC bitstream error, startcode missing, size 1436 data 00000100
- Step 1- Encoding:
ffmpeg -re -i test.ts -r 25 -b:v 2500k -preset medium -c:v libx265 -x265-params crf=27 -y -f mpegts test1.ts
No error, everything fine.
- Step 2- Streaming:
Start code missing.
ffmpeg -re -i test1.ts -c copy -f mpegts udp://172.18.60.47:1234 ffmpeg version N-68441-g4fa42e0 Copyright (c) 2000-2014 the FFmpeg developers built on Dec 14 2014 22:13:03 with gcc 4.9.2 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnut le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --e modplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsc r --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable- --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-decklink --enable-zl libavutil 54. 15.100 / 54. 15.100 libavcodec 56. 14.100 / 56. 14.100 libavformat 56. 15.105 / 56. 15.105 libavdevice 56. 3.100 / 56. 3.100 libavfilter 5. 3.101 / 5. 3.101 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 3.100 / 53. 3.100 Input #0, mpegts, from 'test1.ts': Duration: 00:00:10.12, start: 1.480000, bitrate: 456 kb/s Program 1 Metadata: service_name : Service01 service_provider: FFmpeg Stream #0:0[0x100]: Video: hevc (Main) ([36][0][0][0] / 0x0024), yuv420p(tv), 1280x720, 25 fps, 25 tbr, 90k tbn, 25 tbc Output #0, mpegts, to 'udp://172.18.60.47:1234': Metadata: encoder : Lavf56.15.105 Stream #0:0: Video: hevc ([36][0][0][0] / 0x0024), yuv420p, 1280x720, q=2-31, 25 fps, 25 tbr, 90k tbn, 25 tbc Stream mapping: Stream #0:0 -> #0:0 (copy) Press [q] to stop, [?] for help **[mpegts @ 0000000004ed7320] HEVC bitstream error, startcode missing, size 2462 data 00000102** [mpegts @ 0000000004ed7320] HEVC bitstream error, startcode missing, size 302 data 00000102 [mpegts @ 0000000004ed7320] HEVC bitstream error, startcode missing, size 134 data 00000100 [mpegts @ 0000000004ed7320] HEVC bitstream error, startcode missing, size 149 data 00000100 [mpegts @ 0000000004ed7320] HEVC bitstream error, startcode missing, size 5107 data 00000102 [mpegts @ 0000000004ed7320] HEVC bitstream error, startcode missing, size 1331 data 00000102 [mpegts @ 0000000004ed7320] HEVC bitstream error, startcode missing, size 341 data 00000100 frame= 8 fps=0.0 q=-1.0 Lsize= 37kB time=00:00:00.24 bitrate=1278.4kbits/s video:34kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 9.718209% Received signal 2: terminating.
When I do the steps above with x264 everything works fine. I can stream the video and I can receive it on the other side. Any idea what is wrong? Is this a BUG?
Commands for x264:
ffmpeg -re -i test.ts -r 25 -b:v 2500k -preset medium -c:v libx264 -x264-params crf=27 -y -f mpegts test1.ts
ffmpeg -re -i test1.ts -c copy -f mpegts udp://172.18.60.47:1234
Thanks for the help!!
BR, Rudi
-
Force ffmpeg to ignore error when connecting failed
2 avril 2015, par Given92I'm trying to deploy a live stream delivery system with nginx and nginx-rtmp-module.
For every node in my system, I wish it could 'forward' the live stream received to downstream node. I try to implement it by following config in my nginx.conf:
exec_push ffmpeg -i rtmp://localhost/src/test -vcodec copy -strict -2 -ar 44100 -ac 1 -f flv rtmp://
/src/test -f flv rtmp:// /src/test it works when everything runs well, but if the downstream node is down, this command will exit and none of the downstream nodes could receive the live stream.
How could I force ffmpeg to ignore the
connetion refused
, or is there any better alternative to my implementation? -
How to extract('demux') from 'mp4' video to get the encoded data(or elementary stream) using ffmpeg ?
2 avril 2015, par AlanHow to
demux
frommp4
video to get the video(h264
format) elementary stream usingffmpeg
command line ?Thanks
-
issue after video rotation how fix
2 avril 2015, par VahagnI have next code for rotate video
OpenCVFrameConverter.ToIplImage converter2 = new OpenCVFrameConverter.ToIplImage();
for (int i = firstIndex; i <= lastIndex; i++) { long t = timestamps[i % timestamps.length] - startTime; if (t >= 0) { if (t > recorder.getTimestamp()) { recorder.setTimestamp(t); } Frame g = converter2.convert(rotate(converter2.convertToIplImage(images[i % images.length]),9 0)); recorder.record(g); } }
images[i] - Frame in JavaCV after in video have green lines
UPDATE Convertation function
/* * Copyright (C) 2015 Samuel Audet * * This file is part of JavaCV. * * JavaCV is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version (subject to the "Classpath" exception * as provided in the LICENSE.txt file that accompanied this code). * * JavaCV is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with JavaCV. If not, see /www.gnu.org/licenses/>. */ package com.example.vvardanyan.ffmpeg; import org.bytedeco.javacpp.BytePointer; import org.bytedeco.javacpp.Pointer; import java.nio.Buffer; import static org.bytedeco.javacpp.opencv_core.CV_16S; import static org.bytedeco.javacpp.opencv_core.CV_16U; import static org.bytedeco.javacpp.opencv_core.CV_32F; import static org.bytedeco.javacpp.opencv_core.CV_32S; import static org.bytedeco.javacpp.opencv_core.CV_64F; import static org.bytedeco.javacpp.opencv_core.CV_8S; import static org.bytedeco.javacpp.opencv_core.CV_8U; import static org.bytedeco.javacpp.opencv_core.CV_MAKETYPE; import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_16S; import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_16U; import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_32F; import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_32S; import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_64F; import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_8S; import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_8U; import static org.bytedeco.javacpp.opencv_core.IplImage; import static org.bytedeco.javacpp.opencv_core.Mat; /** * A utility class to map data between {@link Frame} and {@link IplImage} or {@link Mat}. * Since this is an abstract class, one must choose between two concrete classes: * {@link ToIplImage} or {@link ToMat}. * * @author Samuel Audet */ public abstract class OpenCVFrameConverter
extends FrameConverter { IplImage img; Mat mat; public static class ToIplImage extends OpenCVFrameConverter { @Override public IplImage convert(Frame frame) { return convertToIplImage(frame); } } public static class ToMat extends OpenCVFrameConverter { @Override public Mat convert(Frame frame) { return convertToMat(frame); } } public static int getFrameDepth(int depth) { switch (depth) { case IPL_DEPTH_8U: case CV_8U: return Frame.DEPTH_UBYTE; case IPL_DEPTH_8S: case CV_8S: return Frame.DEPTH_BYTE; case IPL_DEPTH_16U: case CV_16U: return Frame.DEPTH_USHORT; case IPL_DEPTH_16S: case CV_16S: return Frame.DEPTH_SHORT; case IPL_DEPTH_32F: case CV_32F: return Frame.DEPTH_FLOAT; case IPL_DEPTH_32S: case CV_32S: return Frame.DEPTH_INT; case IPL_DEPTH_64F: case CV_64F: return Frame.DEPTH_DOUBLE; default: return -1; } } public static int getIplImageDepth(Frame frame) { switch (frame.imageDepth) { case Frame.DEPTH_UBYTE: return IPL_DEPTH_8U; case Frame.DEPTH_BYTE: return IPL_DEPTH_8S; case Frame.DEPTH_USHORT: return IPL_DEPTH_16U; case Frame.DEPTH_SHORT: return IPL_DEPTH_16S; case Frame.DEPTH_FLOAT: return IPL_DEPTH_32F; case Frame.DEPTH_INT: return IPL_DEPTH_32S; case Frame.DEPTH_DOUBLE: return IPL_DEPTH_64F; default: return -1; } } static boolean isEqual(Frame frame, IplImage img) { return img != null && frame != null && frame.image != null && frame.image.length > 0 && frame.imageWidth == img.width() && frame.imageHeight == img.height() && frame.imageChannels == img.nChannels() && getIplImageDepth(frame) == img.depth() && new Pointer(frame.image[0]).address() == img.imageData().address() && frame.imageStride * Math.abs(frame.imageDepth) / 8 == img.widthStep(); } public IplImage convertToIplImage(Frame frame) { if (frame == null) { return null; } else if (frame.opaque instanceof IplImage) { return (IplImage)frame.opaque; } else if (!isEqual(frame, img)) { int depth = getIplImageDepth(frame); img = depth < 0 ? null : IplImage.createHeader(frame.imageWidth, frame.imageHeight, depth, frame.imageChannels) .imageData(new BytePointer(new Pointer(frame.image[0].position(0)))).widthStep(frame.imageStride * Math.abs(frame.imageDepth) / 8); } return img; } public Frame convert(IplImage img) { if (img == null) { return null; } else if (!isEqual(frame, img)) { frame = new Frame(); frame.imageWidth = img.width(); frame.imageHeight = img.height(); frame.imageDepth = getFrameDepth(img.depth()); frame.imageChannels = img.nChannels(); frame.imageStride = img.widthStep() * 8 / Math.abs(frame.imageDepth); frame.image = new Buffer[] { img.createBuffer() }; frame.opaque = img; } return frame; } public static int getMatDepth(Frame frame) { switch (frame.imageDepth) { case Frame.DEPTH_UBYTE: return CV_8U; case Frame.DEPTH_BYTE: return CV_8S; case Frame.DEPTH_USHORT: return CV_16U; case Frame.DEPTH_SHORT: return CV_16S; case Frame.DEPTH_FLOAT: return CV_32F; case Frame.DEPTH_INT: return CV_32S; case Frame.DEPTH_DOUBLE: return CV_64F; default: return -1; } } static boolean isEqual(Frame frame, Mat mat) { return mat != null && frame != null && frame.image != null && frame.image.length > 0 && frame.imageWidth == mat.cols() && frame.imageHeight == mat.rows() && frame.imageChannels == mat.channels() && getMatDepth(frame) == mat.depth() && new Pointer(frame.image[0]).address() == mat.data().address() && frame.imageStride * Math.abs(frame.imageDepth) / 8 == (int)mat.step(); } public Mat convertToMat(Frame frame) { if (frame == null) { return null; } else if (frame.opaque instanceof Mat) { return (Mat)frame.opaque; } else if (!isEqual(frame, mat)) { int depth = getMatDepth(frame); mat = depth < 0 ? null : new Mat(frame.imageHeight, frame.imageWidth, CV_MAKETYPE(depth, frame.imageChannels), new Pointer(frame.image[0].position(0)), frame.imageStride * Math.abs(frame.imageDepth) / 8); } return mat; } public Frame convert(Mat mat) { if (mat == null) { return null; } else if (!isEqual(frame, mat)) { frame = new Frame(); frame.imageWidth = mat.cols(); frame.imageHeight = mat.rows(); frame.imageDepth = getFrameDepth(mat.depth()); frame.imageChannels = mat.channels(); frame.imageStride = (int)mat.step() * 8 / Math.abs(frame.imageDepth); frame.image = new Buffer[] { mat.createBuffer() }; frame.opaque = mat; } return frame; } }