tag.pl 696 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use Getopt::Long;
  5. use Data::Dumper;
  6. my ($title, $artist, $file, $volume);
  7. GetOptions(
  8. "title=s" => \$title,
  9. "artist=s" => \$artist,
  10. "file=s" => \$file,
  11. "volume=s" => \$volume
  12. ) or die $@;
  13. if (-f $file) {
  14. my $tmp = $$;
  15. if ($volume) {
  16. system("avconv -i \"$file\" -vcodec copy -af \"volume=$volume\" /tmp/file$tmp.mp4");
  17. system("mv /tmp/file$tmp.mp4 \"$file\"");
  18. }
  19. if ($title && $artist) {
  20. system("avconv -i \"$file\" -metadata artist=\"$artist\" -metadata title=\"$title\" -codec copy -vcodec copy /tmp/file$tmp.mp4");
  21. system("mv /tmp/file$tmp.mp4 \"$file\"");
  22. }
  23. } else {
  24. print "$file not found.\n";
  25. }