4 पॉइंट द्वारा GN⁺ 2026-03-23 | 1 टिप्पणियां | WhatsApp पर शेयर करें
  • ऑडियो और वीडियो को encode, decode, transcode करने और stream करने के लिए FFmpeg framework की संरचना और उपयोग को कवर करता है
  • ffmpeg, ffplay, ffprobe जैसे command-line tools और libavcodec, libavformat, libavfilter जैसी core libraries की भूमिकाओं को विस्तार से समझाता है
  • AVFormatContext, AVCodecContext, AVPacket, AVFrame के केंद्र में stream analysis और decoding प्रक्रिया को step-by-step implement करता है
  • meson/ninja build system का उपयोग करके example code को अपने-आप download·compile करता है, और sample media files का analysis करके result output करता है
  • FFmpeg के internal working principles और decoding pipeline की समझ के लिए इसे hands-on introductory material की तरह इस्तेमाल किया जा सकता है

FFmpeg पैकेज संरचना

  • FFmpeg विभिन्न ऑडियो·वीडियो formats को encode, decode, transcode करने और network के जरिए stream करने के लिए tools और libraries का एक संग्रह है
  • FFmpeg tools

    • ffmpeg: command-line आधारित multimedia format conversion tool
    • ffplay: SDL और FFmpeg libraries पर आधारित एक सरल media player
    • ffprobe: multimedia streams का analysis करने वाला tool
  • FFmpeg libraries

    • libavformat: input/output और muxing/demuxing सुविधाएँ प्रदान करता है
    • libavcodec: encoding/decoding सुविधाएँ प्रदान करता है
    • libavfilter: graph-based filters के जरिए raw media processing
    • libavdevice: input/output devices का समर्थन
    • libavutil: common multimedia utilities प्रदान करता है
    • libswresample: audio resampling, sample format conversion, audio mixing का समर्थन
    • libswscale: color conversion और image scaling सुविधाएँ
    • libpostproc: video post-processing (deblocking, noise filter आदि) सुविधाएँ

FFmpeg simple player

  • FFmpeg के बुनियादी उपयोग का तरीका multimedia stream को demux करके उसे audio और video streams में अलग करना, फिर उसे raw audio/video data में decode करना है
  • मुख्य structures

    • AVFormatContext: stream synchronization, metadata, muxing को manage करने वाला top-level structure
    • AVStream: लगातार चलने वाली audio या video stream
    • AVCodec: data encoding और decoding के तरीके को define करता है
    • AVPacket: stream के भीतर encoded data
    • AVFrame: decoded raw video frame या audio sample
  • stream analysis और demux प्रक्रिया

    • avformat_alloc_context() से AVFormatContext memory allocate करना
    • avformat_open_input() से multimedia file खोलना
    • avformat_find_stream_info() से file के भीतर stream information का analysis करना
    • हर stream का time base, frame rate, start time, duration, type, FourCC code output करना
    • avformat_close_input() से file बंद करना और memory free करना
  • codec खोज और initialization

    • avcodec_find_decoder() से AVStream के codec ID के अनुरूप decoder खोजना
    • video stream के मामले में resolution (width, height), audio stream के मामले में channel count और sample rate output करना
    • avcodec_alloc_context3() से AVCodecContext बनाना
    • avcodec_parameters_to_context() से stream के codec parameters को decoder context पर लागू करना
    • avcodec_open2() से decoder खोलना
  • packet reading और decoding

    • AVPacket और AVFrame structures को क्रमशः encoded packet और decoded frame को store करने के लिए allocate करना
    • av_read_frame() से input file से packets को क्रमवार पढ़ना
    • packet के stream_index के जरिए यह पहचानना कि वह किस stream से आया है
    • चुनी गई video stream (first_video_stream_index) के packets ही decoder को भेजना
    • avcodec_send_packet() से packet को decoder तक पहुँचाना
    • avcodec_receive_frame() से decoded frames को बार-बार receive करना
    • हर frame का number, type (I/P/B), format, PTS, keyframe है या नहीं output करना
    • av_packet_unref() से packet memory को reuse करना
    • सारी processing पूरी होने पर av_packet_free(), av_frame_free(), avcodec_free_context(), avformat_close_input() से memory free करना
  • execution और result example

    • example code GitHub repository में उपलब्ध है
    • meson और ninja की मदद से build किया जा सकता है (pip3 install meson ninja)
    • meson setup build चलाने पर FFmpeg अपने-आप download और configure हो जाता है
    • ninja -C build से build करने के बाद ./build/ffmpeg-101 sample.mp4 से run करें
    • execution result में file format, stream information (video/audio), codec, resolution, sample rate, हर packet का PTS और decoded frame information output होती है
  • output example summary

    • video stream: H.264 (avc1), resolution 206x80, frame rate 30fps
    • audio stream: AAC (mp4a), 2 channels, 44.1kHz
    • हर packet का PTS और frame type (I/P) क्रम से दिखाया जाता है, और decoding प्रक्रिया console पर output होती है

build और execution environment

  • ज़रूरी tools: Python, pip, meson, ninja
  • installation command: pip3 install meson ninja
  • build प्रक्रिया

    • example archive file को ffmpeg-101 folder में extract करें
    • meson setup build चलाएँ
    • ninja -C build से build करें
    • ./build/ffmpeg-101 sample.mp4 से run करें
    • अगर FFmpeg system में install नहीं है, तो यह अपने-आप download और configure हो जाएगा

1 टिप्पणियां

 
GN⁺ 2026-03-23
Hacker News की राय
  • जो लोग FFmpeg और libav के अंदरूनी कामकाज को गहराई से समझना चाहते हैं, उनके लिए Leandro Moreira का ट्यूटोरियल ज़ोरदार सिफारिश है
    व्यक्तिगत रूप से, अब तक जो मैंने देखा है उनमें यह सबसे पूरा और सबसे स्पष्ट व्याख्या है
    FFmpeg-libav ट्यूटोरियल लिंक

    • यह ट्यूटोरियल सच में मददगार है। धन्यवाद
    • मूल लेख में दिए गए कमांड्स खास दिलचस्प नहीं थे, लेकिन यह ट्यूटोरियल कहीं ज़्यादा व्यावहारिक लगता है
  • यह देखकर हैरानी होती है कि अब ffmpeg 101 आ गया। लगता है जैसे ffmpeg 8 तो कल ही आया था

    • लगता है जैसे सोते समय एजेंट ने कोड push, approval, release सब कुछ कर दिया
  • एक और गाइड साझा की गई है
    HN के संबंधित गाइड का लिंक

  • FFmpeg, वाकई बहुत पसंदीदा टूल है

  • ffmpeg की शुरुआत के लिए यह शानदार सामग्री थी। धन्यवाद

  • ffmpeg सचमुच एक superpower है
    मैं कई वीडियो टुकड़ों को एक चलने योग्य रूप में जोड़ने के लिए इसे हमेशा इस्तेमाल करता हूँ