Recherche avancée
Médias (33)
-
Matmos - Action at a Distance
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
DJ Dolores - Oslodum 2004 (includes (cc) sample of “Oslodum” by Gilberto Gil)
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Danger Mouse & Jemini - What U Sittin’ On ? (starring Cee Lo and Tha Alkaholiks)
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Cornelius - Wataridori 2
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
The Rapture - Sister Saviour (Blackstrobe Remix)
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Chuck D with Fine Arts Militia - No Meaning No
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
Sur d’autres sites (346)
-
AVCodec h264_v4l2m2m hardware decoding unable to find device
26 juillet 2023, par nathansizemoreUsing a custom compiled FFmpeg :


$ ./ffmpeg -codecs | grep h264
ffmpeg version n6.0 Copyright (c) 2000-2023 the FFmpeg developers
 built with gcc 7 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)
 configuration: --arch=aarch64 --enable-cross-compile --target-os=linux --cross-prefix=aarch64-linux-gnu- --prefix=/builds/dronesense/rust/ffmpeg-build/ffmpeg/out --pkgconfigdir= --pkg-config=pkg-config --extra-libs='-ldl -lpthread' --enable-libvpx --enable-libx264 --enable-libx265 --enable-decklink --enable-gpl --enable-nonfree --enable-shared --disable-static
 libavutil 58. 2.100 / 58. 2.100
 libavcodec 60. 3.100 / 60. 3.100
 libavformat 60. 3.100 / 60. 3.100
 libavdevice 60. 1.100 / 60. 1.100
 libavfilter 9. 3.100 / 9. 3.100
 libswscale 7. 1.100 / 7. 1.100
 libswresample 4. 10.100 / 4. 10.100
 libpostproc 57. 1.100 / 57. 1.100
 DEV.LS h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_v4l2m2m ) (encoders: libx264 libx264rgb h264_v4l2m2m )



/dev/video32
seems to have H.264 decoding support :

$ v4l2-ctl --list-formats-out -d /dev/video32
ioctl: VIDIOC_ENUM_FMT
 Index : 0
 Type : Video Output Multiplanar
 Pixel Format: 'MPG2' (compressed)
 Name : MPEG-2 ES

 Index : 1
 Type : Video Output Multiplanar
 Pixel Format: 'H264' (compressed)
 Name : H.264

 Index : 2
 Type : Video Output Multiplanar
 Pixel Format: 'HEVC' (compressed)
 Name : HEVC

 Index : 3
 Type : Video Output Multiplanar
 Pixel Format: 'VP80' (compressed)
 Name : VP8

 Index : 4
 Type : Video Output Multiplanar
 Pixel Format: 'VP90' (compressed)
 Name : VP9



I've tried two approaches (Rust with bindgen) :


Approach 1 :


fn init_decoder() -> Arc<contextwrapper> {
 let name = CString::new("h264_v4l2m2m").unwrap();
 let codec = unsafe { ffmpeg::avcodec_find_decoder_by_name(name.as_ptr()) };
 if codec.is_null() {
 error!("finding codec");
 process::exit(1);
 }

 let ctx = unsafe { ffmpeg::avcodec_alloc_context3(codec) };
 if ctx.is_null() {
 error!("creating context");
 process::exit(1);
 }

 let r = unsafe { ffmpeg::avcodec_open2(ctx, codec, ptr::null_mut()) };
 if r < 0 {
 error!("opening codec: {r}");
 process::exit(1);
 }

 Arc::new(ContextWrapper(ctx))
}
</contextwrapper>


Results in :


[h264_v4l2m2m @ 0x7f1c001600] Could not find a valid device
[h264_v4l2m2m @ 0x7f1c001600] can't configure decoder
[ERROR] [decoder] [webrtc::codec] opening codec: -1



Approach 2


fn init_decoder() -> Arc<contextwrapper> {
 let name = CString::new("h264_v4l2m2m").unwrap();
 let codec = unsafe { ffmpeg::avcodec_find_decoder_by_name(name.as_ptr()) };
 if codec.is_null() {
 error!("finding codec");
 process::exit(1);
 }

 let mut i = 0;
 let mut hw_pix_fmt: AVPixelFormat = unsafe { mem::zeroed() };
 loop {
 let config = unsafe { ffmpeg::avcodec_get_hw_config(codec, i) };
 if config.is_null() {
 error!("decoder not supported");
 process::exit(1);
 }

 unsafe {
 info!("device type: {:?}", (*config).device_type);
 if ((*config).methods & ffmpeg::AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX as i32) > 0 {
 hw_pix_fmt = (*config).pix_fmt;
 break;
 }
 }
 }

 info!("pixel format: {:?}", hw_pix_fmt);

 let ctx = unsafe { ffmpeg::avcodec_alloc_context3(codec) };
 if ctx.is_null() {
 error!("creating context");
 process::exit(1);
 }

 let r = unsafe { ffmpeg::avcodec_open2(ctx, codec, ptr::null_mut()) };
 if r < 0 {
 error!("opening codec: {r}");
 process::exit(1);
 }

 Arc::new(ContextWrapper(ctx))
}

</contextwrapper>


Results in :

error!("decoder not supported");


I feel like there is a major step missing because looking at FFmpeg's Hardware Decode Example there are looking for a device type, to which v4l2 is not a part of the enum, so I do not what functions to call to get it setup.


What is the proper way to setup an AVCodec decoder with H.264 hardware acceleration for v4l2m2m ?


-
Everytime I run my code ffmpeg responds with this instead of doing its function. How do I fix ?
25 juillet 2023, par Oreo FOutput from ffmpeg/avlib:

ffmpeg version 2023-07-19-git-efa6cec759-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
 built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
 configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
 libavutil 58. 14.100 / 58. 14.100
 libavcodec 60. 22.100 / 60. 22.100
 libavformat 60. 10.100 / 60. 10.100
 libavdevice 60. 2.101 / 60. 2.101
 libavfilter 9. 8.102 / 9. 8.102
 libswscale 7. 3.100 / 7. 3.100
 libswresample 4. 11.100 / 4. 11.100
 libpostproc 57. 2.100 / 57. 2.100



Everytime I run the code it does this.


code :


import praw
import requests
import cv2
import os
from pydub import AudioSegment

def download_video(url, filename):
 response = requests.get(url)
 with open(filename, 'wb') as f:
 f.write(response.content)

def combine_videos(video_urls, output_filename):
 video_clips = []
 audio_clips = []
 for i, url in enumerate(video_urls):
 temp_filename = f'temp_video_{i}.mp4'
 download_video(url, temp_filename)
 video_clip = cv2.VideoCapture(temp_filename)
 audio_clip = AudioSegment.from_file(temp_filename, format="mp4")
 video_clips.append(video_clip)
 audio_clips.append(audio_clip)
 
 if not video_clips:
 print("No video clips to combine.")
 return

 frame_width = int(video_clips[0].get(cv2.CAP_PROP_FRAME_WIDTH))
 frame_height = int(video_clips[0].get(cv2.CAP_PROP_FRAME_HEIGHT))
 fps = int(video_clips[0].get(cv2.CAP_PROP_FPS))

 fourcc = cv2.VideoWriter_fourcc(*'mp4v')
 output_clip = cv2.VideoWriter(output_filename, fourcc, fps, (frame_width, frame_height))

 for i, video_clip in enumerate(video_clips):
 while True:
 ret, frame = video_clip.read()
 if not ret:
 break
 output_clip.write(frame)
 
 for video_clip in video_clips:
 video_clip.release()
 
 output_clip.release()

 # Combining audio using pydub
 combined_audio = sum(audio_clips)
 combined_audio.export("combined_audio.mp3", format="mp3")

 # Merging audio with video using ffmpeg
 os.system(f'ffmpeg -i {output_filename} -i combined_audio.mp3 -c:v copy -c:a aac -strict experimental -map 0:v:0 -map 1:a:0 final_output.mp4')

 # Cleaning up temporary files
 os.remove("combined_audio.mp3")

def main():
 reddit = praw.Reddit(
 client_id='XXX',
 client_secret='XXX',
 user_agent='Reddit Video Downloader'
 )
 
 subreddit_name = input("Enter the name of the subreddit: ")
 limit = int(input("Enter the number of videos to download: "))
 
 subreddit = reddit.subreddit(subreddit_name)
 submissions = subreddit.hot(limit=limit)
 
 video_urls = [submission.url for submission in submissions if submission.media and 'reddit_video' in submission.media]
 
 if video_urls:
 output_filename = input("Enter the output filename (e.g., output.mp4): ")
 combine_videos(video_urls, output_filename)
 print("Videos combined successfully!")
 else:
 print("No Reddit videos found in the subreddit.")

if __name__ == "__main__":
 main()



Anyone got any idea why this happens ?


I'm making a script that scrapes videos from a specific subreddit.


Also if it helps the temp video file is corrupted when it gets made.


I've put this into chatGPT as well and brought an expert friend and he hasn't been able to help me.


-
FFMPEG Fontconfig error : Cannot load default config file : No such file : (null) Abort trap
28 juillet 2023, par FastNumbers/usr/local/bin/ffmpeg -loop 1 -t 11.14 -i 3339861349.jpg -filter_complex "drawtext=text=aaaaa" -r 25 -vcodec libx264 -preset veryfast -threads 8 -x264opts no-scenecut -b 850k -bt 850k -ac 2 -ab 32k -async 1 -y -f mp4 test.mp4
Give me result
Fontconfig error : Cannot load default config file : No such file : (null)
Abort trap


With path to font file :
/usr/local/bin/ffmpeg -loop 1 -t 11.14 -i 3339861349.jpg -filter_complex "drawtext=text=aaaaa:fontfile=/usr/local/share/fonts/Roboto-Regular.ttf" -r 25 -vcodec libx264 -preset veryfast -threads 8 -x264opts no-scenecut -b 850k -bt 850k -ac 2 -ab 32k -async 1 -y -f mp4 test.mp4
Give me result
Abort trap


Rebild ffmpeg with —enable-libfontconfig


ffmpeg version 6.0-6.0 Copyright (c) 2000-2023 the FFmpeg developers
built with FreeBSD clang version 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a303)
configuration : —enable-gpl —enable-gmp —enable-gnutls —enable-libdav1d —enable-libsvtav1 —enable-librav1e —enable-libvmaf —enable-libx264 —enable-chromaprint —enable-libx265 —enable-libvpx —enable-libxvid —enable-libvidstab —enable-libaom —enable-libzimg —enable-libmodplug —enable-libsoxr —enable-libmysofa —enable-lv2 —enable-libopencore_amrnb —enable-libopencore_amrwb —enable-libmp3lame —enable-libopus —enable-libvorbis —enable-libtwolame —enable-libspeex —enable-lv2 —enable-libtheora —enable-librubberband —enable-libgme —enable-libwebp —enable-libzmq —enable-libfribidi —enable-libfontconfig —enable-libfreetype —enable-libass —enable-runtime-cpudetect —cc=cc —cxx=cpp —disable-ffplay —disable-debug —disable-doc —disable-shared —enable-pthreads —enable-static —enable-small —enable-version3 —extra-cflags='-static -I/usr/home/azureagent/vsts/_work/1/s/FFmpeg/workspace/include -I/usr/home/azureagent/vsts/_work/1/s/FFmpeg/workspace/include/lilv-0 -I/usr/home/azureagent/vsts/_work/1/s/FFmpeg/workspace/include/lilv-0' —extra-cxxflags='-static -static-libstdc++' —extra-ldexeflags= —extra-ldflags=-L/usr/home/azureagent/vsts/_work/1/s/FFmpeg/workspace/lib —extra-libs='-static -lc++ -ldl -lpthread -lm -lmd -lz -lfftw3' —pkgconfigdir=/usr/home/azureagent/vsts/_work/1/s/FFmpeg/workspace/lib/pkgconfig —pkg-config-flags=—static —prefix=/usr/home/azureagent/vsts/_work/1/s/FFmpeg/workspace/done/ —extra-version=6.0