성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] 그냥 RSS Reader 기능과 약간의 UI 편의성 때문에 사용...
[이종효] 오래된 소프트웨어는 보안 위협이 되기도 합니다. 혹시 어떤 기능...
[정성태] @Keystroke IEEE의 문서를 소개해 주시다니... +_...
[손민수 (Keystroke)] 괜히 듀얼채널 구성할 때 한번에 같은 제품 사라고 하는 것이 아...
[정성태] 전각(Full-width)/반각(Half-width) 기능을 토...
[정성태] Vector에 대한 내용은 없습니다. Vector가 닷넷 BCL...
[orion] 글 읽고 찾아보니 디자인 타임에는 InitializeCompon...
[orion] 연휴 전에 재현 프로젝트 올리자 생각해 놓고 여의치 않아서 못 ...
[정성태] 아래의 글에 정리했으니 참고하세요. C# - Typed D...
[정성태] 간단한 재현 프로젝트라도 있을까요? 저런 식으로 설명만 해...
글쓰기
제목
이름
암호
전자우편
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)를 이용해 멀티미디어 파일의 메타데이터를 보여주는 예제(metadata.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)를 이용해 MP2 오디오 파일 디코딩 예제(decode_audio.c) ; <a target='tab' href='https://www.sysnet.pe.kr/2/0/12933'>https://www.sysnet.pe.kr/2/0/12933</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/metadata_8c-example.html'>metadata.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.Runtime.InteropServices; namespace FFmpegApp1 { internal unsafe class Program { static void 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()}"); #endif Console.WriteLine(); Console.WriteLine($"LIBAVFORMAT Version: {ffmpeg.LIBAVFORMAT_VERSION_MAJOR}.{ffmpeg.LIBAVFORMAT_VERSION_MINOR}"); show_metadata(@"D:\media_sample\test.mp3"); } private static void show_metadata(string filePath) { AVFormatContext* fmt_ctx = null; do { int ret = ffmpeg.avformat_open_input(&fmt_ctx, filePath, null, null); if (ret != 0) { break; } ret = ffmpeg.avformat_find_stream_info(fmt_ctx, null); if (ret < 0) { Console.WriteLine("Cannot find stream information"); break; } AVDictionaryEntry* tag = null; while ((tag = ffmpeg.av_dict_get(fmt_ctx->metadata, "", tag, ffmpeg.AV_DICT_IGNORE_SUFFIX)) != null) { string key = Marshal.PtrToStringAnsi(new IntPtr(tag->key)); string value = Marshal.PtrToStringAnsi(new IntPtr(tag->value)); Console.WriteLine($"{key} = {value}"); } } while (false); if (fmt_ctx != null) { ffmpeg.avformat_close_input(&fmt_ctx); } } } } </pre> <br /> 위의 코드를 <a target='tab' href='https://www.genie.co.kr/'>지니 뮤직</a>을 통해 구매한 "<a target='tab' href='https://www.genie.co.kr/detail/albumInfo?axnm=80460108'>묘해, 너와</a>" MP3 파일을 입력으로 하면 다음과 같은 출력 결과를 볼 수 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > comment = KT뮤직 album = 연애의 발견 OST Part 4 (KBS 월화드라마) genre = Soundtrack title = 묘해, 너와 artist = 어쿠스틱 콜라보 album_artist = 어쿠스틱 콜라보 disc = 1 track = 1 ENCODEDBY = KT MUSIC CORP. lyrics- = 니 생각에 꽤 즐겁고 니 생각에 퍽 외로워 이상한 일이야 누굴 좋아한단 건 ...[생략]... 그래서 한 번더 가보고 싶어져 너와 date = 2014 </pre> <br /> 반면, youtube-dl을 이용해 유튜브의 영상을 다운로드한 MP4 파일을 대상으로 하면 다음과 같이 간단한 메타데이터 정보만 나옵니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > major_brand = isom minor_version = 512 compatible_brands = isomiso2avc1mp41 encoder = Lavf58.45.100 </pre> <br /> (<a target='tab' href='https://www.sysnet.pe.kr/bbs/DownloadAttachment.aspx?fid=1887&boardid=331301885'>첨부 파일은 이 글의 예제 코드를 포함</a>합니다.)<br /> (<a target='tab' href='https://github.com/stjeong/ffmpeg_autogen_cs/tree/master/metadata'>이 글의 소스 코드는 github에 올려</a>져 있습니다.) </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
1816
(왼쪽의 숫자를 입력해야 합니다.)