2016-07-28 3 views
2

나는 메타 데이터에서 비디오 생성 날짜와 시간을 얻을 수있는 코드를 작성하고 있습니다, 나는 완벽에 작동안드로이드 MediaMetadataRetriever.METADATA_KEY_DATE 갤럭시 비디오의 날짜 S7

MediaMetadataRetriever retriever = new MediaMetadataRetriever(); 
retriever.setDataSource(path_to_video); 
String date = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DATE); 

작성 날짜를 얻으려면 다음 코드를 사용하고 삼성 갤럭시 S7을 제외한 모든 장치는 "YYYY MM DD"형식으로 만 날짜를 반환합니다. 타임 스탬프가 필요하지 않습니다. 날짜와 타임 스탬프가 모두 필요합니다.

이 점에 대해 도움을 주시면 감사하겠습니다. 비디오 FFMPEG의 메타 데이터 정보를 인쇄하기 위해

답변

1

ffmpeg -i input_video -f ffmetadata metadata.txt 

이 명령은 필요한 정보를 얻을하는 데 도움이, 사용하는 최선의 방법입니다.

0

비슷한 문제가 발생했습니다. 두 날짜 형식을 모두 다음과 같이 처리했습니다.

//pass date fetched from MetadataRetriever class to below method. 

    public static String formatMediaDate(String date){ 
      String formattedDate = ""; 
      try { 
       Date inputDate = new SimpleDateFormat("yyyyMMdd'T'HHmmss", Locale.getDefault()).parse(date); 
       formattedDate = new SimpleDateFormat("dd MMMM yyyy", Locale.getDefault()).format(inputDate); 
      } 
      catch (Exception e){ 
       Log.w(TAG, "error parsing date: ", e); 
       try { 
        Date inputDate = new SimpleDateFormat("yyyy MM dd", Locale.getDefault()).parse(date); 
        formattedDate = new SimpleDateFormat("dd MMMM yyyy", Locale.getDefault()).format(inputDate); 
       } catch (Exception ex) { 
        Log.e(TAG, "error parsing date: ", ex); 
       } 
      } 
      return formattedDate; 
     }