Recherche avancée

Médias (91)

Autres articles (25)

  • List of compatible distributions

    26 avril 2011, par

    The table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
    If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...)

  • Selection of projects using MediaSPIP

    2 mai 2011, par

    The examples below are representative elements of MediaSPIP specific uses for specific projects.
    MediaSPIP farm @ Infini
    The non profit organizationInfini develops hospitality activities, internet access point, training, realizing innovative projects in the field of information and communication technologies and Communication, and hosting of websites. It plays a unique and prominent role in the Brest (France) area, at the national level, among the half-dozen such association. Its members (...)

  • Sélection de projets utilisant MediaSPIP

    29 avril 2011, par

    Les exemples cités ci-dessous sont des éléments représentatifs d’usages spécifiques de MediaSPIP pour certains projets.
    Vous pensez avoir un site "remarquable" réalisé avec MediaSPIP ? Faites le nous savoir ici.
    Ferme MediaSPIP @ Infini
    L’Association Infini développe des activités d’accueil, de point d’accès internet, de formation, de conduite de projets innovants dans le domaine des Technologies de l’Information et de la Communication, et l’hébergement de sites. Elle joue en la matière un rôle unique (...)

Sur d’autres sites (2661)

  • ffmpeg h264 to mp4 conversion from multiple files fails to preserve in-sequence resolution changes

    1er juillet 2023, par LB2

    This 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.

    


    Example of squishing problem

    


    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 with ffprobe it seems that it uses SAR weird ratios, where first frames are width=1440 height=3040 sample_aspect_ratio=1:1, but later SAR takes on values like width=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 ?

    


  • FFmpeg - How to choose video stream based on resolution

    23 septembre 2023, par Sylven

    I want to choose the video stream based on it's quality, let's say I want to choose one video stream with certain resolution.

    


    Manually selecting the video stream is not good enough for me because I want to process many files in bulk and they have the video streams in different order, so always going for certain position would make me end up with different resolutions.

    


    I don't want to use filters as that would make me reencode which I don't need and would make it way slower.

    


    I've tried using the -map with metadata but the only key that is different is "variant_bitrate" which has slightly different values everytime, so unless I can use some wildcard or conditionals, I guess it won't work either.

    


    What I want to try now is to obtain the exact bitrate of the stream using ffmpeg or ffprobe and then pass it to the ffmpeg command so it ends in something like this :

    


    ffmpeg -i <url> -map m:variant_bitrate:1760000 ...</url>

    &#xA;

    PD : I've been reading the FFmpeg documentation and browsing the whole internet without luck.

    &#xA;

    Edit :&#xA;I managed to make it work by first using ffprobe to obtain stream info in json format (easier to parse), then I search for the string "height": 540 and extract next 50 lines (counted them manually so I'm sure I'll pick the value I need), then I search for the string variant_bitrate and then I use a regular expression to extract the bitrate. Once I have the bitrate I make use of the MacOS clipboard (with pbcopy and pbpaste) to pass the value to the final ffmpeg command through the -map option using a metadata selector.

    &#xA;

    ffprobe -v error -show_streams -of json "https://streamlink.com/master.m3u8?f=dash"&#xA;| grep -A 50 &#x27;"height": 540&#x27; &#xA;| grep variant_bitrate&#xA;| grep -oe &#x27;\([0-9.]*\)&#x27; &#xA;| pbcopy&#xA;&amp;&amp; ffmpeg -protocol_whitelist file,http,https,tcp,tls,crypto -i "https://streamlink.com/master.m3u8?f=dash" -map "0:a:0" -map "m:variant_bitrate:$(pbpaste)" -c copy "Output.mp4"&#xA;

    &#xA;

    (added line breaks for readability)

    &#xA;

    I know it looks kinda dirty but I didn't find any other way to achieve my requirement.

    &#xA;

  • ffmpeg padding doesn't scale when changing resolution

    5 mars 2023, par Martin

    I have a ffmpeg command which takes a bunch of audio files, 3 image files, and renders a video with them.

    &#xA;

    Image Input Dimmensions :

    &#xA;

      &#xA;
    • 1_front.jpg 600w x 593h
    • &#xA;

    • 2_back.jpg 600w x 466h
    • &#xA;

    • 3_cd.jpg 600w x 598h
    • &#xA;

    &#xA;

    The video has a resolution of w=600 h=593, which is the resolution of the first img.

    &#xA;

    Here's the full command

    &#xA;

    ffmpeg&#xA; -r 2 -i "E:\filepath\10. Deejay Punk-Roc - Knock &#x27;em All The Way Out.aiff"&#xA; -r 2 -i "E:\filepath\11. Deejay Punk-Roc - Spring Break.aiff" -r 2 -i "E:\filepath\12. Deejay Punk-Roc - Fat Gold Chain.aiff" &#xA; -r 2 -i "E:\filepath\1_front.jpg" -r 2 -i "E:\filepath\2_back.jpg" -r 2 -i "E:\filepath\3_cd.jpg" &#xA; &#xA; -filter_complex &#xA; "&#xA; [0:a][1:a][2:a]concat=n=3:v=0:a=1[a]; &#xA; &#xA; [3:v]scale=w=600:h=593,setsar=1,loop=580.03:580.03[v3]; &#xA;&#xA; [4:v]pad=600:593:0:63:color=pink,setsar=1,loop=580.03:580.03[v4];&#xA; &#xA; [5:v]scale=w=600:h=593,setsar=1,loop=580.03:580.03[v5];&#xA; &#xA; [v3][v4][v5]concat=n=3:v=1:a=0,pad=ceil(iw/2)*2:ceil(ih/2)*2[v]"&#xA; &#xA;  -map "[v]" -map "[a]" -c:a pcm_s32le -c:v libx264 -bufsize 3M -crf 18 -pix_fmt yuv420p -tune stillimage -t 870.04 &#xA;  "E:\filepath\vidOutPutCorrect.mkv"&#xA;&#xA;

    &#xA;

    For filter_complex this second part will add padding to the second image so that it does not get stretched or cropped.

    &#xA;

    [4:v]pad=600:593:0:63:color=pink,setsar=1,loop=580.03:580.03[v4];&#xA;

    &#xA;

    Specifically this part

    &#xA;

    pad=600:593:0:63:color=pink&#xA;

    &#xA;

    Which I understand means w=600 and h=593, but i dont know that the last part 0:63 means.

    &#xA;

    You can see the output has the pink padding correctly&#xA;enter image description here

    &#xA;

    but i want to render the video with a resolution of w=1920 h=1898 instead of w=600 h=593.

    &#xA;

    So i update the command to have this new resolution :

    &#xA;

    ffmpeg -r 2 -i "E:\filepath\10. Deejay Punk-Roc - Knock &#x27;em All The Way Out.aiff" -r 2 -i "E:\filepath\11. Deejay Punk-Roc - Spring Break.aiff" -r 2 -i "E:\filepath\12. Deejay Punk-Roc - Fat Gold Chain.aiff" -r 2 -i "E:\filepath\1_front.jpg" -r 2 -i "E:\filepath\2_back.jpg" -r 2 -i "E:\filepath\3_cd.jpg" &#xA;&#xA;-filter_complex "&#xA;[0:a][1:a][2:a]concat=n=3:v=0:a=1[a];&#xA;&#xA;[3:v]scale=w=1920:h=1898,setsar=1,loop=580.03:580.03[v3];&#xA;&#xA;[4:v]pad=1920:1898:0:63:color=pink,setsar=1,loop=580.03:580.03[v4];&#xA;&#xA;[5:v]scale=w=1920:h=1898,setsar=1,loop=580.03:580.03[v5];&#xA;&#xA;[v3][v4][v5]concat=n=3:v=1:a=0,pad=ceil(iw/2)*2:ceil(ih/2)*2[v]"&#xA;&#xA; -map "[v]" -map "[a]" -c:a pcm_s32le -c:v libx264 -bufsize 3M -crf 18 -pix_fmt yuv420p -tune stillimage -t 870.04 "E:\filepath\slidet.mkv"&#xA;

    &#xA;

    my video does in fact now have a resolution of 1920x1798 which is great, but the 2nd image padding portion has the image super small and in a corner

    &#xA;

    enter image description here

    &#xA;

    So this line works :

    &#xA;

    pad=600:593:0:63:color=pink&#xA;

    &#xA;

    but with a different resolution is looks bad with the image in the top left corner

    &#xA;

    pad=1920:1898:0:63:color=pink&#xA;

    &#xA;

    What do I need to change 0:63 to in order to have the image be centered ?

    &#xA;

    Download files : http://www.mediafire.com/folder/e8ja1n8elszk1lu,dxw4vglrz7polyh,ojjx6kcqruksv5r,lah9rano4svj46o,q5jg0083vbj9y1p,d3pt8ydf3ulqm5m/shared

    &#xA;