Newest 'x264' Questions - Stack Overflow

http://stackoverflow.com/questions/tagged/x264

Les articles publiés sur le site

  • Generating movie from python without saving individual frames to files

    31 juillet 2022, par Paul

    I would like to create an h264 or divx movie from frames that I generate in a python script in matplotlib. There are about 100k frames in this movie.

    In examples on the web [eg. 1], I have only seen the method of saving each frame as a png and then running mencoder or ffmpeg on these files. In my case, saving each frame is impractical. Is there a way to take a plot generated from matplotlib and pipe it directly to ffmpeg, generating no intermediate files?

    Programming with ffmpeg's C-api is too difficult for me [eg. 2]. Also, I need an encoding that has good compression such as x264 as the movie file will otherwise be too large for a subsequent step. So it would be great to stick with mencoder/ffmpeg/x264.

    Is there something that can be done with pipes [3]?

    [1] http://matplotlib.sourceforge.net/examples/animation/movie_demo.html

    [2] How does one encode a series of images into H264 using the x264 C API?

    [3] http://www.ffmpeg.org/ffmpeg-doc.html#SEC41

  • h264 lossless coding

    19 juillet 2022, par cloudraven

    Is it possible to do completely lossless encoding in h264? By lossless, I mean that if I feed it a series of frames and encode them, and then if I extract all the frames from the encoded video, I will get the exact same frames as in the input, pixel by pixel, frame by frame. Is that actually possible? Take this example:

    I generate a bunch of frames, then I encode the image sequence to an uncompressed AVI (with something like virtualdub), I then apply lossless h264 (the help files claim that setting --qp 0 makes lossless compression, but I am not sure if that means that there is no loss at any point of the process or that just the quantization is lossless). I can then extract the frames from the resulting h264 video with something like mplayer.

    I tried with Handbrake first, but it turns out it doesn't support lossless encoding. I tried x264 but it crashes. It may be because my source AVI file is in RGB colorspace instead of YV12. I don't know how to feed a series of YV12 bitmaps and in what format to x264 anyway, so I cannot even try.

    In summary what I want to know if that is there a way to go from

    Series of lossless bitmaps (in any colorspace) -> some transformation -> h264 encode -> h264 decode -> some transformation -> the original series of lossless bitmaps

    If there a way to achieve this?

    EDIT: There is a VERY valid point about lossless H264 not making too much sense. I am well aware that there is no way I could tell (with just my eyes) the difference between and uncompressed clip and another compressed at a high rate in H264, but I don't think it is not without uses. For example, it may be useful for storing video for editing without taking huge amounts of space and not losing quality and spending too much encoding time every time the file is saved.

    UPDATE 2: Now x264 doesn't crash. I can use as sources either avisynth or lossless yv12 lagarith (to avoid the colorspace compression warning). Howerver, even with --qp 0 and a rgb or yv12 source I still get some differences, minimal but present. This is troubling, because all the information I have found on lossless predictive coding (--qp 0) claims that the whole encoding should be lossless, but I am unable to verifiy this.

  • Why does FFMPEG b-frames and b_pyramid offset start_pts (and start_time) in fragmented output ?

    13 juillet 2022, par Vans S

    It seems when transcoding something into fragmented or segmented output the start_pts is not 0, and no combination of options can make it 0 other than setting bframes to 0 and bpyramid to 0. This does not happen with regular nonfragmented output.

    Does anyone know why this is, and how to prevent it as I believe this is causing weird timesync issues with playback in browsers (every fragment slightly delays the video more and more) where after 2-3 hours the stream can end up 15minutes+ delayed.

    Example where each segment start_pts is not 0:

    ffmpeg -i in.mp4 -pix_fmt yuv420p -an -f yuv4mpegpipe -frames:v 150 - | ffmpeg -f yuv4mpegpipe -i - -y -force_key_frames 1,2,3,4 -map 0 -codec:v libx264 -f segment -segment_list out.csv -segment_times 2,4 -segment_time_delta 0.05 -preset:v fast -segment_format_options movflags=+faststart out%03d.mp4
    

    start_pts is 0 here if we add:

    -x264opts b_pyramid=0 -bf 0 
    #or change codec to
    -codec:v mpeg4
    #or output regular mp4
    ffmpeg -i in.mp4 -pix_fmt yuv420p -an -f yuv4mpegpipe -frames:v 150 - | ffmpeg -f yuv4mpegpipe -i - -y out.mp4
    

    EDIT: Looking into this further I am starting to think this is a bug with how empty_moov interacts with the negative_cts_offsets flag. (when empty_moov is used, negative_cts_offsets seems to be ignored, and we need empty_moov for full webbrowser support.)

  • How to build pion mediadevices examples with x264 Windows ?

    17 mai 2022, par NO_GUI

    I am trying to build the pion mediadevices webrtc example utilizing x264 as my video encoder. I am building on a Windows 10 PC. The pion/mediadevices library utilizes pkg-config to locate x264 to build the program. I keep getting this error when building though:

    # pkg-config --cflags  -- x264
    Package x264 was not found in the pkg-config search path.
    Perhaps you should add the directory containing `x264.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'x264' found
    pkg-config: exit status 1
    

    I downloaded the source code for x264, but there is no x264.pc included. And from my research, it appears x264.pc is only included with libx264. I can't find any way to get libx264 on Windows either. Lastly, what is x264.pc, and what is a .pc file? Thanks for the help!

    Edit: I think I have to build the x264 library first, and I almost got it to work. MinGW was able to compile x264 and give me the x264.pc. But it was all compiled in 32bit, how can I compile the x264 library for 64bit on windows?

  • Gstreamer x264 plugin not found [closed]

    4 mai 2022, par user2038673

    Gstreamer x264 plugin not found on rhel 7.6. I have installed all plugins i.e gstreamer1.0 ugly free bad . Even installed x264 from source from vlc website. But still not able to get x264 plugin . Can anyone help with this. Have checked GStreamer x264enc not found But even then not working