성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[tree soap] 아차! f는 기억이 나는데, m은 ㅜㅜ 감사합니다!!! ^...
[정성태] 'm'은 decimal 타입의 숫자에 붙는 접미사입니다. ...
[정성태] https://lxr.sourceforge.io/ http...
[정성태] VT sequences to "CONOUT$" vs. STD_O...
[정성태] NetCoreDbg is a managed code debugg...
[정성태] Evaluating tail call elimination in...
[정성태] What’s new in System.Text.Json in ....
[정성태] What's new in .NET 9: Cryptography ...
[정성태] 아... 제시해 주신 "https://akrzemi1.wordp...
[정성태] 다시 질문을 정리할 필요가 있을 것 같습니다. 제가 본문에...
글쓰기
제목
이름
암호
전자우편
HTML
홈페이지
유형
제니퍼 .NET
닷넷
COM 개체 관련
스크립트
VC++
VS.NET IDE
Windows
Team Foundation Server
디버깅 기술
오류 유형
개발 환경 구성
웹
기타
Linux
Java
DDK
Math
Phone
Graphics
사물인터넷
부모글 보이기/감추기
내용
<div style='display: inline'> <h1 style='font-family: Malgun Gothic, Consolas; font-size: 20pt; color: #006699; text-align: center; font-weight: bold'>C# - ffmpeg(FFmpeg.AutoGen)를 이용한 qsvdec.c 예제 포팅</h1> <p> 지난 예제에 이어,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > C# - ffmpeg(FFmpeg.AutoGen)를 이용한 muxing.c 예제 포팅 ; <a target='tab' href='https://www.sysnet.pe.kr/2/0/12971'>https://www.sysnet.pe.kr/2/0/12971</a> </pre> <br /> 이번에는 <a target='tab' href='https://ffmpeg.org/doxygen/trunk/examples.html'>ffmpeg 예제</a> 중 "<a target='tab' href='https://ffmpeg.org/doxygen/trunk/qsvdec_8c-example.html'>qsvdec.c</a>" 파일을 FFmpeg.AutoGen으로 포팅하겠습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > using FFmpeg.AutoGen; using FFmpeg.AutoGen.Example; using System; using System.IO; using System.Runtime.InteropServices; using System.Text; namespace ffmpeg_pgm_solve { internal unsafe class Program { const float STREAM_DURATION = 10.0f; const int STREAM_FRAME_RATE = 25; const AVPixelFormat STREAM_PIX_FMT = AVPixelFormat.AV_PIX_FMT_YUV420P; const int SCALE_FLAGS = ffmpeg.SWS_BICUBIC; [DllImport("Kernel32.dll", EntryPoint = "RtlMoveMemory", SetLastError = false)] static extern void MoveMemory(byte* dest, byte* src, int size); static AVPixelFormat _hwPixelFormat = AVPixelFormat.AV_PIX_FMT_NONE; static int Main(string[] args) { FFmpegBinariesHelper.RegisterFFmpegBinaries(); #if DEBUG Console.WriteLine("Current directory: " + Environment.CurrentDirectory); Console.WriteLine("Running in {0}-bit mode.", Environment.Is64BitProcess ? "64" : "32"); Console.WriteLine($"FFmpeg version info: {ffmpeg.av_version_info()}"); Console.WriteLine($"LIBAVFORMAT Version: {ffmpeg.LIBAVFORMAT_VERSION_MAJOR}.{ffmpeg.LIBAVFORMAT_VERSION_MINOR}"); Console.WriteLine(); #endif AVFormatContext* input_ctx = null; AVStream* video_st = null; AVCodecContext* decoder_ctx = null; AVCodec* decoder; AVPacket* pkt = null; AVFrame* frame = null, sw_frame = null; AVIOContext* output_ctx = null; int ret = 0, i; AVBufferRef* device_ref = null; string inputfile = @"D:\media_sample\theade-i-was-young.mp4"; string outputfile = @"C:\temp\output\test2.mp4"; { AVHWDeviceType type = AVHWDeviceType.AV_HWDEVICE_TYPE_NONE; while ((type = ffmpeg.av_hwdevice_iterate_types(type)) != AVHWDeviceType.AV_HWDEVICE_TYPE_NONE) { Console.WriteLine($"{ffmpeg.av_hwdevice_get_type_name(type)}"); } } { const int AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX = 0x01; void* iter = null; for (; ;) { AVCodec* cur = ffmpeg.av_codec_iterate(&iter); if (cur == null) { break; } Console.WriteLine($"{FFmpegHelper.AnsiToString(cur->name)}({FFmpegHelper.AnsiToString(cur->long_name)})"); AVCodecHWConfig* config = null; for (int n = 0; (config = ffmpeg.avcodec_get_hw_config(cur, n)) != null; n++) { if ((config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) == AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) { Console.WriteLine($"\thw-accel: {config->pix_fmt}, type: {config->device_type}, decoder: {ffmpeg.av_codec_is_decoder(cur)}, encoder: {ffmpeg.av_codec_is_encoder(cur)}"); } } } } try { ret = ffmpeg.avformat_open_input(&input_ctx, inputfile, null, null); if (ret < 0) { Console.WriteLine($"Cannot open input file: {inputfile}"); throw new ApplicationException(); } for (i = 0; i < input_ctx->nb_streams; i++) { AVStream* st = input_ctx->streams[i]; if (st->codecpar->codec_id == AVCodecID.AV_CODEC_ID_H264 && video_st == null) { video_st = st; } else { st->discard = AVDiscard.AVDISCARD_ALL; } } if (video_st == null) { Console.WriteLine("No H.264 video stream in the input file"); throw new ApplicationException(); } AVHWDeviceType hwDeviceType = AVHWDeviceType.AV_HWDEVICE_TYPE_QSV; _hwPixelFormat = AVPixelFormat.AV_PIX_FMT_QSV; string formatName = "h264_qsv"; ret = ffmpeg.av_hwdevice_ctx_create(&device_ref, hwDeviceType, "auto", null, 0); if (ret < 0) { ret.ThrowExceptionIfError(); Console.WriteLine("Cannot open the hardware device"); throw new ApplicationException(); } decoder = ffmpeg.avcodec_find_decoder_by_name(formatName); if (decoder == null) { Console.WriteLine($"The {formatName} decoder is not present in libavcodec"); throw new ApplicationException(); } decoder_ctx = ffmpeg.avcodec_alloc_context3(decoder); if (decoder_ctx == null) { ret = ffmpeg.AVERROR(ffmpeg.ENOMEM); throw new ApplicationException(); } decoder_ctx->codec_id = AVCodecID.AV_CODEC_ID_H264; if (video_st->codecpar->extradata_size != 0) { decoder_ctx->extradata = (byte *)ffmpeg.av_mallocz((ulong)(video_st->codecpar->extradata_size + ffmpeg.AV_INPUT_BUFFER_PADDING_SIZE)); if (decoder_ctx->extradata == null) { ret = ffmpeg.AVERROR(ffmpeg.ENOMEM); throw new ApplicationException(); } MoveMemory(decoder_ctx->extradata, video_st->codecpar->extradata, video_st->codecpar->extradata_size); decoder_ctx->extradata_size = video_st->codecpar->extradata_size; } decoder_ctx->hw_device_ctx = ffmpeg.av_buffer_ref(device_ref); decoder_ctx->get_format = (AVCodecContext_get_format_func)get_format; ret = ffmpeg.avcodec_open2(decoder_ctx, null, null); if (ret < 0) { Console.WriteLine("Error opening the decode: "); throw new ApplicationException(); } ret = ffmpeg.avio_open(&output_ctx, outputfile, ffmpeg.AVIO_FLAG_WRITE); if (ret < 0) { Console.WriteLine("Error opening the output context: "); throw new ApplicationException(); } frame = ffmpeg.av_frame_alloc(); sw_frame = ffmpeg.av_frame_alloc(); pkt = ffmpeg.av_packet_alloc(); if (frame == null || sw_frame == null || pkt == null) { ret = ffmpeg.AVERROR(ffmpeg.ENOMEM); throw new ApplicationException(); } while (ret >= 0) { ret = ffmpeg.av_read_frame(input_ctx, pkt); if (ret < 0) { break; } if (pkt->stream_index == video_st->index) { ret = decode_packet(decoder_ctx, frame, sw_frame, pkt, output_ctx); } ffmpeg.av_packet_unref(pkt); } ret = decode_packet(decoder_ctx, frame, sw_frame, null, output_ctx); Console.WriteLine($"ffplay -autoexit -f rawvideo -pixel_format {ffmpeg.av_get_pix_fmt_name(decoder_ctx->sw_pix_fmt)} -video_size {decoder_ctx->width}x{decoder_ctx->height} {outputfile}"); } catch (Exception) { } finally { if (ret < 0) { Console.WriteLine(FFmpegHelper.av_strerror(ret)); } ffmpeg.avformat_close_input(&input_ctx); ffmpeg.av_frame_free(&frame); ffmpeg.av_frame_free(&sw_frame); ffmpeg.av_packet_free(&pkt); ffmpeg.avcodec_free_context(&decoder_ctx); ffmpeg.av_buffer_unref(&device_ref); ffmpeg.avio_close(output_ctx); } return ret; } public unsafe static AVPixelFormat get_format(AVCodecContext* avctx, AVPixelFormat* pix_fmts) { AVPixelFormat* p; for (p = pix_fmts; *p != AVPixelFormat.AV_PIX_FMT_NONE; p++) { if (*p == _hwPixelFormat) { return *p; } } Console.WriteLine("Failed to get HW surface format."); return AVPixelFormat.AV_PIX_FMT_NONE; } public unsafe static int decode_packet(AVCodecContext* decoder_ctx, AVFrame* frame, AVFrame* sw_frame, AVPacket* pkt, AVIOContext* output_ctx) { int ret = ffmpeg.avcodec_send_packet(decoder_ctx, pkt); if (ret < 0) { Console.WriteLine("Error during decoding"); return ret; } while (ret >= 0) { uint i; int j; ret = ffmpeg.avcodec_receive_frame(decoder_ctx, frame); if (ret == ffmpeg.AVERROR(ffmpeg.EAGAIN) || ret == ffmpeg.AVERROR_EOF) { break; } else if (ret < 0) { Console.WriteLine("Error during decoding"); return ret; } ret = ffmpeg.av_hwframe_transfer_data(sw_frame, frame, 0); if (ret < 0) { Console.WriteLine("Error transferring the data to system memory"); } else { if (sw_frame->format == (int)AVPixelFormat.AV_PIX_FMT_NV12) { for (i = 0; i < byte_array8.Size && sw_frame->data[i] != null; i++) { for (j = 0; j < (sw_frame->height >> (i > 0 ? 1 : 0)); j++) { ffmpeg.avio_write(output_ctx, sw_frame->data[i] + j * sw_frame->linesize[i], sw_frame->width); } } } } ffmpeg.av_frame_unref(sw_frame); ffmpeg.av_frame_unref(frame); if (ret < 0) { return ret; } } return 0; } } } </pre> <br /> 그런데, 제 경우에 실제로 실행해 보면 av_hwdevice_ctx_create 함수에서 -12를 반환합니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > ret = ffmpeg.av_hwdevice_ctx_create(&device_ref, AVHWDeviceType.AV_HWDEVICE_TYPE_QSV, "auto", null, 0); if (ret < 0) { Console.WriteLine("Cannot open the hardware device"); throw new ApplicationException(); } </pre> <br /> <a target='tab' href='https://www.sysnet.pe.kr/2/0/12977'>이 문제는 다음 편에서 어떻게 해결</a>하는지 다루겠습니다. ^^<br /> <br /> <hr style='width: 50%' /><br /> <br /> 암튼, 그래도 qsvdec.c 테스트는 해야 하니... 아마도 다른 하드웨어 가속 디코더를 지정해도 될 듯합니다. 그래서, 코덱을 조회해 보면,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > { const int AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX = 0x01; void* iter = null; for (; ;) { AVCodec* cur = ffmpeg.av_codec_iterate(&iter); if (cur == null) { break; } Console.WriteLine($"{FFmpegHelper.AnsiToString(cur->name)}({FFmpegHelper.AnsiToString(cur->long_name)})"); AVCodecHWConfig* config = null; for (int n = 0; (config = ffmpeg.avcodec_get_hw_config(cur, n)) != null; n++) { if ((config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) == AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) { Console.WriteLine($"\thw-accel: {config->pix_fmt}, type: {config->device_type}, decoder: {ffmpeg.av_codec_is_decoder(cur)}, encoder: {ffmpeg.av_codec_is_encoder(cur)}"); } } } } </pre> <br /> 다음과 같은 결과를 얻습니다.<br /> <br /> <pre style='height: 400px; margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > a64multi(Multicolor charset for Commodore 64) a64multi5(Multicolor charset for Commodore 64, extended with 5th color (colram)) alias_pix(Alias/Wavefront PIX image) amv(AMV Video) asv1(ASUS V1) asv2(ASUS V2) avrp(Avid 1:1 10-bit RGB Packer) avui(Avid Meridien Uncompressed) ayuv(Uncompressed packed MS 4:4:4:4) bmp(BMP (Windows and OS/2 bitmap)) cfhd(GoPro CineForm HD) cinepak(Cinepak) cljr(Cirrus Logic AccuPak) comfortnoise(RFC 3389 comfort noise generator) dnxhd(VC3/DNxHD) dpx(DPX (Digital Picture Exchange) image) dvvideo(DV (Digital Video)) ffv1(FFmpeg video codec #1) ffvhuff(Huffyuv FFmpeg variant) fits(Flexible Image Transport System) flv(FLV / Sorenson Spark / Sorenson H.263 (Flash Video)) gif(GIF (Graphics Interchange Format)) h261(H.261) h263(H.263 / H.263-1996) h263p(H.263+ / H.263-1998 / H.263 version 2) huffyuv(Huffyuv / HuffYUV) jpeg2000(JPEG 2000) jpegls(JPEG-LS) ljpeg(Lossless JPEG) magicyuv(MagicYUV video) mjpeg(MJPEG (Motion JPEG)) mpeg1video(MPEG-1 video) mpeg2video(MPEG-2 video) mpeg4(MPEG-4 part 2) msmpeg4v2(MPEG-4 part 2 Microsoft variant version 2) msmpeg4(MPEG-4 part 2 Microsoft variant version 3) msvideo1(Microsoft Video-1) pam(PAM (Portable AnyMap) image) pbm(PBM (Portable BitMap) image) pcx(PC Paintbrush PCX image) pfm(PFM (Portable FloatMap) image) pgm(PGM (Portable GrayMap) image) pgmyuv(PGMYUV (Portable GrayMap YUV) image) ppm(PPM (Portable PixelMap) image) prores(Apple ProRes) prores_aw(Apple ProRes) prores_ks(Apple ProRes (iCodec Pro)) qtrle(QuickTime Animation (RLE) video) r10k(AJA Kona 10-bit RGB Codec) r210(Uncompressed RGB 10-bit) rawvideo(raw video) roqvideo(id RoQ video) rpza(QuickTime video (RPZA)) rv10(RealVideo 1.0) rv20(RealVideo 2.0) s302m(SMPTE 302M) sgi(SGI image) snow(Snow) speedhq(NewTek SpeedHQ) sunrast(Sun Rasterfile image) svq1(Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1) targa(Truevision Targa image) tiff(TIFF image) utvideo(Ut Video) v210(Uncompressed 4:2:2 10-bit) v308(Uncompressed packed 4:4:4) v408(Uncompressed packed QT 4:4:4:4) v410(Uncompressed 4:4:4 10-bit) vc2(SMPTE VC-2) wrapped_avframe(AVFrame to AVPacket passthrough) wmv1(Windows Media Video 7) wmv2(Windows Media Video 8) xbm(XBM (X BitMap) image) xface(X-face image) xwd(XWD (X Window Dump) image) y41p(Uncompressed YUV 4:1:1 12-bit) yuv4(Uncompressed packed 4:2:0) aac(AAC (Advanced Audio Coding)) ac3(ATSC A/52A (AC-3)) ac3_fixed(ATSC A/52A (AC-3)) alac(ALAC (Apple Lossless Audio Codec)) aptx(aptX (Audio Processing Technology for Bluetooth)) aptx_hd(aptX HD (Audio Processing Technology for Bluetooth)) dca(DCA (DTS Coherent Acoustics)) eac3(ATSC A/52 E-AC-3) flac(FLAC (Free Lossless Audio Codec)) g723_1(G.723.1) mlp(MLP (Meridian Lossless Packing)) mp2(MP2 (MPEG audio layer 2)) mp2fixed(MP2 fixed point (MPEG audio layer 2)) nellymoser(Nellymoser Asao) opus(Opus) real_144(RealAudio 1.0 (14.4K)) sbc(SBC (low-complexity subband codec)) sonic(Sonic) sonicls(Sonic lossless) truehd(TrueHD) tta(TTA (True Audio)) vorbis(Vorbis) wavpack(WavPack) wmav1(Windows Media Audio 1) wmav2(Windows Media Audio 2) pcm_alaw(PCM A-law / G.711 A-law) pcm_dvd(PCM signed 16|20|24-bit big-endian for DVD media) pcm_f32be(PCM 32-bit floating point big-endian) pcm_f32le(PCM 32-bit floating point little-endian) pcm_f64be(PCM 64-bit floating point big-endian) pcm_f64le(PCM 64-bit floating point little-endian) pcm_mulaw(PCM mu-law / G.711 mu-law) pcm_s8(PCM signed 8-bit) pcm_s8_planar(PCM signed 8-bit planar) pcm_s16be(PCM signed 16-bit big-endian) pcm_s16be_planar(PCM signed 16-bit big-endian planar) pcm_s16le(PCM signed 16-bit little-endian) pcm_s16le_planar(PCM signed 16-bit little-endian planar) pcm_s24be(PCM signed 24-bit big-endian) pcm_s24daud(PCM D-Cinema audio signed 24-bit) pcm_s24le(PCM signed 24-bit little-endian) pcm_s24le_planar(PCM signed 24-bit little-endian planar) pcm_s32be(PCM signed 32-bit big-endian) pcm_s32le(PCM signed 32-bit little-endian) pcm_s32le_planar(PCM signed 32-bit little-endian planar) pcm_s64be(PCM signed 64-bit big-endian) pcm_s64le(PCM signed 64-bit little-endian) pcm_u8(PCM unsigned 8-bit) pcm_u16be(PCM unsigned 16-bit big-endian) pcm_u16le(PCM unsigned 16-bit little-endian) pcm_u24be(PCM unsigned 24-bit big-endian) pcm_u24le(PCM unsigned 24-bit little-endian) pcm_u32be(PCM unsigned 32-bit big-endian) pcm_u32le(PCM unsigned 32-bit little-endian) pcm_vidc(PCM Archimedes VIDC) roq_dpcm(id RoQ DPCM) adpcm_adx(SEGA CRI ADX ADPCM) adpcm_argo(ADPCM Argonaut Games) g722(G.722 ADPCM) g726(G.726 ADPCM) g726le(G.726 little endian ADPCM ("right-justified")) adpcm_ima_amv(ADPCM IMA AMV) adpcm_ima_alp(ADPCM IMA High Voltage Software ALP) adpcm_ima_apm(ADPCM IMA Ubisoft APM) adpcm_ima_qt(ADPCM IMA QuickTime) adpcm_ima_ssi(ADPCM IMA Simon & Schuster Interactive) adpcm_ima_wav(ADPCM IMA WAV) adpcm_ms(ADPCM Microsoft) adpcm_swf(ADPCM Shockwave Flash) adpcm_yamaha(ADPCM Yamaha) ssa(ASS (Advanced SubStation Alpha) subtitle) ass(ASS (Advanced SubStation Alpha) subtitle) dvbsub(DVB subtitles) dvdsub(DVD subtitles) mov_text(3GPP Timed Text subtitle) srt(SubRip subtitle) subrip(SubRip subtitle) text(Raw text subtitle) ttml(TTML subtitle) webvtt(WebVTT subtitle) xsub(DivX subtitles (XSUB)) aac_mf(AAC via MediaFoundation) ac3_mf(AC3 via MediaFoundation) h264_mf(H264 via MediaFoundation) h264_nvenc(NVIDIA NVENC H.264 encoder) hw-accel: AV_PIX_FMT_NONE, type: AV_HWDEVICE_TYPE_CUDA, decoder: 0, encoder: 1 hw-accel: AV_PIX_FMT_NONE, type: AV_HWDEVICE_TYPE_D3D11VA, decoder: 0, encoder: 1 nvenc(NVIDIA NVENC H.264 encoder) hw-accel: AV_PIX_FMT_NONE, type: AV_HWDEVICE_TYPE_CUDA, decoder: 0, encoder: 1 hw-accel: AV_PIX_FMT_NONE, type: AV_HWDEVICE_TYPE_D3D11VA, decoder: 0, encoder: 1 nvenc_h264(NVIDIA NVENC H.264 encoder) hw-accel: AV_PIX_FMT_NONE, type: AV_HWDEVICE_TYPE_CUDA, decoder: 0, encoder: 1 hw-accel: AV_PIX_FMT_NONE, type: AV_HWDEVICE_TYPE_D3D11VA, decoder: 0, encoder: 1 nvenc_hevc(NVIDIA NVENC hevc encoder) hw-accel: AV_PIX_FMT_NONE, type: AV_HWDEVICE_TYPE_CUDA, decoder: 0, encoder: 1 hw-accel: AV_PIX_FMT_NONE, type: AV_HWDEVICE_TYPE_D3D11VA, decoder: 0, encoder: 1 hevc_mf(HEVC via MediaFoundation) hevc_nvenc(NVIDIA NVENC hevc encoder) hw-accel: AV_PIX_FMT_NONE, type: AV_HWDEVICE_TYPE_CUDA, decoder: 0, encoder: 1 hw-accel: AV_PIX_FMT_NONE, type: AV_HWDEVICE_TYPE_D3D11VA, decoder: 0, encoder: 1 mp3_mf(MP3 via MediaFoundation) aasc(Autodesk RLE) aic(Apple Intermediate Codec) alias_pix(Alias/Wavefront PIX image) agm(Amuse Graphics Movie) amv(AMV Video) anm(Deluxe Paint Animation) ansi(ASCII/ANSI art) arbc(Gryphon's Anim Compressor) argo(Argonaut Games Video) asv1(ASUS V1) asv2(ASUS V2) aura(Auravision AURA) aura2(Auravision Aura 2) avrp(Avid 1:1 10-bit RGB Packer) avrn(Avid AVI Codec) avs(AVS (Audio Video Standard) video) avui(Avid Meridien Uncompressed) ayuv(Uncompressed packed MS 4:4:4:4) bethsoftvid(Bethesda VID video) bfi(Brute Force & Ignorance) binkvideo(Bink video) bitpacked(Bitpacked) bmp(BMP (Windows and OS/2 bitmap)) bmv_video(Discworld II BMV video) brender_pix(BRender PIX image) c93(Interplay C93) cavs(Chinese AVS (Audio Video Standard) (AVS1-P2, JiZhun profile)) cdgraphics(CD Graphics video) cdtoons(CDToons video) cdxl(Commodore CDXL video) cfhd(GoPro CineForm HD) cinepak(Cinepak) clearvideo(Iterated Systems ClearVideo) cljr(Cirrus Logic AccuPak) cllc(Canopus Lossless Codec) comfortnoise(RFC 3389 comfort noise generator) cpia(CPiA video format) cri(Cintel RAW) camstudio(CamStudio) cyuv(Creative YUV (CYUV)) dds(DirectDraw Surface image decoder) dfa(Chronomaster DFA) dirac(BBC Dirac VC-2) dnxhd(VC3/DNxHD) dpx(DPX (Digital Picture Exchange) image) dsicinvideo(Delphine Software International CIN video) dvaudio(Ulead DV Audio) dvvideo(DV (Digital Video)) dxtory(Dxtory) dxv(Resolume DXV) eacmv(Electronic Arts CMV video) eamad(Electronic Arts Madcow Video) eatgq(Electronic Arts TGQ video) eatgv(Electronic Arts TGV video) eatqi(Electronic Arts TQI Video) 8bps(QuickTime 8BPS video) 8svx_exp(8SVX exponential) 8svx_fib(8SVX fibonacci) escape124(Escape 124) escape130(Escape 130) ffv1(FFmpeg video codec #1) ffvhuff(Huffyuv FFmpeg variant) fic(Mirillis FIC) fits(Flexible Image Transport System) flic(Autodesk Animator Flic video) flv(FLV / Sorenson Spark / Sorenson H.263 (Flash Video)) fmvc(FM Screen Capture Codec) 4xm(4X Movie) fraps(Fraps) frwu(Forward Uncompressed) gdv(Gremlin Digital Video) gif(GIF (Graphics Interchange Format)) h261(H.261) h263(H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2) hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 h263i(Intel H.263) h263p(H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2) hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 h264(H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10) hw-accel: AV_PIX_FMT_DXVA2_VLD, type: AV_HWDEVICE_TYPE_DXVA2, decoder: 1, encoder: 0 hw-accel: AV_PIX_FMT_D3D11, type: AV_HWDEVICE_TYPE_D3D11VA, decoder: 1, encoder: 0 hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 hap(Vidvox Hap) hevc(HEVC (High Efficiency Video Coding)) hw-accel: AV_PIX_FMT_DXVA2_VLD, type: AV_HWDEVICE_TYPE_DXVA2, decoder: 1, encoder: 0 hw-accel: AV_PIX_FMT_D3D11, type: AV_HWDEVICE_TYPE_D3D11VA, decoder: 1, encoder: 0 hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 hnm4video(HNM 4 video) hq_hqa(Canopus HQ/HQA) hqx(Canopus HQX) huffyuv(Huffyuv / HuffYUV) hymt(HuffYUV MT) idcinvideo(id Quake II CIN video) iff(IFF ACBM/ANIM/DEEP/ILBM/PBM/RGB8/RGBN) imm4(Infinity IMM4) imm5(Infinity IMM5) indeo2(Intel Indeo 2) indeo3(Intel Indeo 3) indeo4(Intel Indeo Video Interactive 4) indeo5(Intel Indeo Video Interactive 5) interplayvideo(Interplay MVE video) ipu(IPU Video) jpeg2000(JPEG 2000) jpegls(JPEG-LS) jv(Bitmap Brothers JV video) kgv1(Kega Game Video) kmvc(Karl Morton's video codec) lagarith(Lagarith lossless) loco(LOCO) m101(Matrox Uncompressed SD) magicyuv(MagicYUV video) mdec(Sony PlayStation MDEC (Motion DECoder)) mimic(Mimic) mjpeg(MJPEG (Motion JPEG)) hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 mjpegb(Apple MJPEG-B) mmvideo(American Laser Games MM Video) mobiclip(MobiClip Video) motionpixels(Motion Pixels video) mpeg1video(MPEG-1 video) hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 mpeg2video(MPEG-2 video) hw-accel: AV_PIX_FMT_DXVA2_VLD, type: AV_HWDEVICE_TYPE_DXVA2, decoder: 1, encoder: 0 hw-accel: AV_PIX_FMT_D3D11, type: AV_HWDEVICE_TYPE_D3D11VA, decoder: 1, encoder: 0 hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 mpeg4(MPEG-4 part 2) hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 mpegvideo(MPEG-1 video) msa1(MS ATC Screen) msmpeg4v1(MPEG-4 part 2 Microsoft variant version 1) msmpeg4v2(MPEG-4 part 2 Microsoft variant version 2) msmpeg4(MPEG-4 part 2 Microsoft variant version 3) msp2(Microsoft Paint (MSP) version 2) msrle(Microsoft RLE) mss1(MS Screen 1) mss2(MS Windows Media Video V9 Screen) msvideo1(Microsoft Video 1) mszh(LCL (LossLess Codec Library) MSZH) mts2(MS Expression Encoder Screen) mv30(MidiVid 3.0) mvc1(Silicon Graphics Motion Video Compressor 1) mvc2(Silicon Graphics Motion Video Compressor 2) mvdv(MidiVid VQ) mxpeg(Mobotix MxPEG video) notchlc(NotchLC) nuv(NuppelVideo/RTJPEG) paf_video(Amazing Studio Packed Animation File Video) pam(PAM (Portable AnyMap) image) pbm(PBM (Portable BitMap) image) pcx(PC Paintbrush PCX image) pfm(PFM (Portable FloatMap) image) pgm(PGM (Portable GrayMap) image) pgmyuv(PGMYUV (Portable GrayMap YUV) image) pgx(PGX (JPEG2000 Test Format)) photocd(Kodak Photo CD) pictor(Pictor/PC Paint) pixlet(Apple Pixlet) ppm(PPM (Portable PixelMap) image) prores(Apple ProRes (iCodec Pro)) prosumer(Brooktree ProSumer Video) psd(Photoshop PSD file) ptx(V.Flash PTX image) qdraw(Apple QuickDraw) qpeg(Q-team QPEG) qtrle(QuickTime Animation (RLE) video) r10k(AJA Kona 10-bit RGB Codec) r210(Uncompressed RGB 10-bit) rawvideo(raw video) rl2(RL2 video) roqvideo(id RoQ video) rpza(QuickTime video (RPZA)) rv10(RealVideo 1.0) rv20(RealVideo 2.0) rv30(RealVideo 3.0) rv40(RealVideo 4.0) s302m(SMPTE 302M) sanm(LucasArts SANM/Smush video) scpr(ScreenPressor) sga(Digital Pictures SGA Video) sgi(SGI image) sgirle(Silicon Graphics RLE 8-bit video) sheervideo(BitJazz SheerVideo) simbiosis_imx(Simbiosis Interactive IMX Video) smackvid(Smacker video) smc(QuickTime Graphics (SMC)) smvjpeg(SMV JPEG) snow(Snow) sp5x(Sunplus JPEG (SP5X)) speedhq(NewTek SpeedHQ) sunrast(Sun Rasterfile image) svq1(Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1) svq3(Sorenson Vector Quantizer 3 / Sorenson Video 3 / SVQ3) targa(Truevision Targa image) targa_y216(Pinnacle TARGA CineWave YUV16) theora(Theora) thp(Nintendo Gamecube THP video) tiertexseqvideo(Tiertex Limited SEQ video) tiff(TIFF image) tmv(8088flex TMV) truemotion1(Duck TrueMotion 1.0) truemotion2(Duck TrueMotion 2.0) truemotion2rt(Duck TrueMotion 2.0 Real Time) tscc2(TechSmith Screen Codec 2) txd(Renderware TXD (TeXture Dictionary) image) ultimotion(IBM UltiMotion) utvideo(Ut Video) v210(Uncompressed 4:2:2 10-bit) v210x(Uncompressed 4:2:2 10-bit) v308(Uncompressed packed 4:4:4) v408(Uncompressed packed QT 4:4:4:4) v410(Uncompressed 4:4:4 10-bit) vb(Beam Software VB) vble(VBLE Lossless Codec) vc1(SMPTE VC-1) hw-accel: AV_PIX_FMT_DXVA2_VLD, type: AV_HWDEVICE_TYPE_DXVA2, decoder: 1, encoder: 0 hw-accel: AV_PIX_FMT_D3D11, type: AV_HWDEVICE_TYPE_D3D11VA, decoder: 1, encoder: 0 hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 vc1image(Windows Media Video 9 Image v2) vcr1(ATI VCR1) vmdvideo(Sierra VMD video) vmnc(VMware Screen Codec / VMware Video) vp3(On2 VP3) vp4(On2 VP4) vp5(On2 VP5) vp6(On2 VP6) vp6a(On2 VP6 (Flash version, with alpha channel)) vp6f(On2 VP6 (Flash version)) vp7(On2 VP7) vp8(On2 VP8) hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 vp9(Google VP9) hw-accel: AV_PIX_FMT_DXVA2_VLD, type: AV_HWDEVICE_TYPE_DXVA2, decoder: 1, encoder: 0 hw-accel: AV_PIX_FMT_D3D11, type: AV_HWDEVICE_TYPE_D3D11VA, decoder: 1, encoder: 0 hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 vqavideo(Westwood Studios VQA (Vector Quantized Animation) video) webp(WebP image) wrapped_avframe(AVPacket to AVFrame passthrough) wmv1(Windows Media Video 7) wmv2(Windows Media Video 8) wmv3(Windows Media Video 9) hw-accel: AV_PIX_FMT_DXVA2_VLD, type: AV_HWDEVICE_TYPE_DXVA2, decoder: 1, encoder: 0 hw-accel: AV_PIX_FMT_D3D11, type: AV_HWDEVICE_TYPE_D3D11VA, decoder: 1, encoder: 0 hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 wmv3image(Windows Media Video 9 Image) wnv1(Winnov WNV1) xan_wc3(Wing Commander III / Xan) xan_wc4(Wing Commander IV / Xxan) xbm(XBM (X BitMap) image) xface(X-face image) xl(Miro VideoXL) xpm(XPM (X PixMap) image) xwd(XWD (X Window Dump) image) y41p(Uncompressed YUV 4:1:1 12-bit) ylc(YUY2 Lossless Codec) yop(Psygnosis YOP Video) yuv4(Uncompressed packed 4:2:0) 012v(Uncompressed 4:2:2 10-bit) aac(AAC (Advanced Audio Coding)) aac_fixed(AAC (Advanced Audio Coding)) aac_latm(AAC LATM (Advanced Audio Coding LATM syntax)) ac3(ATSC A/52A (AC-3)) ac3_fixed(ATSC A/52A (AC-3)) acelp.kelvin(Sipro ACELP.KELVIN) alac(ALAC (Apple Lossless Audio Codec)) als(MPEG-4 Audio Lossless Coding (ALS)) amrnb(AMR-NB (Adaptive Multi-Rate NarrowBand)) amrwb(AMR-WB (Adaptive Multi-Rate WideBand)) ape(Monkey's Audio) aptx(aptX (Audio Processing Technology for Bluetooth)) aptx_hd(aptX HD (Audio Processing Technology for Bluetooth)) atrac1(ATRAC1 (Adaptive TRansform Acoustic Coding)) atrac3(ATRAC3 (Adaptive TRansform Acoustic Coding 3)) atrac3al(ATRAC3 AL (Adaptive TRansform Acoustic Coding 3 Advanced Lossless)) atrac3plus(ATRAC3+ (Adaptive TRansform Acoustic Coding 3+)) atrac3plusal(ATRAC3+ AL (Adaptive TRansform Acoustic Coding 3+ Advanced Lossless)) atrac9(ATRAC9 (Adaptive TRansform Acoustic Coding 9)) binkaudio_dct(Bink Audio (DCT)) binkaudio_rdft(Bink Audio (RDFT)) bmv_audio(Discworld II BMV audio) cook(Cook / Cooker / Gecko (RealAudio G2)) dca(DCA (DTS Coherent Acoustics)) dolby_e(Dolby E) dsd_lsbf(DSD (Direct Stream Digital), least significant bit first) dsd_msbf(DSD (Direct Stream Digital), most significant bit first) dsd_lsbf_planar(DSD (Direct Stream Digital), least significant bit first, planar) dsd_msbf_planar(DSD (Direct Stream Digital), most significant bit first, planar) dsicinaudio(Delphine Software International CIN audio) dss_sp(Digital Speech Standard - Standard Play mode (DSS SP)) dst(DST (Digital Stream Transfer)) eac3(ATSC A/52B (AC-3, E-AC-3)) evrc(EVRC (Enhanced Variable Rate Codec)) fastaudio(MobiClip FastAudio) wavesynth(Wave synthesis pseudo-codec) flac(FLAC (Free Lossless Audio Codec)) g723_1(G.723.1) g729(G.729) gsm(GSM) gsm_ms(GSM Microsoft variant) hca(CRI HCA) hcom(HCOM Audio) iac(IAC (Indeo Audio Coder)) ilbc(iLBC (Internet Low Bitrate Codec)) imc(IMC (Intel Music Coder)) interplayacm(Interplay ACM) mace3(MACE (Macintosh Audio Compression/Expansion) 3:1) mace6(MACE (Macintosh Audio Compression/Expansion) 6:1) metasound(Voxware MetaSound) mlp(MLP (Meridian Lossless Packing)) mp1(MP1 (MPEG audio layer 1)) mp1float(MP1 (MPEG audio layer 1)) mp2(MP2 (MPEG audio layer 2)) mp2float(MP2 (MPEG audio layer 2)) mp3float(MP3 (MPEG audio layer 3)) mp3(MP3 (MPEG audio layer 3)) mp3adufloat(ADU (Application Data Unit) MP3 (MPEG audio layer 3)) mp3adu(ADU (Application Data Unit) MP3 (MPEG audio layer 3)) mp3on4float(MP3onMP4) mp3on4(MP3onMP4) mpc7(Musepack SV7) mpc8(Musepack SV8) nellymoser(Nellymoser Asao) on2avc(On2 Audio for Video Codec) opus(Opus) paf_audio(Amazing Studio Packed Animation File Audio) qcelp(QCELP / PureVoice) qdm2(QDesign Music Codec 2) qdmc(QDesign Music Codec 1) real_144(RealAudio 1.0 (14.4K)) real_288(RealAudio 2.0 (28.8K)) ralf(RealAudio Lossless) sbc(SBC (low-complexity subband codec)) shorten(Shorten) sipr(RealAudio SIPR / ACELP.NET) siren(Siren) smackaud(Smacker audio) sonic(Sonic) tak(TAK (Tom's lossless Audio Kompressor)) truehd(TrueHD) truespeech(DSP Group TrueSpeech) tta(TTA (True Audio)) twinvq(VQF TwinVQ) vmdaudio(Sierra VMD audio) vorbis(Vorbis) wavpack(WavPack) wmalossless(Windows Media Audio Lossless) wmapro(Windows Media Audio 9 Professional) wmav1(Windows Media Audio 1) wmav2(Windows Media Audio 2) wmavoice(Windows Media Audio Voice) ws_snd1(Westwood Audio (SND1)) xma1(Xbox Media Audio 1) xma2(Xbox Media Audio 2) pcm_alaw(PCM A-law / G.711 A-law) pcm_bluray(PCM signed 16|20|24-bit big-endian for Blu-ray media) pcm_dvd(PCM signed 16|20|24-bit big-endian for DVD media) pcm_f16le(PCM 16.8 floating point little-endian) pcm_f24le(PCM 24.0 floating point little-endian) pcm_f32be(PCM 32-bit floating point big-endian) pcm_f32le(PCM 32-bit floating point little-endian) pcm_f64be(PCM 64-bit floating point big-endian) pcm_f64le(PCM 64-bit floating point little-endian) pcm_lxf(PCM signed 20-bit little-endian planar) pcm_mulaw(PCM mu-law / G.711 mu-law) pcm_s8(PCM signed 8-bit) pcm_s8_planar(PCM signed 8-bit planar) pcm_s16be(PCM signed 16-bit big-endian) pcm_s16be_planar(PCM signed 16-bit big-endian planar) pcm_s16le(PCM signed 16-bit little-endian) pcm_s16le_planar(PCM signed 16-bit little-endian planar) pcm_s24be(PCM signed 24-bit big-endian) pcm_s24daud(PCM D-Cinema audio signed 24-bit) pcm_s24le(PCM signed 24-bit little-endian) pcm_s24le_planar(PCM signed 24-bit little-endian planar) pcm_s32be(PCM signed 32-bit big-endian) pcm_s32le(PCM signed 32-bit little-endian) pcm_s32le_planar(PCM signed 32-bit little-endian planar) pcm_s64be(PCM signed 64-bit big-endian) pcm_s64le(PCM signed 64-bit little-endian) pcm_sga(PCM SGA) pcm_u8(PCM unsigned 8-bit) pcm_u16be(PCM unsigned 16-bit big-endian) pcm_u16le(PCM unsigned 16-bit little-endian) pcm_u24be(PCM unsigned 24-bit big-endian) pcm_u24le(PCM unsigned 24-bit little-endian) pcm_u32be(PCM unsigned 32-bit big-endian) pcm_u32le(PCM unsigned 32-bit little-endian) pcm_vidc(PCM Archimedes VIDC) derf_dpcm(DPCM Xilam DERF) gremlin_dpcm(DPCM Gremlin) interplay_dpcm(DPCM Interplay) roq_dpcm(DPCM id RoQ) sdx2_dpcm(DPCM Squareroot-Delta-Exact) sol_dpcm(DPCM Sol) xan_dpcm(DPCM Xan) adpcm_4xm(ADPCM 4X Movie) adpcm_adx(SEGA CRI ADX ADPCM) adpcm_afc(ADPCM Nintendo Gamecube AFC) adpcm_agm(ADPCM AmuseGraphics Movie) adpcm_aica(ADPCM Yamaha AICA) adpcm_argo(ADPCM Argonaut Games) adpcm_ct(ADPCM Creative Technology) adpcm_dtk(ADPCM Nintendo Gamecube DTK) adpcm_ea(ADPCM Electronic Arts) adpcm_ea_maxis_xa(ADPCM Electronic Arts Maxis CDROM XA) adpcm_ea_r1(ADPCM Electronic Arts R1) adpcm_ea_r2(ADPCM Electronic Arts R2) adpcm_ea_r3(ADPCM Electronic Arts R3) adpcm_ea_xas(ADPCM Electronic Arts XAS) g722(G.722 ADPCM) g726(G.726 ADPCM) g726le(G.726 ADPCM little-endian) adpcm_ima_amv(ADPCM IMA AMV) adpcm_ima_alp(ADPCM IMA High Voltage Software ALP) adpcm_ima_apc(ADPCM IMA CRYO APC) adpcm_ima_apm(ADPCM IMA Ubisoft APM) adpcm_ima_cunning(ADPCM IMA Cunning Developments) adpcm_ima_dat4(ADPCM IMA Eurocom DAT4) adpcm_ima_dk3(ADPCM IMA Duck DK3) adpcm_ima_dk4(ADPCM IMA Duck DK4) adpcm_ima_ea_eacs(ADPCM IMA Electronic Arts EACS) adpcm_ima_ea_sead(ADPCM IMA Electronic Arts SEAD) adpcm_ima_iss(ADPCM IMA Funcom ISS) adpcm_ima_moflex(ADPCM IMA MobiClip MOFLEX) adpcm_ima_mtf(ADPCM IMA Capcom's MT Framework) adpcm_ima_oki(ADPCM IMA Dialogic OKI) adpcm_ima_qt(ADPCM IMA QuickTime) adpcm_ima_rad(ADPCM IMA Radical) adpcm_ima_ssi(ADPCM IMA Simon & Schuster Interactive) adpcm_ima_smjpeg(ADPCM IMA Loki SDL MJPEG) adpcm_ima_wav(ADPCM IMA WAV) adpcm_ima_ws(ADPCM IMA Westwood) adpcm_ms(ADPCM Microsoft) adpcm_mtaf(ADPCM MTAF) adpcm_psx(ADPCM Playstation) adpcm_sbpro_2(ADPCM Sound Blaster Pro 2-bit) adpcm_sbpro_3(ADPCM Sound Blaster Pro 2.6-bit) adpcm_sbpro_4(ADPCM Sound Blaster Pro 4-bit) adpcm_swf(ADPCM Shockwave Flash) adpcm_thp(ADPCM Nintendo THP) adpcm_thp_le(ADPCM Nintendo THP (little-endian)) adpcm_vima(LucasArts VIMA audio) adpcm_xa(ADPCM CDROM XA) adpcm_yamaha(ADPCM Yamaha) adpcm_zork(ADPCM Zork) ssa(ASS (Advanced SubStation Alpha) subtitle) ass(ASS (Advanced SubStation Alpha) subtitle) cc_dec(Closed Caption (EIA-608 / CEA-708)) dvbsub(DVB subtitles) dvdsub(DVD subtitles) jacosub(JACOsub subtitle) microdvd(MicroDVD subtitle) mov_text(3GPP Timed Text subtitle) mpl2(MPL2 subtitle) pgssub(HDMV Presentation Graphic Stream subtitles) pjs(PJS subtitle) realtext(RealText subtitle) sami(SAMI subtitle) srt(SubRip subtitle) stl(Spruce subtitle format) subrip(SubRip subtitle) subviewer(SubViewer subtitle) subviewer1(SubViewer1 subtitle) text(Raw text subtitle) vplayer(VPlayer subtitle) webvtt(WebVTT subtitle) xsub(XSUB) bintext(Binary text) xbin(eXtended BINary text) idf(iCEDraw text) av1(Alliance for Open Media AV1) hw-accel: AV_PIX_FMT_DXVA2_VLD, type: AV_HWDEVICE_TYPE_DXVA2, decoder: 1, encoder: 0 hw-accel: AV_PIX_FMT_D3D11, type: AV_HWDEVICE_TYPE_D3D11VA, decoder: 1, encoder: 0 hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 av1_cuvid(Nvidia CUVID AV1 decoder) hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 h264_cuvid(Nvidia CUVID H264 decoder) hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 hevc_cuvid(Nvidia CUVID HEVC decoder) hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 mjpeg_cuvid(Nvidia CUVID MJPEG decoder) hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 mpeg1_cuvid(Nvidia CUVID MPEG1VIDEO decoder) hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 mpeg2_cuvid(Nvidia CUVID MPEG2VIDEO decoder) hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 mpeg4_cuvid(Nvidia CUVID MPEG4 decoder) hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 vc1_cuvid(Nvidia CUVID VC1 decoder) hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 vp8_cuvid(Nvidia CUVID VP8 decoder) hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 vp9_cuvid(Nvidia CUVID VP9 decoder) hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 </pre> <br /> 이 중에서 (제 컴퓨터에는 NVidia 그래픽 카드가 있으니) 마지막에 나온 다음의 항목을 사용하면 될 것 같은데요, <br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > h264_cuvid(Nvidia CUVID H264 decoder) hw-accel: AV_PIX_FMT_CUDA, type: AV_HWDEVICE_TYPE_CUDA, decoder: 1, encoder: 0 </pre> <br /> 그래서 qsvdec.c의 내부 옵션을 다음과 같이 변경했습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > bool useCuda = false; AVHWDeviceType hwDeviceType = (useCuda == true) ? AVHWDeviceType.AV_HWDEVICE_TYPE_CUDA : AVHWDeviceType.AV_HWDEVICE_TYPE_QSV; _hwPixelFormat = (useCuda == true) ? AVPixelFormat.AV_PIX_FMT_CUDA : AVPixelFormat.AV_PIX_FMT_QSV; string formatName = (useCuda == true) ? "h264_cuvid" : "h264_qsv"; ret = ffmpeg.av_hwdevice_ctx_create(&device_ref, hwDeviceType, "auto", null, 0); if (ret < 0) { ret.ThrowExceptionIfError(); Console.WriteLine("Cannot open the hardware device"); throw new ApplicationException(); } decoder = ffmpeg.avcodec_find_decoder_by_name(formatName); if (decoder == null) { Console.WriteLine($"The {formatName} decoder is not present in libavcodec"); throw new ApplicationException(); } </pre> <br /> 이후, av_hwdevice_ctx_create 호출도 성공하고 avcodec_find_decoder_by_name도 정상적인 AVCodec을 반환하며 디코딩 코드도 그대로 변경 없이 동작을 잘 합니다.<br /> <br /> <hr style='width: 50%' /><br /> <br /> 위의 실습을 하고 나니, 이전에 h264 인코딩한 예제의 경우,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > C# - ffmpeg(FFmpeg.AutoGen): Bitmap으로부터 h264 형식의 파일로 쓰기 ; <a target='tab' href='https://www.sysnet.pe.kr/2/0/12970'>https://www.sysnet.pe.kr/2/0/12970</a> </pre> <br /> 이때 코덱 이름이 "h264_mf"로 나왔는데요, 따라서 기본적으로는 하드웨어 가속 혜택을 받지 못하는 코덱이었습니다. 아마도 근래의 PC 환경에서는 CPU든, GPU든 뭐든 하나는 가속을 지원할 것이므로 가능한 하드웨어 가속이 지원되는 코덱을 먼저 찾는 코드를 넣어두는 것이 좋겠습니다. ^^<br /> <br /> <hr style='width: 50%' /><br /> <br /> 그나저나 코덱을 임의로 바꿨는데, 정상적인 디코딩이 되고 있는지 확인할 방법이 뭐가 있을까요? ^^<br /> <br /> decode_packet을 보면, 결국 압축된 packet에서 해제가 된 frame을 받고 있는데요. 따라서, 해당 frame을 그대로 디스크에 저장했다는 것은 곧 <a target='tab' href='https://www.sysnet.pe.kr/2/0/12961#src'>이전에처럼 그대로 쓴 rawvideo 형식의 파일</a>일 것입니다.<br /> <br /> 따라서, 이번에도 다음과 같은 식으로 ffplay를 이용해 재생할 수 있는 명령행을 알아낼 수 있고,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Console.WriteLine($"ffplay -autoexit -f rawvideo -pixel_format {ffmpeg.av_get_pix_fmt_name(decoder_ctx->sw_pix_fmt)} -video_size {decoder_ctx->width}x{decoder_ctx->height} {outputfile}"); </pre> <br /> 실제로 제가 테스트한 동영상의 경우 다음과 같은 명령으로,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > C:\temp> <span style='color: blue; font-weight: bold'>ffplay -autoexit -f rawvideo -pixel_format nv12 -video_size 640x360 C:\temp\output\test2.mp4</span> </pre> <br /> 실행해 재생이 잘 되는 것을 확인할 수 있습니다.<br /> <br /> (사진은 <a target='tab' href='https://www.youtube.com/watch?v=f-sxdm4QIvc'>유튜브 영상 "디에이드"의 "안다은" 님</a>이고 사용을 허락받고 올립니다.)<br /> <img alt='ffmpeg_qsvdec_1.png' src='/SysWebRes/bbs/ffmpeg_qsvdec_1.png' /><br /> <br /> 특이하게 pixel_format이 nv12로 되어 있는데요, 그래서 이것을 다루는 코드가 <a target='tab' href='https://www.sysnet.pe.kr/2/0/12958#yuv2rgb'>이전의 yuv 포맷을 다루는 코드</a>와는 사뭇 다릅니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > ret = ffmpeg.av_hwframe_transfer_data(sw_frame, frame, 0); if (ret < 0) { Console.WriteLine("Error transferring the data to system memory"); } else { <span style='color: blue; font-weight: bold'>for (i = 0; i < byte_array8.Size && sw_frame->data[i] != null; i++) { for (j = 0; j < (sw_frame->height >> (i > 0 ? 1 : 0)); j++) { ffmpeg.avio_write(output_ctx, sw_frame->data[i] + j * sw_frame->linesize[i], sw_frame->width); } }</span> } </pre> <br /> 위에서 sw_frame->format의 값이 23으로 나오는데요,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > // Summary: // planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which // are interleaved (first byte U and the following byte V) AV_PIX_FMT_NV12 = 23, </pre> <br /> 이에 대한 저장 포맷은 아래의 글에 나오는 것처럼,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Recommended 8-Bit YUV Formats for Video Rendering - NV12 ; <a target='tab' href='https://learn.microsoft.com/en-us/windows/win32/medfound/recommended-8-bit-yuv-formats-for-video-rendering#nv12'>https://learn.microsoft.com/en-us/windows/win32/medfound/recommended-8-bit-yuv-formats-for-video-rendering#nv12</a> </pre> <br /> <img alt='yuvformats09.gif' src='/SysWebRes/bbs/yuvformats09.gif' /><br /> <br /> Y 데이터가 먼저 나오고, 이어서, V와 U 데이터가 절반의 height 크기로 각각 절반의 width만큼 차지하고 있기 때문에 저런 희한한 디코딩 코드가 나온 것입니다.<br /> <br /> 실제로 640x360 크기의 동영상에 대해 linesize를 찍어보면, 이렇게 값이 나옵니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > sw_frame->linesize[0] = 640 sw_frame->linesize[1] = 640 sw_frame->linesize[2] = 0 // 이후 모두 0 </pre> <br /> 하드웨어 디코더가 언제나 저렇게 AV_PIX_FMT_NV12 형식으로 반환하는지는 모르겠지만, 혹시 모를 위험을 대비해 조건을 두는 것도 좋을 듯합니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > if (sw_frame->format == (int)AVPixelFormat.AV_PIX_FMT_NV12) { // yuv 데이터 접근 } </pre> <br /> <hr style='width: 50%' /><br /> <br /> 하는 김에, PGM 파일도 저장해 볼까요? ^^ 결국 NV12에서 Y 데이터만 저장하는 것이므로 YUV420P를 다룰 때와 유사하게 다음과 같이 처리할 수 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > if (decoder_ctx->frame_number == 100) { string outputFile = Path.Combine(@"C:\temp\output", "noname_" + decoder_ctx->frame_number + ".pgm"); // <a target='tab' href='https://www.sysnet.pe.kr/2/0/12924#src'>https://www.sysnet.pe.kr/2/0/12924#src</a> pgm_save(sw_frame->data[0], sw_frame->linesize[0], sw_frame->width, sw_frame->height, outputFile); } </pre> <br /> 확인해 보면, 역시 잘 나옵니다. ^^<br /> <br /> (사진은 <a target='tab' href='https://www.youtube.com/watch?v=f-sxdm4QIvc'>유튜브 영상 "디에이드"의 "안다은" 님</a>이고 사용을 허락받고 올립니다.)<br /> <img alt='ffmpeg_qsvdec_2.png' src='/SysWebRes/bbs/ffmpeg_qsvdec_2.png' /><br /> <br /> <hr style='width: 50%' /><br /> <br /> 그건 그렇고, 다 작성하고 나니 예전에 포팅했던 hw_decode.c와 다소 유사합니다. ^^<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > C# - ffmpeg(FFmpeg.AutoGen)로 하드웨어 가속기를 이용한 비디오 디코딩 예제(hw_decode.c) ; <a target='tab' href='https://www.sysnet.pe.kr/2/0/12932'>https://www.sysnet.pe.kr/2/0/12932</a> </pre> <br /> 재미있군요, 그래도 그새 좀 익숙해졌는지, hw_decode.c도 이젠 대충 눈에 들어오는 것 같습니다. ^^<br /> <br /> (<a target='tab' href='https://www.sysnet.pe.kr/bbs/DownloadAttachment.aspx?fid=1907&boardid=331301885'>첨부 파일은 이 글의 예제 코드를 포함</a>합니다.)<br /> (<a target='tab' href='https://github.com/stjeong/ffmpeg_autogen_cs/tree/master/qsvdec'>이 글의 소스 코드는 github에 올려</a>져 있습니다.)<br /> </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
5001
(왼쪽의 숫자를 입력해야 합니다.)