
Recherche avancée
Médias (2)
-
GetID3 - Bloc informations de fichiers
9 avril 2013, par
Mis à jour : Mai 2013
Langue : français
Type : Image
-
GetID3 - Boutons supplémentaires
9 avril 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Image
Autres articles (38)
-
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
-
Les formats acceptés
28 janvier 2010, parLes commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
ffmpeg -codecs ffmpeg -formats
Les format videos acceptés en entrée
Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
Les formats vidéos de sortie possibles
Dans un premier temps on (...) -
Supporting all media types
13 avril 2011, parUnlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)
Sur d’autres sites (5335)
-
ffmpeg h264 to mp4 conversion from multiple files fails to preserve in-sequence resolution changes
1er juillet 2023, par LB2This will be a long post, so I thank you in advance for your patience in digesting it.


Context


I have different sources that generate visual content that eventually need to be all composed into a single .mp4 file. The sources are :


- 

- H.264 video (encoded using CUDA NVENC).

- 

- This video can have in-sequence resolution change that is natively supported by H.264 codec.
- I.e. stream may start as HxW resolution and mid-stream change to WxH. This behavior happens because it comes from a camera device that can be rotated and flipped between portrait and landscape (e.g. think of a phone camera recording video and phone being flipped from one orientation to another, and video recording adjusting its encoding for proper video scaling and orientation).
- When rotation occurs, most of the time H & W are just swaps, but may actually be entirely new values — e.g. in some cases 1024x768 will switch to 768x1024, but in other cases 1024x768 may become 460x640 (depends on source camera capabilities that I have no control over).








- JPEGs. A series (a.k.a. batch) of still JPEGs.

- 

- The native resolution of JPEGs may or may not match the video resolution in the earlier bullet.
- JPEGs can also reflect rotation of device and so some JPEGs in a sequence may start at HxW resolution and then from some arbitrary JPEG file can flip and become WxH. Similar to video, resolution dimensions are likely to be just a swap, but may become altogether different values.






- There can be any number of batches and intermixes between video and still sources. E.g. V1 + S2 + S3 + V4 + V5 + V6 + S7 + ...
- There can be any number of resolution changes between or within batches. e.g. V1 ;r1 + V1 ;r2 + S2 ;r1 + S2 ;r3 + V3 ;r2 + ... (where first subscript is batch sequence ; rX is resolution)










Problem


I'm attempting to do this conversion with
ffmpeg
and can't quite get it right. The problem is that I can't get output to respect source resolutions, and it just squishes all into a single output resolution.



As already mentioned above, H.264 supports resolution changes in-sequence (mid-stream), and it should be possible to convert and concatenate all the content and have final output contain in-sequence resolution changes.


Since MP4 is just a container, I'm assuming that MP4 files can do so as well ?


Attempts so far


The approach thus far has been to take each batch of content (i.e. .h264 video or a set of JPEGs), and individually convert to .mp4. Video is converted using
-c copy
to ensure it doesn't try to transcode, e.g. :

ffmpeg -hide_banner -i videoX.h264 -c copy -vsync vfr -video_track_timescale 90000 intermediateX.mp4



... and JPEGs are converted using
-f concat


ffmpeg -hide_banner -f concat -safe 0 -i jpegsX.txt -vf 'scale=trunc(iw/2)*2:trunc(ih/2)*2' -r 30 -vsync vfr -video_track_timescale 90000 intermediateX.mp4



... and then all the intermediates concatenated together


ffmpeg -hide_banner -f concat -safe 0 -i final.txt -pix_fmt yuv420p -c copy -vsync vfr -video_track_timescale 90000 -metadata title='yabadabadoo' -fflags +bitexact -flags:v +bitexact -flags:a +bitexact final.mp4



This concatenates, but if resolution changes at some mid point, then that part of content comes up squished/stretched in final output.


Use h.264 as intermediates


All the intermediates are produced the same, except as .h264. All intermediate .h264 are
cat
'ed together like `cat intermediate1.h264 intermediate2.264 > final.h264.

If final output is
final.mp4
, the output is incorrect and images are squished/stretched.

If
final.h264
, then at least it seems to be respecting aspect ratios of input and managing to produce correctly looking output. However, examining withffprobe
it seems that it uses SAR weird ratios, where first frames arewidth=1440 height=3040 sample_aspect_ratio=1:1
, but later SAR takes on values likewidth=176 height=340 sample_aspect_ratio=1545:176
, which I suspect isn't right, since all original input was with "square pixels". I think the reason for it is that it was composed out of different sized JPEGs, and concat filter somehow caused ffmpeg to manipulate SAR "to get things fit".

But at least it renders respectably, though hard to say with
ffplay
if player would actually see resolution change and resize accordingly .

And, that's .h264 ; and I need final output to be .mp4.


Use
-vf
filter

I tried enforcing SAR using
-vf 'scale=trunc(iw/2)*2:trunc(ih/2)*2,setsar=1:1'
(scaling is to deal with odd dimension JPEGs), but it still produces frames with SAR like stated earlier.

Other thoughts


For now, while I haven't given up, I'm trying to avoid in my code examining each individual JEPG in a batch to see if there are differing sizes, and splitting batch so that each sub-batch is homogenous resolution-wise, and generating individual intermediate .h264 so that SAR remains sane, and keep fingers crossed that the final would work correctly. It'll be very slow, unfortunately.


Question


What's the right way to deal with all that using
ffmpeg
, and how to concatenate mulitple varying resolution sources into a final mp4 so that it respects resolution changes mid-stream ?

- H.264 video (encoded using CUDA NVENC).

-
How to use ffmpeg to upscale video resolution with anime4k ?
29 juillet 2023, par IronboxIn Vapoursynth, it is convenient to download and use plugins to change the frame rate of videos. However, it seems that using FFmpeg has more limitations (or maybe I haven't found the right method). Anime4K is a video enhancement algorithm suitable for anime and similar videos. In MPV, their plugins can be imported and used for real-time frame rate conversion.


In FFmpeg, how can I use the algorithms in glsl files to change the video frame rate, instead of using FFmpeg's built-in algorithms ?


In FFmpeg, i can use libplacebo filters can also be used to apply GLSL shaders. In my tests, using command like :


libplacebo=custom_shader_path=Anime4K_Upscale_CNN_x2_VL.glsl



this leads to noticeable GPU usage, but the output video resolution remains the same as the original.


I can pass in the w and h parameters when calling the libplacebo filter :


libplacebo=w=iw*2:h=ih*2:custom_shader_path=shaders/Anime4K_Upscale_CNN_x2_VL.glsl



This achieves the purpose of super resolution, but is it essentially using anime4k for upscaling behind the processing ?
Is it using the upscaling algorithm in libplacebo first, before applying anime4k ? How can I achieve my original goal that only use anime4k to upscale ?
here's my full command (in python) :


[
 'ffmpeg -hide_banner',
 '-hwaccel', 'cuda',
 '-i', '"{input_ab_path}"',
 '-filter_complex',
 '"[0:v]libplacebo=custom_shader_path=libplacebo=custom_shader_path=shaders/Anime4K_Upscale_CNN_x2_VL.glsl,subtitles="{sub_file}":si=0[out]"',
 '-map', '0:a',
 '-map', '"[out]"',
 '-c:v', 'libsvtav1',
 '-svtav1-params', 'scm=2:scd=1:enable-overlays=1:enable-tf=0:tune=0:preset=7:crf=18',
 '-c:a', 'libvorbis',
 '-qscale:a', '10',
 '-pix_fmt', 'yuv420p10le',
 '-y', '"{output_ab_path}"'
]



-
How to use ffmpeg to upscale video resolution with libplacebo ?
30 juillet 2023, par IronboxIn Vapoursynth, it is convenient to download and use plugins to change the frame rate of videos. However, it seems that using FFmpeg has more limitations (or maybe I haven't found the right method). Anime4K is a video enhancement algorithm suitable for anime and similar videos. In MPV, their plugins can be imported and used for real-time frame rate conversion.


In FFmpeg, how can I use the algorithms in glsl files to change the video frame rate, instead of using FFmpeg's built-in algorithms ?


In FFmpeg, i can use libplacebo filters can also be used to apply GLSL shaders. In my tests, using command like :


libplacebo=custom_shader_path=Anime4K_Upscale_CNN_x2_VL.glsl



this leads to noticeable GPU usage, but the output video resolution remains the same as the original.


I can pass in the w and h parameters when calling the libplacebo filter :


libplacebo=w=iw*2:h=ih*2:custom_shader_path=shaders/Anime4K_Upscale_CNN_x2_VL.glsl



This achieves the purpose of super resolution, but is it essentially using anime4k for upscaling behind the processing ?
Is it using the upscaling algorithm in libplacebo first, before applying anime4k ? How can I achieve my original goal that only use anime4k to upscale ?
here's my full command (in python) :


[
 'ffmpeg -hide_banner',
 '-hwaccel', 'cuda',
 '-i', '"{input_ab_path}"',
 '-filter_complex',
 '"[0:v]libplacebo=custom_shader_path=libplacebo=custom_shader_path=shaders/Anime4K_Upscale_CNN_x2_VL.glsl,subtitles="{sub_file}":si=0[out]"',
 '-map', '0:a',
 '-map', '"[out]"',
 '-c:v', 'libsvtav1',
 '-svtav1-params', 'scm=2:scd=1:enable-overlays=1:enable-tf=0:tune=0:preset=7:crf=18',
 '-c:a', 'libvorbis',
 '-qscale:a', '10',
 '-pix_fmt', 'yuv420p10le',
 '-y', '"{output_ab_path}"'
]