Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
Pipe opencv frames to ffmpeg
17 juillet 2016, par baciI am trying to pipe opencv frames to ffmpeg using rawvideo format, which should accept the input as BGRBGRBGR... encoding the frame before piping is not an option.
cv::Mat frame; cv::VideoCapture cap("cap.avi"); while(1) { cap >> frame; if(!frame.data) break; // some processing cv::Mat array = frame.reshape(0, 1); // to make continuous std::string output((char*) array.data, array.total() * array.elemSize()); std::cout << output; }
with command
cap.exe | ffplay -f rawvideo -pixel_format bgr24 -video_size 1920x1080 -framerate 10 -i -
gives this kind of distorted result
I think problem is not related to ffmpeg/ffplay, but something is wrong with my frame to raw conversion
how to convert mat with 3 channels to rawvideo bgr24 format ?
-
With ffmpeg, trying to change a container from Mpeg TS to MP4, fps became twice of Mpeg TS
17 juillet 2016, par user2148481I got a Mpeg TS file from a capture board to make a DEMO video clip.
Here is information of the file from ffmpeg;
Stream #0:0[0x51]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 59.94 tbr, 90k tbn, 59.94 tbc Stream #0:1[0x61]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 224 kb/s
However, I cannot edit it in FCP X, so I tried to change just its container TS to MP4 with ffmpeg using the below command.
ffmpeg -i input.ts -vcodec copy -acodec copy output.mp4
After doing it, fps of output.mp4 became 59.94 fps and information is like below;
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 1750 kb/s, 59.94 fps, 59.94 tbr, 90k tbn, 59.94 tbc Stream #0:1(und): Audio: mp2 (mp4a / 0x6134706D), 48000 Hz, stereo, s16p, 224 kb/s
Fps is not same.
Is there a way to keep same fps as TS with just copy option to change a container?
I am wondering whether just re-encoding is solution or not.
/////
Full logs;
$ ffmpeg -i input.ts -vcodec copy -acodec copy output.mp4 ffmpeg version 1.1.2 Copyright (c) 2000-2013 the FFmpeg developers built on Feb 6 2013 10:45:57 with Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn) configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libspeex --enable-libfreetype --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid libavutil 52. 13.100 / 52. 13.100 libavcodec 54. 86.100 / 54. 86.100 libavformat 54. 59.106 / 54. 59.106 libavdevice 54. 3.102 / 54. 3.102 libavfilter 3. 32.100 / 3. 32.100 libswscale 2. 1.103 / 2. 1.103 libswresample 0. 17.102 / 0. 17.102 libpostproc 52. 2.100 / 52. 2.100 [mpegts @ 0x7f8a2b033000] max_analyze_duration 5000000 reached at 5003333 Input #0, mpegts, from 'input.ts': Duration: 00:05:01.27, start: 0.224400, bitrate: 2727 kb/s Program 1 Stream #0:0[0x51]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 59.94 tbr, 90k tbn, 59.94 tbc Stream #0:1[0x61]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 224 kb/s Output #0, mp4, to 'output.mp4': Metadata: encoder : Lavf54.59.106 Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 29.97 fps, 90k tbn, 90k tbc Stream #0:1: Audio: mp2 (i[0][0][0] / 0x0069), 48000 Hz, stereo, 224 kb/s Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy) Press [q] to stop, [?] for help [mp4 @ 0x7f8a2b058200] pts has no value frame=13472 fps=0.0 q=-1.0 size= 54536kB time=00:03:44.80 bitrate=1987.3kbits/frame=18056 fps=0.0 q=-1.0 Lsize= 73024kB time=00:05:01.28 bitrate=1985.5kbits/s video:64370kB audio:8212kB subtitle:0 global headers:0kB muxing overhead 0.608498%
-
Why does mplayer not play my stream ?
17 juillet 2016, par SirWindfieldI wanted to use mplayer (a command line tool) to play a SoundCloud url that I fetched with there official API. The url looks like this
https://cf-media.sndcdn.com/qop35iYKlHhs.128.mp3?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiKjovL2NmLW1lZGlhLnNuZGNkbi5jb20vcW9wMzVpWUtsSGhzLjEyOC5tcDMiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE0Njg3NTM4NjB9fX1dfQ__&Signature=OZ4IawmjdU6hEN8KB8e~t3QTy4lBFVBbIDg-a6tuPkb65e0mPskkCFFASkTWbyy5lsaT9IrURan6y70sZhLXPbng1IfkTsGdX1dO938NwVYnKs-BS7IL4TiVFxTBXoKJgmCmUD0qmmGmYqm3YdGZQrP~Sj~mw9~fmtwdHQu0rhl3O-dKsgk497JAR6pMorQs7BSs0XIosV1Mmv2DMD6iifquCWV9Ezq4ekneQ1gfSjVmzjjnKvsxjPpgmU~5DTdewwzlNClVxdzHSQONWM7c0YMGlBcVz97NviaeZOQSCAW8QZS59WULXJBJ9OmEPctWtpe3O0mo-GYjwEkbVGYl9A__&Key-Pair-Id=APKAJAGZ7VMH2PFPW6UQ
I use the command "mplayer 'url'" to play it but I always get the output:
libavformat version 57.25.100 (internal) https protocol not found, recompile FFmpeg with openssl, gnutls, or securetransport enabled.
Looking which protocols have been installed tells me that I have https input and output support (ffmpeg -protocols):
ffmpeg version 3.1.1 Copyright (c) 2000-2016 the FFmpeg developers built with Apple LLVM version 7.3.0 (clang-703.0.31) configuration: --prefix=/usr/local/Cellar/ffmpeg/3.1.1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libtheora --enable-libvorbis --enable-libvpx --enable-librtmp --enable-libfaac --enable-ffplay --enable-libspeex --enable-openssl --enable-libopus --disable-lzma --enable-nonfree --enable-vda libavutil 55. 28.100 / 55. 28.100 libavcodec 57. 48.101 / 57. 48.101 libavformat 57. 41.100 / 57. 41.100 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 47.100 / 6. 47.100 libavresample 3. 0. 0 / 3. 0. 0 libswscale 4. 1.100 / 4. 1.100 libswresample 2. 1.100 / 2. 1.100 libpostproc 54. 0.100 / 54. 0.100 Supported file protocols: Input: async cache concat crypto data file ftp gopher hls http httpproxy https mmsh mmst pipe rtp srtp subfile tcp tls udp udplite unix rtmp rtmpe rtmps rtmpt rtmpte Output: crypto file ftp gopher http httpproxy https icecast md5 pipe rtp srtp tcp tls udp udplite unix rtmp rtmpe rtmps rtmpt rtmpte
-
How to add album art with ffmpeg ?
17 juillet 2016, par Adi Ricky kEverybody, I've stuck to add album art on mp3 files.
I already research and Googling about this issue but not solution yet, on
ffmpeg
documentation to add image (album art) to mp3 use this script:ffmpeg -i input.mp3 -i cover.png -c copy -map 0 -map 1 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" out.mp3
Source from: http://www.ffmpeg.org/ffmpeg-all.html#mp3
But it's doesn't work on my console output is:
Unrecognized option 'c' Failed to set value 'copy' for option 'c'
I looking for another solution and I get from: http://trac.ffmpeg.org/ticket/2221:
ffmpeg -i input.mp3 -i cover.png -map 0:0 -map 1:0 -c copy -id3v2_version 3 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" out.mp3
Also return same output, I already research why return :
Unrecognized option 'c' Failed to set value 'copy' for option 'c'
But there are no body have same problem. anybody can help me, please?
nb: I use ubuntu 12.04 and ffmpeg version 0.8.6-4:0.8.6-0. thanks
-
Changing resolution mid-video with FFMPEG
16 juillet 2016, par kingroloI have a source video (mpeg2video) which I'm transcoding to x264. The source contains 2 different programs recorded from TV. One is in 4:3 AR and the other 16:9 AR. When I play the source file through VLC the player correctly changes size to show the video at the correct AR. So far so good.
When I transcode the conversion process auto detects the AR from the first few frames and then transcodes the whole video using this AR. If the 16:9 section comes first then the whole conversion is done in 16:9 and the 4:3 section looks stretch horizontally. If the 4:3 section is at the start of the source file then the whole transcode is done in 4:3 and the 16:9 section looks squashed horizontally.
No black bars are ever visible.
Here's my command:
nice -n 17 ffmpeg -i source.mpg -acodec libfaac -ar 48000 -ab 192k -async 1 -copyts -vcodec libx264 -b 1250k -threads 2 -level 31 -map 0:0 -map 0:1 -map 0:2 -scodec copy -deinterlace output.mkv
I don't fully understand what's going on. How do I get the same 'change in AR' mid video in the output file that I have in the input video?