Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
errors when compiling c code with ffmpeg library
2 mai 2017, par KindermannI've installed ffmpeg library in my new ubuntu 16.04 OS. When I tried to compile my c code, I got the following strange errors:
/home/widerstand/ffmpeg_build/lib/libavutil.a(hwcontext_vaapi.o): In function `vaapi_device_free': /home/widerstand/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:861: undefined reference to `XCloseDisplay' /home/widerstand/ffmpeg_build/lib/libavutil.a(hwcontext_vaapi.o): In function `vaapi_device_create': /home/widerstand/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:891: undefined reference to `XOpenDisplay' /home/widerstand/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:896: undefined reference to `vaGetDisplay' /home/widerstand/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:903: undefined reference to `XDisplayName' /home/widerstand/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:893: undefined reference to `XDisplayName' /home/widerstand/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:917: undefined reference to `vaGetDisplayDRM' /home/widerstand/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:891: undefined reference to `XOpenDisplay' /home/widerstand/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:893: undefined reference to `XDisplayName' /home/widerstand/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:898: undefined reference to `XDisplayName' /home/widerstand/ffmpeg_build/lib/libavutil.a(hwcontext_vdpau.o): In function `vdpau_device_create': /home/widerstand/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vdpau.c:431: undefined reference to `XOpenDisplay' /home/widerstand/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vdpau.c:437: undefined reference to `XDisplayString' /home/widerstand/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vdpau.c:439: undefined reference to `XDefaultScreen' /home/widerstand/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vdpau.c:439: undefined reference to `vdp_device_create_x11' /home/widerstand/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vdpau.c:433: undefined reference to `XDisplayName' /home/widerstand/ffmpeg_build/lib/libavutil.a(hwcontext_vdpau.o): In function `vdpau_device_free': /home/widerstand/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vdpau.c:410: undefined reference to `XCloseDisplay' collect2: error: ld returned 1 exit status Makefile:30: recipe for target 'video_analysis' failed make: *** [video_analysis] Error 1
I've reinstalled ffmpeg library multiple times using the following configurations:
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \ --prefix="$HOME/ffmpeg_build" \ --pkg-config-flags="--static" \ --extra-cflags="-I$HOME/ffmpeg_build/include" \ --extra-ldflags="-L$HOME/ffmpeg_build/lib" \ --bindir="$HOME/bin" \ --enable-gpl \ --enable-libass \ --enable-libfdk-aac \ --enable-libfreetype \ --enable-libmp3lame \ --enable-libopus \ --enable-libtheora \ --enable-libvorbis \ --enable-libvpx \ --enable-libx264 \ --enable-nonfree PATH="$HOME/bin:$PATH" make
The installation process was successful each time. But when I tried to compile my own c code, I always encountered the same errors as mentioned above. I have no idea about that... Here is the makefile I used:
EDIT:
FFMPEG_LIBS= libavdevice \ libavformat \ libavfilter \ libavcodec \ libswresample \ libswscale \ libavutil \ TARGET = video_analysis LIBS = -lX11 -lm -lvdpau -lva CC = gcc CFLAGS += -O2 -g -O0 CFLAGS := $(shell pkg-config --cflags $(FFMPEG_LIBS)) $(CFLAGS) LDLIBS := $(shell pkg-config --libs $(FFMPEG_LIBS)) $(LDLIBS) .PHONY: default all clean default: $(TARGET) all: default OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c)) HEADERS = $(wildcard *.h) %.o: %.c $(HEADERS) $(CC) $(CFLAGS) -c $< -o $@ .PRECIOUS: $(TARGET) $(OBJECTS) $(TARGET): $(OBJECTS) $(CC) $(OBJECTS) $(LDLIBS) $(LIBS) -o $@ clean: -rm -f *.o -rm -f $(TARGET)
EDIT:
Afer swapping $(LIBS) and $(LDLIBS) to be $(LDLIBS) $(LIBS) at line 30, it looks much better, but the compiler still reports the following errors:
/root/ffmpeg_build/lib/libavutil.a(hwcontext_vaapi.o): In function `vaapi_device_create': /ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:896: undefined reference to `vaGetDisplay' /ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:917: undefined reference to `vaGetDisplayDRM'
I have no idea which library is still missing? It looks as if libva were still missing?... I got the answer by myself...Have a look at here: errors of 'vaGetDisplay' and `vaGetDisplayDRM'
-
Capture FFMPEG output
2 mai 2017, par AndrewI need to read the output from ffmpeg in order to even try the solution to my question from yesterday. This is a separate issue from my problem there, so I made a new question.
How the heck do I get the output from an
ffmpeg -i
command in PHP?This is what I've been trying:
<?PHP error_reporting(E_ALL); $src = "/var/videos/video1.wmv"; $command = "/usr/bin/ffmpeg -i " . $src; echo "",$command,"
"; $command = escapeshellcmd($command); echo "backtick:"; `$command`; echo "
system:"; echo system($command); echo "
shell_exec:"; echo shell_exec($command); echo "
passthru:"; passthru($command); echo "
exec:"; $output = array(); exec($command,$output,$status); foreach($output AS $o) { echo $o , "
"; } echo "
popen:"; $handle = popen($command,'r'); echo fread($handle,1048576); pclose($handle); echo "
"; ?>This is my output:
/usr/bin/ffmpeg -i /var/videos/video1.wmv
backtick:
system:
shell_exec:
passthru:
exec:
popen:
I don't get it.
safe_mode
is off. There's nothing indisable_functions
. The directory is owned bywww-data
(the apache user on my Ubuntu system). I get a valid status back fromexec()
andsystem()
and running the same command from the command line give me tons of output. I feel like I must be missing something obvious but I have no idea what it is. -
rescale with ffmpeg but keep the pixel density constant
2 mai 2017, par rinofcanI have a 1280x720 video resolution After I resized the video output was blurred more than the original video How to output video is clearer
-
FFMPEG Recode all audio streams while keeping originals
2 mai 2017, par OliravI am trying to add a additional set of audio tracks into some video files, as part of a automated process. I would like to keep all the original audio tracks and have a second re-coded copy.
What I have been using is:
ffmpeg -i file -map 0:v -codec:v copy -map 0:a -codec:a copy -map 0:a:0 -codec:a:0 aac -strict experimental ...(Bitrate, filters etc all with :a:0) -map 0:s -codec:s copy output file
However I can't work out how to change this to handle input files that have multiple audio tracks as it will only convert the first.
If I change the :a:0 to :a on the codec line it produces the extra copy I need but overrides the copy codec for the original copy.
Any ideas anyone?
-
Reading encoded data using muxing in ffmpeg
2 mai 2017, par Sanduni WickramasingheI am trying to read an encoded video using ffmpeg c++. When I try to build my code error appears as identifier options is undefined. But it is already defined as
AVDictionary *options = NULL
.What is wrong with my code?
void CFfmpegmethods::VideoRead(){ const char *url = "H:/Sanduni_projects/ad_2.mp4"; AVFormatContext *s = NULL; int ret = avformat_open_input(&s, url, NULL, NULL); if (ret < 0) abort(); avformat_find_stream_info(s, &options); AVDictionary *options = NULL; av_dict_set(&options, "video_size", "640x480", 0); av_dict_set(&options, "pixel_format", "rgb24", 0); if (avformat_open_input(&s, url, NULL, &options) < 0){ abort(); } av_dict_free(&options); AVDictionaryEntry *e; if (e = av_dict_get(options, "", NULL, AV_DICT_IGNORE_SUFFIX)) { fprintf(stderr, "Option %s not recognized by the demuxer.\n", e->key); abort(); } avformat_close_input(&s); }