
Recherche avancée
Autres articles (48)
-
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
Les statuts des instances de mutualisation
13 mars 2010, parPour des raisons de compatibilité générale du plugin de gestion de mutualisations avec les fonctions originales de SPIP, les statuts des instances sont les mêmes que pour tout autre objets (articles...), seuls leurs noms dans l’interface change quelque peu.
Les différents statuts possibles sont : prepa (demandé) qui correspond à une instance demandée par un utilisateur. Si le site a déjà été créé par le passé, il est passé en mode désactivé. publie (validé) qui correspond à une instance validée par un (...) -
Déploiements possibles
31 janvier 2010, parDeux types de déploiements sont envisageable dépendant de deux aspects : La méthode d’installation envisagée (en standalone ou en ferme) ; Le nombre d’encodages journaliers et la fréquentation envisagés ;
L’encodage de vidéos est un processus lourd consommant énormément de ressources système (CPU et RAM), il est nécessaire de prendre tout cela en considération. Ce système n’est donc possible que sur un ou plusieurs serveurs dédiés.
Version mono serveur
La version mono serveur consiste à n’utiliser qu’une (...)
Sur d’autres sites (6553)
-
ffserver : translate cropped video
26 janvier 2021, par Michael O.I'm getting the h264 video from IP camera. I need to crop it and retranslate with
ffserver
. Here is the commandffmpeg
to get a stream :

ffmpeg -rtsp_transport tcp -i "rtsp://admin:@192.168.88.10:554/channel=1&stream=0.sdp" -filter:v "crop=400:250:800:1045" -vcodec h264 tmp.mp4



It works fine and I get the cropped video in the file
tmp.mp4
.

Here are the
ffserver
settings :

<feed>
File /tmp/feed1.ffm
FileMaxSize 200M
Launch ffmpeg -rtsp_transport tcp -i "rtsp://admin:@192.168.88.10:554/channel=1&stream=0.sdp" -filter:v "crop=400:250:800:1045" -vcodec h264
</feed>
<stream>
Feed feed1.ffm
Format mjpeg
VideoBitRate 1000
VideoBufferSize 400
VideoFrameRate 17
VideoSize 400x250
VideoGopSize 10
NoAudio
Preroll 5
NoDefaults
</stream>



Trying to launch
ffserver
:

$ ffserver -loglevel debug -d -f /etc/ffserver.conf
ffserver started on 2021-01-27 at 01:02:43
Report written to "ffserver-20210127-010243.log"
ffserver version 3.4.8-0ubuntu0.2 Copyright (c) 2000-2020 the FFmpeg developers
 built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
 configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
 libavutil 55. 78.100 / 55. 78.100
 libavcodec 57.107.100 / 57.107.100
 libavformat 57. 83.100 / 57. 83.100
 libavdevice 57. 10.100 / 57. 10.100
 libavfilter 6.107.100 / 6.107.100
 libavresample 3. 7. 0 / 3. 7. 0
 libswscale 4. 8.100 / 4. 8.100
 libswresample 2. 9.100 / 2. 9.100
 libpostproc 54. 7.100 / 54. 7.100
Wed Jan 27 01:02:43 2021 [NULL @ 0x55769974cbc0]Opening '/tmp/feed1.ffm' for reading
Wed Jan 27 01:02:43 2021 [file @ 0x557699755300]Setting default whitelist 'file,crypto'
Wed Jan 27 01:02:43 2021 [ffm @ 0x55769974cbc0]Format ffm probed with size=2048 and score=101
Wed Jan 27 01:02:43 2021 [NULL @ 0x557699757320]Setting entry with key 'b' to value '1000000'
Wed Jan 27 01:02:43 2021 [NULL @ 0x557699757320]Setting entry with key 'bufsize' to value '3276800'
Wed Jan 27 01:02:43 2021 [NULL @ 0x557699757320]Setting entry with key 'time_base' to value '1/17'
Wed Jan 27 01:02:43 2021 [NULL @ 0x557699757320]Setting entry with key 'video_size' to value '400x250'
Wed Jan 27 01:02:43 2021 [NULL @ 0x557699757320]Setting entry with key 'g' to value '10'
Wed Jan 27 01:02:43 2021 Codecs do not match for stream 0
Wed Jan 27 01:02:43 2021 [AVIOContext @ 0x55769974d7a0]Statistics: 4096 bytes read, 0 seeks
Wed Jan 27 01:02:43 2021 [file @ 0x5576997552e0]Setting default whitelist 'file,crypto'
Wed Jan 27 01:02:43 2021 [ffm @ 0x55769974cbc0]Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Wed Jan 27 01:02:43 2021 writing recommended configuration: b=1000000,bufsize=3276800,time_base=1/17,video_size=400x250,g=10
Wed Jan 27 01:02:43 2021 [AVIOContext @ 0x557699757be0]Statistics: 0 seeks, 1 writeouts
Wed Jan 27 01:02:43 2021 FFserver started.
Wed Jan 27 01:02:43 2021 Launch command line: ./ffmpeg -rtsp_transport tcp -i rtsp://admin:@192.168.88.10:554/channel=1&stream=0.sdp -filter:v crop=400:250:800:1045 -vcodec h264 http://127.0.0.1:8090/feed1.ffm 
feed1.ffm: Pid 30808 exited with status 256 after 0 seconds



There is the line :


Codecs do not match for stream 0



every time when I try to launch it. I tried various video formats : mpjpeg, avi, mpeg, flv, mp4, webm, and the result is the same. How can I successfully launch
ffserver
?

-
How to schedule ffmpeg audio streams of varying lengths with titles and metadata ?
10 septembre 2021, par underdootI have a Shoutcast stream that I want to archive 24/7 with ffmpeg. Shows on this stream vary in length between 1-3 hours, but have a regular weekly schedule.


How do I download these shows, and give the files appropriate titles according to the show playing (determined by day of week and hour of day) ? I want the title of files to be along the lines of "2021.09.21 - 0300-0400 — Radio Show Name" and automatically add to a set folder. I also want to run the program only once, and have it running in the background constantly.


-
FFMPEG Api conversion from YUV420P to RGB produces strange output
20 novembre 2024, par fasc8I'm using the FFMPEG Api in Rust to get RGB images from video files.


While some videos work correct and I get the frames back as expected, some work not. Or at least the result is not the way I expected it to be.


The code I use in Rust :


ffmpeg::init().unwrap();

let in_ctx = input(&Path::new(source)).unwrap();
let input = in_ctx
 .streams()
 .best(Type::Video)
 .ok_or(ffmpeg::Error::StreamNotFound)?;

let decoder = input.codec().decoder().video()?;

let scaler = Context::get(
 decoder.format(),
 decoder.width(),
 decoder.height(),
 Pixel::RGB24,
 decoder.width(),
 decoder.height(),
 Flags::FULL_CHR_H_INT | Flags::ACCURATE_RND,
)?; // <--- Is basically sws_getContext

// later to get the actual frame
let mut decoded = Video::empty();
if self.decoder.receive_frame(&mut decoded).is_ok() {
 let mut rgb_frame = Video::empty();
 self.scaler.run(&decoded, &mut rgb_frame)?; // <--- Does sws_scale
 println!("Converted Pixel Format: {}", rgb_frame.format() as i32);
 Ok(Some(rgb_frame))
}



Which should roughly translate to C like so :


// Get the context and video stream
SwsContext * ctx = sws_getContext(imgWidth, imgHeight,
 imgFormat, imgWidth, imgHeight,
 AV_PIX_FMT_RGB24, 0, 0, 0, 0);
sws_scale(ctx, decoded.data, decoded.linesize, 0, decoded.height, rgb_frame.data, rbg_frame.linesize);



And like I said earlier, sometimes it works fine and I get the expected frame back. But sometimes I get something like this :
Weird result image


I saved the images as .ppm files for quick visual comparison. I used this method, which basically writes the bytes to a file with a simple .ppm header :


fn save_file(frame: &Video, index: usize) -> std::result::Result<(), std::io::Error> 
{
 let mut file = File::create(format!("frame{}.ppm", index))?;
 file.write_all(format!("P6\n{} {}\n255\n", frame.width(), frame.height()).as_bytes())?;
 file.write_all(frame.data(0))?;
 Ok(())
}



Here you can see that on the left side there is a good image result vs. on the right side there is a bad image result.
Comparison of the .ppm files


To come to the question now :


Why is this happening. I tested everything on my side and the only thing left is ffmpeg conversion. FFMPEG seems to convert these two test files differently even though it reports YUV420P as format for both. I cannot figure out what the difference may be...


Here the info for the two video files i used :


Good video file :


General
Complete name : /mnt/smb/Snapchat-174933781.mp4
Format : MPEG-4
Format profile : Base Media / Version 2
Codec ID : mp42 (isom/mp42)
File size : 1.90 MiB
Duration : 9 s 612 ms
Overall bit rate : 1 661 kb/s
Encoded date : UTC 2021-07-28 22:09:36
Tagged date : UTC 2021-07-28 22:09:36
eng : -180.00

Video
ID : 512
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L3.1
Format settings : CABAC / 1 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 1 frame
Format settings, GOP : M=1, N=30
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 9 s 598 ms
Bit rate : 1 597 kb/s
Width : 480 pixels
Height : 944 pixels
Display aspect ratio : 0.508
Frame rate mode : Variable
Frame rate : 29.797 FPS
Minimum frame rate : 15.000 FPS
Maximum frame rate : 30.000 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.118
Stream size : 1.83 MiB (96%)
Title : Snap Video
Language : English
Encoded date : UTC 2021-07-28 22:09:36
Tagged date : UTC 2021-07-28 22:09:36
Color range : Full
colour_range_Original : Limited
Color primaries : BT.709
Transfer characteristics : BT.601
transfer_characteristics_Original : BT.709
Matrix coefficients : BT.709
Codec configuration box : avcC

Audio
ID : 256
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Codec ID : mp4a-40-2
Duration : 9 s 612 ms
Bit rate mode : Constant
Bit rate : 62.0 kb/s
Channel(s) : 1 channel
Channel layout : C
Sampling rate : 44.1 kHz
Frame rate : 43.066 FPS (1024 SPF)
Compression mode : Lossy
Stream size : 73.3 KiB (4%)
Title : Snap Audio
Language : English
Encoded date : UTC 2021-07-28 22:09:36
Tagged date : UTC 2021-07-28 22:09:36



Bad video file :


General
Complete name : /mnt/smb/Snapchat-1989594918.mp4
Format : MPEG-4
Format profile : Base Media / Version 2
Codec ID : mp42 (isom/mp42)
File size : 2.97 MiB
Duration : 6 s 313 ms
Overall bit rate : 3 948 kb/s
Encoded date : UTC 2019-07-11 06:43:04
Tagged date : UTC 2019-07-11 06:43:04
com.android.version : 9

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Baseline@L3.1
Format settings : 1 Ref Frames
Format settings, CABAC : No
Format settings, Reference frames : 1 frame
Format settings, GOP : M=1, N=30
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 6 s 313 ms
Bit rate : 3 945 kb/s
Width : 496 pixels
Height : 960 pixels
Display aspect ratio : 0.517
Frame rate mode : Variable
Frame rate : 29.306 FPS
Minimum frame rate : 19.767 FPS
Maximum frame rate : 39.508 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.283
Stream size : 2.97 MiB (100%)
Title : VideoHandle
Language : English
Encoded date : UTC 2019-07-11 06:43:04
Tagged date : UTC 2019-07-11 06:43:04
Color range : Limited
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709
Codec configuration box : avcC



Or as a diff image :


The problem is that I am not that familiar with ffmpeg yet I don't know all the quirks it has.


I hope someone can point me in the right direction.