New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Common Metadata Passhtru (Date Handling) #3588
Comments
We could promote the first part of the label to be a subheading for the group. Per our discussion on IRC, I've added title metadata and agree we should limit this feature to title & date, so those can be prefilled using filesystem data in the absence of source container metadata. When passthru common metadata is enabled...Set title metadata to: [ special field entry based on filename ] [×] Only when Source date metadata is blank or missing Set date metadata to:
[×] Only when Source date metadata is blank or missing |
Anyone coming here from #51, please note we are still against setting the destination's filesystem creation/modification dates to the source's. Rather, we are considering providing the option to promote the source's filesystem info to be the destination's container metadata. This way, it is possible to preserve this information for sources with correct filesystem dates but lacking proper metadata (an unfortunately common scenario), without relying on or abusing the filesystem info going forward. Of course, there is the possibility that source's filesystem dates are incorrect (e.g., set to the epoch or copy date after copying across filesystems or downloading on the internet), which the proposed options cannot correct in the absence of proper date metadata. This only serves to illustrate why utilizing filesystem information for such information is unreliable and discouraged. |
For everyone looking for a solution to convert videos and preserve the original file's creation date I can recommend ffWorks It works like a charm and now I like it even more than Handbrake! |
Any updates here? Waiting for the feature. Thanks |
No updates. It's not being worked on at present. Ultimately it's a hobby project for a very small number of people, with very little time. Ergo, patience is required. |
Re-targeting for 1.6.0. |
For anyone interested in this functionality, i made a bash script that can pass through the date using ffmpeg. https://gist.github.com/domportera/d23b02695874c207dede0e7c5d8ecfe3 |
just a suggestion, how about using/integrating FFmpeg library? how about we modify the HandBrake transcoding process to first use FFmpeg to copy the metadata from the input file to a temporary file, and then use HandBrake to transcode the video and audio streams from the temporary file to the final output file. Lastly, we can again use the FFmpeg library to copy the metadata from the temporary file to the final output file. this could be simplified by telling people that they would need to download and install FFmpeg and then just put the program path of FFmpeg in Handbrake. the below code is made with Python and is only for the common metadata import subprocess
input_file = 'input.mp4'
temp_file = 'temp.mp4'
output_file = 'output.mp4'
# Use FFmpeg to copy metadata from input file to temp file
subprocess.run(['ffmpeg', '-i', input_file, '-c', 'copy', '-map_metadata', '0', temp_file])
# Use FFmpeg to copy metadata from temp file to output file
subprocess.run(['ffmpeg', '-i', temp_file, '-c', 'copy', '-map_metadata', '0', output_file]) For the Extended attributes, which i believe is what we need for promoting the source's filesystem info to be the destination's container metadata, would differ from OS to OS. I think the below would work for MacOS: import subprocess
source_file = "/path/to/source.mp4"
destination_file = "/path/to/destination.mp4"
# Use FFmpeg to copy metadata from source to destination
subprocess.call(["ffmpeg", "-i", source_file, "-map_metadata", "0", "-c", "copy", destination_file])
# Extract extended attributes of the source file
extended_attributes = subprocess.check_output(["xattr", "-l", source_file]).decode()
# Use HandbrakeCLI to convert the source file to destination file and pass the extended attributes
subprocess.call(["HandBrakeCLI", "-i", source_file, "-o", destination_file, "--all-metadata="+extended_attributes]) For Windows, this might work: #include <windows.h>
#include <tchar.h>
int main()
{
// Open the source file
HANDLE hSource = CreateFile(_T("source.txt"), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hSource == INVALID_HANDLE_VALUE)
{
_tprintf(_T("CreateFile failed (%d)\n"), GetLastError());
return 1;
}
// Get the extended metadata of the source file
FILE_BASIC_INFO sourceInfo;
if (!GetFileInformationByHandleEx(hSource, FileBasicInfo, &sourceInfo, sizeof(sourceInfo)))
{
_tprintf(_T("GetFileInformationByHandleEx failed (%d)\n"), GetLastError());
CloseHandle(hSource);
return 1;
}
// Close the handle to the source file
CloseHandle(hSource);
// Open the output file
HANDLE hOutput = CreateFile(_T("output.txt"), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hOutput == INVALID_HANDLE_VALUE)
{
_tprintf(_T("CreateFile failed (%d)\n"), GetLastError());
return 1;
}
// Set the extended metadata of the output file
if (!SetFileInformationByHandle(hOutput, FileBasicInfo, &sourceInfo, sizeof(sourceInfo)))
{
_tprintf(_T("SetFileInformationByHandle failed (%d)\n"), GetLastError());
CloseHandle(hOutput);
return 1;
}
// Close the handle to the output file
CloseHandle(hOutput);
return 0;
} Then for Linux (also not sure): ffmpeg -i sourcefile.mp4 -map_metadata 0 -c copy -y -map_metadata:s:v 0:s:v -map_metadata:s:a 0:s:a destinationfile.mp4 If you have time, please check if the code i provided could be used to add the metadata passthru functionality. Thanks for reading |
HandBrake uses libav for a variety of things including muxing already. Changing the creation_time tag is relatively easy. You can pass through the original files creation_time tag simply by commenting out a few lines of code in libhb/muxavformat.c. The problem is that there are competing alternatives to what that tag should be set to and therefor UI issues surrounding how to allow the various alternatives to be selected. Since this is a pretty low priority item (i.e. none of the small number of HandBrake developers uses this feature) it simply hasn't received much attention. |
Maybe not the developers but a lot of end users - at least if I browse throught the topics in the forum and related requests here. |
HandBrake is opensource, and everyone can contribute to it, patches are very welcomed. |
Ticket name has a typo, should be 'Passthru' |
I think this is a good idea, but if you want to perform batch operations, it would be too cumbersome to change the file names one by one. Can we improve it so that all files in the target path with the same names as the files in the source path can have their matching EXIF source data copied over? |
Since we now have exposed the common metadata passthru we can potentially extend the behaviour for the date field to handle a common request to copy the source filesystem dates over.
New global preferences under "Output Files" section:
"When passthru common metadata is enabled, set the date field in the container metadata to:" [DROPDOWN]
[X] Only when source container metadata field is empty. (Uses source container date)
The text was updated successfully, but these errors were encountered: